-
-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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 options for essential config files #213006
Conversation
Is there some reason to keep these commits separated? I think these should be squashed when the PR is finished, you can still keep the commit titles in the commit message body. Have you tried to hook up upsmon even though this PR doesn't do anything automatically? Yes I think this should be in release-notes when completed. |
I thought it would be easier to review with multiple commits. I'll squash them once the changes are otherwise ready to merge.
Yes, I've tested |
99a2ffa
to
bda8d27
Compare
Updated the secrets logic to use |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/prs-ready-for-review/3032/2683 |
I've been running this quite happily for a few weeks, but I'm not sure about handling the severely breaking changes - perhaps this should be gated behind state versions? |
- Ensure NUT_STATEPATH exists (fixes service startup) - Use mode option to enable services (fixes NixOS#113735) - Remove extraneous slash in paths (fixes confusing logs) - Support reload for upsmon and upsd - Remove ExecStart wrapper scripts
This is great @Majiir, thank you! |
@amaxine Thanks for the merge. Regarding breaking changes: When |
@Majiir yup, in the context of that and the overhauled release notes format for 24.05 (plus 23.11 being just out the door), I felt like it's not actually that awful to merge a severely breaking change right now. Thanks a bunch for this work! |
Something has been missed here. I'm sure the changes are good, and the bit about tripping the "MINSUPPLIES" assertion is true so I knew I had to go looking for something to migrate, however:
Again, I have no problem with breaking changes, but there needs to be better information on what I should do. I have this as my current config, power.ups = {
enable = true;
ups.pw5110 = {
port = "auto";
driver = "bcmxcp_usb";
};
}; what should the new one look like? The example above has some passwords and users, but I don't know what they are and there's no password I'm aware of. If they're now required, can they not be generated automatically (e.g. random) if no specific settings are given? |
@dcarosone Can you help me better understand your setup and what you intend for it to do? If that's your only config and you didn't manually create any config files, then you would have been missing Regarding the options: This module exposes options for NUT (Network UPS Tools) services and their config files. You can find information about them in their man pages ( |
Sure, it's the simplest case possible: a single minipc workstation on a dedicated small ups. I just want monitoring and the box to shut down when the UPS is nearing discharge. Logging of power states/transitions and other interesting events is a bonus, but seems to be happening. I would have expected (naively) that credentials and other similar settings were only relevant for multi-host network setups, and that seems to have been the case for me until now.
Well! I took a look.. [root@oenone:/etc/nut]# l
total 40K
drwxr-xr-x 2 root root 8 Dec 10 13:35 .
drwxr-xr-x 47 root root 108 Dec 10 13:35 ..
lrwxrwxrwx 1 root root 24 Dec 10 13:35 nut.conf -> /etc/static/nut/nut.conf
lrwxrwxrwx 1 root root 24 Dec 10 13:35 ups.conf -> /etc/static/nut/ups.conf
-rw-r--r-- 1 root root 0 Dec 20 2021 upsd.conf
-rwx------ 1 root root 74 Dec 21 2021 upsd.users
-r--r--r-- 1 root root 16K Dec 21 2021 upsmon.conf
lrwxrwxrwx 1 root root 29 Dec 10 13:35 upssched.conf -> /etc/static/nut/upssched.conf So,
I said:
… but it seems what I missed was that I did have existing config outside nix. My apologies, I have no recollection whatsoever of having created this, but seemingly I did.
Yeah. Now that it's managed by nix, I can migrate whatever is in these files, and I guess it's worth investing the time to look at all this config. I can put the credential in agenix and configure a remote client.
I do think an example like the one at the top of this PR, and a couple of pointers like the paragraph above, would be useful in the documentation of the new options. I'll see what concrete improvements I can suggest when I've figure out the details. |
Ok, step 1 (the minimal migration) is done successfully. Other than ups specifics and agenix secrets stuff, the only real difference to your example was upsmon = "primary"; based on the manpage, though my existing config had "master" there, too. I assume either is valid for compat, but chose to use the better modern term encouraged by the documentation. In terms of generated output differences, in
|
Thanks for leaving the example in the PR's body, it was essential to understand what to do. |
Description
power.ups
for configuringupsd.users
,upsd.conf
, andupsmon.conf
. (Fixes NixOS power.ups module does not generate all needed config files #91681.)mode
option to enable the appropriate services. (Fixes power.ups does not work correctly for netclient #113735.)/var/lib/nut
doesn't already exist.upsmon
andupsd
.Design
My goal with the new options is to have sensible defaults that minimize the configuration necessary to run a basic
standalone
setup:This is enough to monitor the UPS and shut down the system when the battery is low.
Testing
I tested these changes with one node in a
standalone
configuration attached to the UPS and a second node connected in anetclient
configuration. The first node uses a customNOTIFYCMD
and the second node usesupssched
. I tested basic power loss scenarios and tested that activating config changes reloads services successfully.Things done
sandbox = true
set innix.conf
? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)nixos/doc/manual/md-to-db.sh
to update generated release notes