2018-03-27 03:37:49 +00:00
|
|
|
{ stdenv, fetchurl, pkgconfig, systemd, utillinux, coreutils, wall, hostname, man
|
2013-07-16 23:53:30 +00:00
|
|
|
, enableCgiScripts ? true, gd
|
|
|
|
}:
|
|
|
|
|
2014-04-13 18:28:43 +00:00
|
|
|
assert enableCgiScripts -> gd != null;
|
|
|
|
|
2013-07-16 23:53:30 +00:00
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "apcupsd";
|
2016-10-17 09:38:07 +00:00
|
|
|
name = "${pname}-3.14.14";
|
2013-07-16 23:53:30 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
2013-07-17 19:10:56 +00:00
|
|
|
url = "mirror://sourceforge/${pname}/${name}.tar.gz";
|
2016-10-17 09:38:07 +00:00
|
|
|
sha256 = "0rwqiyzlg9p0szf3x6q1ppvrw6f6dbpn2rc5z623fk3bkdalhxyv";
|
2013-07-16 23:53:30 +00:00
|
|
|
};
|
|
|
|
|
2017-09-05 21:26:13 +00:00
|
|
|
nativeBuildInputs = [ pkgconfig ];
|
|
|
|
buildInputs = [ utillinux man ] ++ stdenv.lib.optional enableCgiScripts gd;
|
2013-07-16 23:53:30 +00:00
|
|
|
|
2017-08-15 19:57:57 +00:00
|
|
|
prePatch = ''
|
|
|
|
sed -e "s,\$(INSTALL_PROGRAM) \$(STRIP),\$(INSTALL_PROGRAM)," \
|
|
|
|
-i ./src/apcagent/Makefile ./autoconf/targets.mak
|
|
|
|
'';
|
|
|
|
|
2013-07-16 23:53:30 +00:00
|
|
|
# ./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
|
2018-03-27 18:17:10 +00:00
|
|
|
export ac_cv_path_WALL=${wall}/bin/wall
|
2013-07-16 23:53:30 +00:00
|
|
|
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/ \
|
2013-07-21 18:58:26 +00:00
|
|
|
--with-nologin=/run \
|
2013-07-16 23:53:30 +00:00
|
|
|
--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
|
2018-03-27 03:37:49 +00:00
|
|
|
sed -i -e 's|^WALL=.*|WALL="${wall}/bin/wall"|g' \
|
|
|
|
-e 's|^HOSTNAME=.*|HOSTNAME=`${hostname}/bin/hostname`|g' \
|
2013-07-16 23:53:30 +00:00
|
|
|
"$file"
|
|
|
|
done
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with stdenv.lib; {
|
2013-10-05 14:22:46 +00:00
|
|
|
description = "Daemon for controlling APC UPSes";
|
2020-04-01 01:11:51 +00:00
|
|
|
homepage = "http://www.apcupsd.com/";
|
2013-07-16 23:53:30 +00:00
|
|
|
license = licenses.gpl2;
|
|
|
|
platforms = platforms.linux;
|
|
|
|
maintainers = [ maintainers.bjornfor ];
|
|
|
|
};
|
|
|
|
}
|