1 { lib, stdenv, fetchurl, pkg-config, systemd, util-linux, coreutils, wall, hostname, man
2 , enableCgiScripts ? true, gd
6 assert enableCgiScripts -> gd != null;
8 stdenv.mkDerivation rec {
13 url = "mirror://sourceforge/${pname}/${pname}-${version}.tar.gz";
14 sha256 = "0rwqiyzlg9p0szf3x6q1ppvrw6f6dbpn2rc5z623fk3bkdalhxyv";
17 nativeBuildInputs = [ pkg-config man util-linux ];
18 buildInputs = lib.optional enableCgiScripts gd;
21 sed -e "s,\$(INSTALL_PROGRAM) \$(STRIP),\$(INSTALL_PROGRAM)," \
22 -i ./src/apcagent/Makefile ./autoconf/targets.mak
26 sed -i 's|/bin/cat|${coreutils}/bin/cat|' configure
29 # ./configure ignores --prefix, so we must specify some paths manually
30 # There is no real reason for a bin/sbin split, so just use bin.
32 "--bindir=${placeholder "out"}/bin"
33 "--sbindir=${placeholder "out"}/bin"
34 "--sysconfdir=${placeholder "out"}/etc/apcupsd"
35 "--mandir=${placeholder "out"}/share/man"
36 "--with-halpolicydir=${placeholder "out"}/share/halpolicy"
37 "--localstatedir=/var"
39 "--with-log-dir=/var/log/apcupsd"
40 "--with-pwrfail-dir=/run/apcupsd"
41 "--with-lock-dir=/run/lock"
44 "ac_cv_path_SHUTDOWN=${systemd}/sbin/shutdown"
45 "ac_cv_path_WALL=${wall}/bin/wall"
46 ] ++ lib.optionals enableCgiScripts [
48 "--with-cgi-bin=${placeholder "out"}/libexec/cgi-bin"
52 for file in "$out"/etc/apcupsd/*; do
53 sed -i -e 's|^WALL=.*|WALL="${wall}/bin/wall"|g' \
54 -e 's|^HOSTNAME=.*|HOSTNAME=`${hostname}/bin/hostname`|g' \
59 passthru.tests.smoke = nixosTests.apcupsd;
62 description = "Daemon for controlling APC UPSes";
63 homepage = "http://www.apcupsd.com/";
64 license = licenses.gpl2Only;
65 platforms = platforms.linux;
66 maintainers = [ maintainers.bjornfor ];