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

nixos/ups: add envvars for interactive use #341080

Merged

Conversation

bjornfor
Copy link
Contributor

Description of changes

Set environment variables that fix running upsdrvctl interactively.

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.

No functional change, but more DRY.
This allows using upsdrvctl interactively, which otherwise tries to use
a missing ups.conf in the Nix store, instead of the correct
/etc/nut/ups.conf.
@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
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild 10.rebuild-linux: 1-10 labels Sep 10, 2024
@bjornfor bjornfor added backport release-24.05 Backport PR automatically labels Sep 10, 2024
Copy link
Contributor

@philiptaron philiptaron left a comment

Choose a reason for hiding this comment

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

Sure. It seems like this should be in the derivation for nut itself, but sure.

Copy link
Contributor

@Majiir Majiir left a comment

Choose a reason for hiding this comment

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

Sure.

My thought exactly. 😄

Out of curiosity, what does "running upsdrvctl interactively" look like?

@wegank wegank added the 12.approvals: 2 This PR was reviewed and approved by two reputable people label Sep 11, 2024
@bjornfor
Copy link
Contributor Author

Sure.

My thought exactly. 😄

Out of curiosity, what does "running upsdrvctl interactively" look like?

I'd paste the output, but I'm actually upgrading hardware tonight, so I don't have it readily available.

For example, see "Testing shutdown" from https://networkupstools.org/docs/user-manual.chunked/ar01s06.html. You'd run upsdrvctl -t shutdown and it logs what it'll do. Before this PR it would fail, after it succeeds.

@bjornfor bjornfor merged commit 1cb392f into NixOS:master Sep 11, 2024
29 checks passed
@bjornfor bjornfor deleted the nixos-ups-add-envvars-for-interactive-use branch September 11, 2024 19:14
@bjornfor
Copy link
Contributor Author

It seems like this should be in the derivation for nut itself, but sure.

Yes, that might be a good idea.

Copy link
Contributor

Successfully created backport PR for release-24.05:

@bjornfor
Copy link
Contributor Author

Out of curiosity, what does "running upsdrvctl interactively" look like?

For example:

Before:

$ upsdrvctl -t shutdown
Network UPS Tools - UPS driver controller 2.8.2
*** Testing mode: not calling exec/kill/signal
   0.000000     [D2] 
If you're not a NUT core developer, chances are that you're told to enable debugging
to see why a driver isn't working for you. We're sorry for the confusion, but this is
the 'upsdrvctl' wrapper, not the driver you're interested in.

Below you'll find one or more lines starting with 'exec:' followed by an absolute
path to the driver binary and some command line option. This is what the driver
starts and you need to copy and paste that line and append the debug flags to that
line (less the 'exec:' prefix).

Alternately, provide an additional '-d' (lower-case) parameter to 'upsdrvctl' to
pass its current debug level to the launched driver, and '-B' keeps it backgrounded.

   0.000030     Can't open /nix/store/qbb38bmhb74qad66xarnh26wms6rfawr-nut-2.8.2/etc/ups.conf: Can't open /nix/store/qbb38bmhb74qad66xarnh26wms6rfawr-nut-2.8.2/etc/ups.conf: No such file or directory
   0.000034     [D1] Completed the job of upsdrvctl tool, cleaning up and exiting now
   0.000036     [D1] Completed the job of upsdrvctl tool, clean-up finished, exiting now
[...error exit code 1...]

After:

$ upsdrvctl -t shutdown
Network UPS Tools - UPS driver controller 2.8.2
*** Testing mode: not calling exec/kill/signal
   0.000000     [D2] 
If you're not a NUT core developer, chances are that you're told to enable debugging
to see why a driver isn't working for you. We're sorry for the confusion, but this is
the 'upsdrvctl' wrapper, not the driver you're interested in.

Below you'll find one or more lines starting with 'exec:' followed by an absolute
path to the driver binary and some command line option. This is what the driver
starts and you need to copy and paste that line and append the debug flags to that
line (less the 'exec:' prefix).

Alternately, provide an additional '-d' (lower-case) parameter to 'upsdrvctl' to
pass its current debug level to the launched driver, and '-B' keeps it backgrounded.

   0.000046     [D1] upsdrvctl commanding all drivers (1 found): (null)
   0.000049     [D1] Shutdown UPS: eaton3s
   0.000051     [D2] exec:  /nix/store/qbb38bmhb74qad66xarnh26wms6rfawr-nut-2.8.2/bin/usbhid-ups -a eaton3s -k
   0.000054     [D1] upsdrvctl: successfully finished
   0.000056     [D1] Completed the job of upsdrvctl tool, cleaning up and exiting now
   0.000059     [D1] Completed the job of upsdrvctl tool, clean-up finished, exiting now
[...successful exit code...]

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: 0 This PR does not cause any packages to rebuild 10.rebuild-linux: 1-10 12.approvals: 2 This PR was reviewed and approved by two reputable people backport release-24.05 Backport PR automatically
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants