mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2025-01-05 02:23:07 +03:00
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.
This commit is contained in:
parent
446d737bee
commit
295c552dc9
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user