nixpkgs-suyu/pkgs/servers/apcupsd/default.nix

57 lines
1.8 KiB
Nix
Raw Normal View History

{ stdenv, fetchurl, pkgconfig, systemd, utillinux, coreutils, nettools, man
, enableCgiScripts ? true, gd
}:
2014-04-13 20:28:43 +02:00
assert enableCgiScripts -> gd != null;
stdenv.mkDerivation rec {
pname = "apcupsd";
2015-06-08 08:52:06 +02:00
name = "${pname}-3.14.13";
src = fetchurl {
2013-07-17 21:10:56 +02:00
url = "mirror://sourceforge/${pname}/${name}.tar.gz";
2015-06-08 08:52:06 +02:00
sha256 = "1y83bly5bgpjbfaxxwmdk2mndbi4cw0svq5z9n6byj043phbvv2p";
};
buildInputs = [ pkgconfig utillinux man ] ++ stdenv.lib.optional enableCgiScripts gd;
# ./configure ignores --prefix, so we must specify some paths manually
# There is no real reason for a bin/sbin split, so just use bin.
preConfigure = ''
export ac_cv_path_SHUTDOWN=${systemd}/sbin/shutdown
export ac_cv_path_WALL=${utillinux}/bin/wall
sed -i 's|/bin/cat|${coreutils}/bin/cat|' configure
export configureFlags="\
--bindir=$out/bin \
--sbindir=$out/bin \
--sysconfdir=$out/etc/apcupsd \
--mandir=$out/share/man \
--with-halpolicydir=$out/share/halpolicy \
--localstatedir=/var/ \
--with-nologin=/run \
--with-log-dir=/var/log/apcupsd \
--with-pwrfail-dir=/run/apcupsd \
--with-lock-dir=/run/lock \
--with-pid-dir=/run \
--enable-usb \
${stdenv.lib.optionalString enableCgiScripts "--enable-cgi --with-cgi-bin=$out/libexec/cgi-bin"}
"
'';
postInstall = ''
for file in "$out"/etc/apcupsd/*; do
sed -i -e 's|^WALL=.*|WALL="${utillinux}/bin/wall"|g' \
-e 's|^HOSTNAME=.*|HOSTNAME=`${nettools}/bin/hostname`|g' \
"$file"
done
'';
meta = with stdenv.lib; {
description = "Daemon for controlling APC UPSes";
homepage = http://www.apcupsd.com/;
license = licenses.gpl2;
platforms = platforms.linux;
maintainers = [ maintainers.bjornfor ];
};
}