pytrainer: unpin python 3.10
[NixPkgs.git] / pkgs / servers / apcupsd / default.nix
blobeeecfa2f0ec4885bc5955e5515bf0842591e4f77
1 { lib, stdenv, fetchurl, pkg-config, systemd, util-linux, coreutils, wall, hostname, man
2 , enableCgiScripts ? true, gd
3 , nixosTests
4 }:
6 assert enableCgiScripts -> gd != null;
8 stdenv.mkDerivation rec {
9   pname = "apcupsd";
10   version = "3.14.14";
12   src = fetchurl {
13     url = "mirror://sourceforge/${pname}/${pname}-${version}.tar.gz";
14     sha256 = "0rwqiyzlg9p0szf3x6q1ppvrw6f6dbpn2rc5z623fk3bkdalhxyv";
15   };
17   nativeBuildInputs = [ pkg-config man util-linux ];
18   buildInputs = lib.optional enableCgiScripts gd;
20   prePatch = ''
21     sed -e "s,\$(INSTALL_PROGRAM) \$(STRIP),\$(INSTALL_PROGRAM)," \
22         -i ./src/apcagent/Makefile ./autoconf/targets.mak
23   '';
25   preConfigure = ''
26     sed -i 's|/bin/cat|${coreutils}/bin/cat|' configure
27   '';
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.
31   configureFlags = [
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"
38     "--with-nologin=/run"
39     "--with-log-dir=/var/log/apcupsd"
40     "--with-pwrfail-dir=/run/apcupsd"
41     "--with-lock-dir=/run/lock"
42     "--with-pid-dir=/run"
43     "--enable-usb"
44     "ac_cv_path_SHUTDOWN=${systemd}/sbin/shutdown"
45     "ac_cv_path_WALL=${wall}/bin/wall"
46   ] ++ lib.optionals enableCgiScripts [
47     "--enable-cgi"
48     "--with-cgi-bin=${placeholder "out"}/libexec/cgi-bin"
49   ];
51   postInstall = ''
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' \
55                "$file"
56     done
57   '';
59   passthru.tests.smoke = nixosTests.apcupsd;
61   meta = with lib; {
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 ];
67   };