2021-01-19 06:50:56 +00:00
|
|
|
{ lib, stdenv, fetchurl, pkg-config, systemd, util-linux, coreutils, wall, hostname, man
|
2013-07-16 23:53:30 +00:00
|
|
|
, enableCgiScripts ? true, gd
|
2022-12-29 23:09:44 +00:00
|
|
|
, nixosTests
|
2013-07-16 23:53:30 +00:00
|
|
|
}:
|
|
|
|
|
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";
|
2021-07-25 21:53:02 +00:00
|
|
|
version = "3.14.14";
|
2013-07-16 23:53:30 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
2021-07-25 21:53:02 +00:00
|
|
|
url = "mirror://sourceforge/${pname}/${pname}-${version}.tar.gz";
|
2016-10-17 09:38:07 +00:00
|
|
|
sha256 = "0rwqiyzlg9p0szf3x6q1ppvrw6f6dbpn2rc5z623fk3bkdalhxyv";
|
2013-07-16 23:53:30 +00:00
|
|
|
};
|
|
|
|
|
2023-06-18 09:44:58 +00:00
|
|
|
nativeBuildInputs = [ pkg-config man util-linux ];
|
|
|
|
buildInputs = 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
|
|
|
preConfigure = ''
|
|
|
|
sed -i 's|/bin/cat|${coreutils}/bin/cat|' configure
|
|
|
|
'';
|
|
|
|
|
2023-06-18 09:44:58 +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.
|
|
|
|
configureFlags = [
|
|
|
|
"--bindir=${placeholder "out"}/bin"
|
|
|
|
"--sbindir=${placeholder "out"}/bin"
|
|
|
|
"--sysconfdir=${placeholder "out"}/etc/apcupsd"
|
|
|
|
"--mandir=${placeholder "out"}/share/man"
|
|
|
|
"--with-halpolicydir=${placeholder "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"
|
|
|
|
"ac_cv_path_SHUTDOWN=${systemd}/sbin/shutdown"
|
|
|
|
"ac_cv_path_WALL=${wall}/bin/wall"
|
|
|
|
] ++ lib.optionals enableCgiScripts [
|
|
|
|
"--enable-cgi"
|
|
|
|
"--with-cgi-bin=${placeholder "out"}/libexec/cgi-bin"
|
|
|
|
];
|
|
|
|
|
2013-07-16 23:53:30 +00:00
|
|
|
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
|
|
|
|
'';
|
|
|
|
|
2022-12-29 23:09:44 +00:00
|
|
|
passthru.tests.smoke = nixosTests.apcupsd;
|
|
|
|
|
2021-01-11 07:54:33 +00:00
|
|
|
meta = with 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/";
|
2024-05-23 08:44:51 +00:00
|
|
|
license = licenses.gpl2Only;
|
2013-07-16 23:53:30 +00:00
|
|
|
platforms = platforms.linux;
|
|
|
|
maintainers = [ maintainers.bjornfor ];
|
|
|
|
};
|
|
|
|
}
|