Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upower: Upgrade to 1.90.6 and extend CriticalPowerActions #341086

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

benjamb
Copy link
Contributor

@benjamb benjamb commented Sep 10, 2024

Description of changes

  • Upgrade to 1.90.6
  • Support Suspend and Ignore CriticalPowerActions introduced in this release.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.11 Release Notes (or backporting 23.11 and 24.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` labels Sep 10, 2024
@benjamb
Copy link
Contributor Author

benjamb commented Sep 10, 2024

When I build locally, the compilation succeeds, but I run into test failures.

Copy link
Member

@jtojnar jtojnar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -218,6 +246,7 @@ in
TimeLow = cfg.timeLow;
TimeCritical = cfg.timeCritical;
TimeAction = cfg.timeAction;
AllowRiskyCriticalPowerAction = cfg.allowRiskyCriticalPowerAction;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh, we should really switch to RFC 42-style settings so that we do not need to keep adding the options forever like this. Opened #341107 for now

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That does indeed seem like better way of doing things.

@@ -80,6 +81,7 @@ stdenv.mkDerivation (finalAttrs: {
buildInputs = [
libgudev
libusb1
polkit
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the diff, https://gitlab.freedesktop.org/upower/upower/-/commit/0c9ba8048fd38567aa1292f3760fbff48904c3ca sets POLKIT_ACTIONDIR define but it does not look like it is currently used? If not, that should not be an issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, it doesn't look like it's used.

pkgs/os-specific/linux/upower/default.nix Outdated Show resolved Hide resolved
@benjamb benjamb force-pushed the upower-critical-actions branch 2 times, most recently from 8c1e1f5 to ad1a29d Compare September 11, 2024 11:15
@ofborg ofborg bot requested a review from jtojnar September 11, 2024 21:23
@benjamb benjamb force-pushed the upower-critical-actions branch 3 times, most recently from 9a67952 to 508db42 Compare September 18, 2024 08:26
@benjamb benjamb changed the title upower: Upgrade to 1.90.5 and extend CriticalPowerActions upower: Upgrade to 1.90.6 and extend CriticalPowerActions Sep 18, 2024
@benjamb
Copy link
Contributor Author

benjamb commented Sep 18, 2024

@jtojnar I've bumped up to 1.90.6, which avoids the need for patching the tests.

@benjamb
Copy link
Contributor Author

benjamb commented Oct 1, 2024

@jtojnar Don't suppose you have time for another review pass?

Copy link
Contributor

@jfly jfly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this change! I just had my laptop die on my for the upteenth time, and decided to finally set up upower.

I don't have hibernation support enabled on my machine, so I want this Sleep functionality!

assertions = [
{
assertion =
with builtins;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, feel free to ignore: what is builtins used for here? Is it just elem? I think this would be nicer as just a inherit (builtins) elem; in the let block instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

];
riskyActionEnabled = elem cfg.criticalPowerAction riskyActions;
in
!cfg.allowRiskyCriticalPowerAction && riskyActionEnabled;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, feel free to ignore: would this be cleaner written as riskyActionEnabled -> cfg.allowRiskyCriticalPowerAction? I think it's the same boolean logic, and reads a bit more nicely ("if a risky action is enabled, then we must allow risky actions").

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, is the current assertion correct? I'm trying out this patch locally, and I've set services.upower.criticalPowerAction = "Suspend", so riskyActionEnabled = true. I have not yet set services.upower.allowRiskyCriticalPowerAction to anything, so it's just the default value of false.

Plugging that into this expression, I get:

!cfg.allowRiskyCriticalPowerAction && riskyActionEnabled => !false && true => true && true => true

That's wrong, right? Don't we want this configuration to trigger the assertion (i.e., evaluate to false)?

I think the riskyActionEnabled -> cfg.allowRiskyCriticalPowerAction I suggested above is correct. Or perhaps !riskyActionEnabled or cfg.allowRiskyCriticalPowerAction.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL ->.

Quite right. I was treating that as an expression that when evaluated as true would trigger an error, rather than (what should have been clear to me) when the assertion condition is not met.

Good spot!

(UPS or laptop batteries) supplying the computer
(UPS or laptop batteries) supplying the computer.

When set to `Suspend` or `Ignore`, `allowRiskyCriticalPowerAction`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recently learned there's special syntax for referencing options. See https://github.com/NixOS/nixpkgs/tree/master/doc#roles

Suggested change
When set to `Suspend` or `Ignore`, `allowRiskyCriticalPowerAction`
When set to `Suspend` or `Ignore`, {option}`services.upower.allowRiskyCriticalPowerAction`

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to know! Done.

@benjamb benjamb force-pushed the upower-critical-actions branch from 508db42 to 57077af Compare October 9, 2024 23:40
Copy link
Contributor

@jfly jfly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Latest changes LGTM

@benjamb
Copy link
Contributor Author

benjamb commented Oct 23, 2024

@jfly @jtojnar What's required of me in order for this to land? It would be great to get this in before 24.11.

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-already-reviewed/2617/2062

@jfly
Copy link
Contributor

jfly commented Oct 26, 2024

I've been using this for a couple weeks and it's working great for me.

I've added a link to this PR in https://discourse.nixos.org/t/prs-already-reviewed/2617/2062.

@wegank wegank added 12.approvals: 1 This PR was reviewed and approved by one reputable person 2.status: merge conflict This PR has merge conflicts with the target branch labels Oct 29, 2024
@jfly
Copy link
Contributor

jfly commented Nov 22, 2024

@benjamb, do you have time to rebase this branchb and address the conflicts? If it's helpful, I'm maintaining a branch here with your changes: https://github.com/jfly/nixpkgs/tree/upower-critical-actions

@benjamb benjamb force-pushed the upower-critical-actions branch from 57077af to 789bb45 Compare November 22, 2024 14:11
@benjamb
Copy link
Contributor Author

benjamb commented Nov 22, 2024

@benjamb, do you have time to rebase this brand and address the conflicts?

Done!

@ofborg ofborg bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Nov 23, 2024
@wegank wegank removed the 12.approvals: 1 This PR was reviewed and approved by one reputable person label Nov 23, 2024
@jfly
Copy link
Contributor

jfly commented Dec 16, 2024

@jtojnar, any chance of getting this merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 11-100 10.rebuild-linux: 101-500
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants