2021-09-12 07:49:10 +00:00
|
|
|
{ stdenv, fetchurl, fetchpatch, perl, file, nettools, iputils, iproute2, makeWrapper
|
2016-09-28 01:39:11 +00:00
|
|
|
, coreutils, gnused, openldap ? null
|
2019-03-23 04:44:16 +00:00
|
|
|
, buildPackages, lib
|
2022-03-30 18:39:55 +00:00
|
|
|
|
|
|
|
# client and relay are end of life, remove after 4.4.3
|
|
|
|
, withClient ? false
|
|
|
|
, withRelay ? false
|
2015-03-26 19:27:48 +00:00
|
|
|
}:
|
2005-08-21 16:11:25 +00:00
|
|
|
|
2009-07-23 23:57:11 +00:00
|
|
|
stdenv.mkDerivation rec {
|
2019-08-15 12:41:18 +00:00
|
|
|
pname = "dhcp";
|
2022-10-05 22:22:25 +00:00
|
|
|
version = "4.4.3-P1";
|
2016-09-28 01:39:11 +00:00
|
|
|
|
2005-08-21 16:11:25 +00:00
|
|
|
src = fetchurl {
|
2019-08-15 12:41:18 +00:00
|
|
|
url = "https://ftp.isc.org/isc/dhcp/${version}/${pname}-${version}.tar.gz";
|
2022-10-05 22:22:25 +00:00
|
|
|
sha256 = "sha256-CsQWu1WZfKhjIXT9EHN/1hzbjbonUhYKM1d1vCHcc8c=";
|
2005-08-21 16:11:25 +00:00
|
|
|
};
|
2008-05-08 22:08:58 +00:00
|
|
|
|
2009-09-29 16:14:33 +00:00
|
|
|
patches =
|
2018-01-08 16:33:59 +00:00
|
|
|
[
|
2011-04-01 15:04:20 +00:00
|
|
|
# Make sure that the hostname gets set on reboot. Without this
|
|
|
|
# patch, the hostname doesn't get set properly if the old
|
|
|
|
# hostname (i.e. before reboot) is equal to the new hostname.
|
|
|
|
./set-hostname.patch
|
2009-09-29 16:14:33 +00:00
|
|
|
];
|
|
|
|
|
2021-02-07 09:17:39 +00:00
|
|
|
nativeBuildInputs = [ perl makeWrapper ];
|
2019-03-23 04:44:16 +00:00
|
|
|
|
2021-02-07 09:17:39 +00:00
|
|
|
buildInputs = [ openldap ];
|
2019-03-23 04:44:16 +00:00
|
|
|
|
|
|
|
depsBuildBuild = [ buildPackages.stdenv.cc ];
|
2015-03-26 19:27:48 +00:00
|
|
|
|
|
|
|
configureFlags = [
|
|
|
|
"--enable-failover"
|
|
|
|
"--enable-execute"
|
|
|
|
"--enable-tracing"
|
|
|
|
"--enable-delayed-ack"
|
|
|
|
"--enable-dhcpv6"
|
|
|
|
"--enable-paranoia"
|
|
|
|
"--enable-early-chroot"
|
|
|
|
"--sysconfdir=/etc"
|
|
|
|
"--localstatedir=/var"
|
2019-11-20 08:21:30 +00:00
|
|
|
] ++ lib.optional stdenv.isLinux "--with-randomdev=/dev/random"
|
2021-12-21 13:26:15 +00:00
|
|
|
++ lib.optionals (openldap != null) [ "--with-ldap" "--with-ldapcrypto" ]
|
|
|
|
++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) "BUILD_CC=$(CC_FOR_BUILD)";
|
2015-03-26 19:27:48 +00:00
|
|
|
|
2019-10-30 00:12:09 +00:00
|
|
|
NIX_CFLAGS_COMPILE = builtins.toString [
|
2018-05-16 21:36:32 +00:00
|
|
|
"-Wno-error=pointer-compare"
|
|
|
|
"-Wno-error=format-truncation"
|
2019-11-02 22:41:50 +00:00
|
|
|
"-Wno-error=stringop-truncation"
|
|
|
|
"-Wno-error=format-overflow"
|
2020-06-08 12:21:49 +00:00
|
|
|
"-Wno-error=stringop-overflow=8"
|
2018-05-16 21:36:32 +00:00
|
|
|
];
|
2017-11-12 11:16:47 +00:00
|
|
|
|
2015-03-26 19:27:48 +00:00
|
|
|
installFlags = [ "DESTDIR=\${out}" ];
|
2008-03-14 13:40:32 +00:00
|
|
|
|
2009-07-23 23:57:11 +00:00
|
|
|
postInstall =
|
|
|
|
''
|
2015-03-26 19:27:48 +00:00
|
|
|
mv $out/$out/* $out
|
|
|
|
DIR=$out/$out
|
|
|
|
while rmdir $DIR 2>/dev/null; do
|
|
|
|
DIR="$(dirname "$DIR")"
|
|
|
|
done
|
|
|
|
|
2009-07-23 23:57:11 +00:00
|
|
|
cp client/scripts/linux $out/sbin/dhclient-script
|
|
|
|
substituteInPlace $out/sbin/dhclient-script \
|
2021-03-14 16:05:16 +00:00
|
|
|
--replace /sbin/ip ${iproute2}/sbin/ip
|
2009-07-23 23:57:11 +00:00
|
|
|
wrapProgram "$out/sbin/dhclient-script" --prefix PATH : \
|
2010-08-06 10:34:34 +00:00
|
|
|
"${nettools}/bin:${nettools}/sbin:${iputils}/bin:${coreutils}/bin:${gnused}/bin"
|
2022-03-30 18:39:55 +00:00
|
|
|
'' + lib.optionalString (!withClient) ''
|
|
|
|
rm $out/sbin/{dhclient,dhclient-script,.dhclient-script-wrapped}
|
|
|
|
'' + lib.optionalString (!withRelay) ''
|
|
|
|
rm $out/sbin/dhcrelay
|
2009-07-23 23:57:11 +00:00
|
|
|
'';
|
2008-03-14 13:40:32 +00:00
|
|
|
|
2009-09-29 16:14:33 +00:00
|
|
|
preConfigure =
|
|
|
|
''
|
2014-06-24 21:58:38 +00:00
|
|
|
substituteInPlace configure --replace "/usr/bin/file" "${file}/bin/file"
|
2009-07-30 10:04:48 +00:00
|
|
|
sed -i "includes/dhcpd.h" \
|
2020-10-26 14:19:52 +00:00
|
|
|
-e "s|^ *#define \+_PATH_DHCLIENT_SCRIPT.*$|#define _PATH_DHCLIENT_SCRIPT \"$out/sbin/dhclient-script\"|g"
|
2019-03-23 04:44:16 +00:00
|
|
|
|
|
|
|
export AR='${stdenv.cc.bintools.bintools}/bin/${stdenv.cc.targetPrefix}ar'
|
2009-09-29 16:14:33 +00:00
|
|
|
'';
|
2009-07-30 10:04:48 +00:00
|
|
|
|
2021-10-27 20:57:21 +00:00
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2021-01-11 07:54:33 +00:00
|
|
|
meta = with lib; {
|
2008-05-08 22:08:58 +00:00
|
|
|
description = "Dynamic Host Configuration Protocol (DHCP) tools";
|
|
|
|
|
|
|
|
longDescription = ''
|
|
|
|
ISC's Dynamic Host Configuration Protocol (DHCP) distribution
|
|
|
|
provides a freely redistributable reference implementation of
|
|
|
|
all aspects of DHCP, through a suite of DHCP tools: server,
|
|
|
|
client, and relay agent.
|
|
|
|
'';
|
|
|
|
|
2020-01-10 00:34:25 +00:00
|
|
|
homepage = "https://www.isc.org/dhcp/";
|
2021-07-11 20:11:33 +00:00
|
|
|
license = licenses.mpl20;
|
2014-08-07 04:08:10 +00:00
|
|
|
platforms = platforms.unix;
|
2022-03-30 18:39:55 +00:00
|
|
|
knownVulnerabilities = lib.optional (withClient || withRelay) "The client and relay component of the dhcp package have reached their end of life";
|
2008-03-14 13:40:32 +00:00
|
|
|
};
|
2005-08-21 16:11:25 +00:00
|
|
|
}
|