diff options
author | Bjørn Forsman <bjorn.forsman@gmail.com> | 2022-12-29 13:39:01 +0100 |
---|---|---|
committer | Bjørn Forsman <bjorn.forsman@gmail.com> | 2023-01-04 21:45:58 +0100 |
commit | 295c552dc92ac63ff9d0a979f723c8dfa058fb5f (patch) | |
tree | 1b944d5b9901c48419eeb96ca8895aaf72703fd9 | |
parent | 446d737bee93ff6dd9d10f37f5216551efd60431 (diff) | |
download | nixpkgs-295c552dc92ac63ff9d0a979f723c8dfa058fb5f.tar nixpkgs-295c552dc92ac63ff9d0a979f723c8dfa058fb5f.tar.gz nixpkgs-295c552dc92ac63ff9d0a979f723c8dfa058fb5f.tar.bz2 nixpkgs-295c552dc92ac63ff9d0a979f723c8dfa058fb5f.tar.lz nixpkgs-295c552dc92ac63ff9d0a979f723c8dfa058fb5f.tar.xz nixpkgs-295c552dc92ac63ff9d0a979f723c8dfa058fb5f.tar.zst nixpkgs-295c552dc92ac63ff9d0a979f723c8dfa058fb5f.zip |
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.
-rw-r--r-- | nixos/modules/services/monitoring/apcupsd.nix | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/nixos/modules/services/monitoring/apcupsd.nix b/nixos/modules/services/monitoring/apcupsd.nix index d4216b44cdc..666479c78a8 100644 --- a/nixos/modules/services/monitoring/apcupsd.nix +++ b/nixos/modules/services/monitoring/apcupsd.nix @@ -62,6 +62,21 @@ let ); + # Ensure the CLI uses our generated configFile + wrappedBinaries = pkgs.runCommandLocal "apcupsd-wrapped-binaries" + { nativeBuildInputs = [ pkgs.makeWrapper ]; } + '' + for p in "${lib.getBin pkgs.apcupsd}/bin/"*; do + bname=$(basename "$p") + makeWrapper "$p" "$out/bin/$bname" --add-flags "-f ${configFile}" + done + ''; + + apcupsdWrapped = pkgs.symlinkJoin { + name = "apcupsd-wrapped"; + # Put wrappers first so they "win" + paths = [ wrappedBinaries pkgs.apcupsd ]; + }; in { @@ -138,7 +153,7 @@ in } ]; # Give users access to the "apcaccess" tool - environment.systemPackages = [ pkgs.apcupsd ]; + environment.systemPackages = [ apcupsdWrapped ]; # NOTE 1: apcupsd runs as root because it needs permission to run # "shutdown" |