mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-25 15:11:35 +00:00
4a7f99d55d
Part of: https://github.com/NixOS/nixpkgs/issues/108938 meta = with stdenv.lib; is a widely used pattern. We want to slowly remove the `stdenv.lib` indirection and encourage people to use `lib` directly. Thus let’s start with the meta field. This used a rewriting script to mostly automatically replace all occurances of this pattern, and add the `lib` argument to the package header if it doesn’t exist yet. The script in its current form is available at https://cs.tvl.fyi/depot@2f807d7f141068d2d60676a89213eaa5353ca6e0/-/blob/users/Profpatsch/nixpkgs-rewriter/default.nix
63 lines
2 KiB
Nix
63 lines
2 KiB
Nix
{ lib, stdenv, fetchurl, pkgconfig, systemd, util-linux, coreutils, wall, hostname, man
|
|
, enableCgiScripts ? true, gd
|
|
}:
|
|
|
|
assert enableCgiScripts -> gd != null;
|
|
|
|
stdenv.mkDerivation rec {
|
|
pname = "apcupsd";
|
|
name = "${pname}-3.14.14";
|
|
|
|
src = fetchurl {
|
|
url = "mirror://sourceforge/${pname}/${name}.tar.gz";
|
|
sha256 = "0rwqiyzlg9p0szf3x6q1ppvrw6f6dbpn2rc5z623fk3bkdalhxyv";
|
|
};
|
|
|
|
nativeBuildInputs = [ pkgconfig ];
|
|
buildInputs = [ util-linux man ] ++ stdenv.lib.optional enableCgiScripts gd;
|
|
|
|
prePatch = ''
|
|
sed -e "s,\$(INSTALL_PROGRAM) \$(STRIP),\$(INSTALL_PROGRAM)," \
|
|
-i ./src/apcagent/Makefile ./autoconf/targets.mak
|
|
'';
|
|
|
|
# ./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=${wall}/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="${wall}/bin/wall"|g' \
|
|
-e 's|^HOSTNAME=.*|HOSTNAME=`${hostname}/bin/hostname`|g' \
|
|
"$file"
|
|
done
|
|
'';
|
|
|
|
meta = with lib; {
|
|
description = "Daemon for controlling APC UPSes";
|
|
homepage = "http://www.apcupsd.com/";
|
|
license = licenses.gpl2;
|
|
platforms = platforms.linux;
|
|
maintainers = [ maintainers.bjornfor ];
|
|
};
|
|
}
|