lol

nixos/apcupsd: wrap CLI with "-f ${configFile}"

This ensures that the CLI is in sync with the service configuration.

(I tried building apcupsd with --sysconfdir=/etc instead, but it wants
to install stuff there at build time, so I backed out.)

Fixes https://github.com/NixOS/nixpkgs/issues/208204.

+16 -1
+16 -1
nixos/modules/services/monitoring/apcupsd.nix
··· 62 62 63 63 ); 64 64 65 + # Ensure the CLI uses our generated configFile 66 + wrappedBinaries = pkgs.runCommandLocal "apcupsd-wrapped-binaries" 67 + { nativeBuildInputs = [ pkgs.makeWrapper ]; } 68 + '' 69 + for p in "${lib.getBin pkgs.apcupsd}/bin/"*; do 70 + bname=$(basename "$p") 71 + makeWrapper "$p" "$out/bin/$bname" --add-flags "-f ${configFile}" 72 + done 73 + ''; 74 + 75 + apcupsdWrapped = pkgs.symlinkJoin { 76 + name = "apcupsd-wrapped"; 77 + # Put wrappers first so they "win" 78 + paths = [ wrappedBinaries pkgs.apcupsd ]; 79 + }; 65 80 in 66 81 67 82 { ··· 138 153 } ]; 139 154 140 155 # Give users access to the "apcaccess" tool 141 - environment.systemPackages = [ pkgs.apcupsd ]; 156 + environment.systemPackages = [ apcupsdWrapped ]; 142 157 143 158 # NOTE 1: apcupsd runs as root because it needs permission to run 144 159 # "shutdown"