2021-12-21 02:18:32 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
2023-07-15 17:15:38 +00:00
|
|
|
, fetchFromGitHub
|
2021-12-21 02:18:32 +00:00
|
|
|
, pkg-config
|
|
|
|
, udev
|
2024-06-20 14:57:18 +00:00
|
|
|
, freebsd
|
2021-12-21 02:18:32 +00:00
|
|
|
, runtimeShellPackage
|
|
|
|
, runtimeShell
|
|
|
|
, nixosTests
|
2024-10-11 05:15:48 +00:00
|
|
|
, enablePrivSep ? false
|
2021-12-21 02:18:32 +00:00
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "dhcpcd";
|
2024-09-19 14:19:46 +00:00
|
|
|
version = "10.0.6";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "NetworkConfiguration";
|
|
|
|
repo = "dhcpcd";
|
|
|
|
rev = "v${version}";
|
2024-09-19 14:19:46 +00:00
|
|
|
sha256 = "sha256-tNC5XCA8dShaTIff15mQz8v+YK9sZkRNLCX5qnlpxx4=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
nativeBuildInputs = [ pkg-config ];
|
2020-04-24 23:36:52 +00:00
|
|
|
buildInputs = [
|
|
|
|
runtimeShellPackage # So patchShebangs finds a bash suitable for the installed scripts
|
2024-09-26 11:04:55 +00:00
|
|
|
] ++ lib.optionals stdenv.hostPlatform.isLinux [
|
2024-06-20 14:57:18 +00:00
|
|
|
udev
|
2024-09-26 11:04:55 +00:00
|
|
|
] ++ lib.optionals stdenv.hostPlatform.isFreeBSD [
|
2024-06-20 14:57:18 +00:00
|
|
|
freebsd.libcapsicum
|
|
|
|
freebsd.libcasper
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
2024-02-29 20:09:43 +00:00
|
|
|
postPatch = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
substituteInPlace hooks/dhcpcd-run-hooks.in --replace /bin/sh ${runtimeShell}
|
|
|
|
'';
|
|
|
|
|
|
|
|
configureFlags = [
|
|
|
|
"--sysconfdir=/etc"
|
|
|
|
"--localstatedir=/var"
|
2024-10-11 05:15:48 +00:00
|
|
|
"--disable-privsep"
|
|
|
|
"--dbdir=/var/lib/dhcpcd"
|
|
|
|
(lib.enableFeature enablePrivSep "privsep")
|
|
|
|
] ++ lib.optional enablePrivSep "--privsepuser=dhcpcd";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
makeFlags = [ "PREFIX=${placeholder "out"}" ];
|
|
|
|
|
2024-10-11 05:15:48 +00:00
|
|
|
# Hack to make installation succeed. dhcpcd will still use /var/lib
|
2020-04-24 23:36:52 +00:00
|
|
|
# at runtime.
|
|
|
|
installFlags = [ "DBDIR=$(TMPDIR)/db" "SYSCONFDIR=${placeholder "out"}/etc" ];
|
|
|
|
|
|
|
|
# Check that the udev plugin got built.
|
2024-09-26 11:04:55 +00:00
|
|
|
postInstall = lib.optionalString (udev != null && stdenv.hostPlatform.isLinux) "[ -e ${placeholder "out"}/lib/dhcpcd/dev/udev.so ]";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-10-11 05:15:48 +00:00
|
|
|
passthru.tests = {
|
|
|
|
inherit (nixosTests.networking.scripted) macvlan dhcpSimple dhcpOneIf;
|
2022-02-10 20:34:41 +00:00
|
|
|
};
|
2021-12-21 02:18:32 +00:00
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2024-06-20 14:57:18 +00:00
|
|
|
description = "Client for the Dynamic Host Configuration Protocol (DHCP)";
|
2020-04-24 23:36:52 +00:00
|
|
|
homepage = "https://roy.marples.name/projects/dhcpcd";
|
2024-06-20 14:57:18 +00:00
|
|
|
platforms = platforms.linux ++ platforms.freebsd;
|
2020-04-24 23:36:52 +00:00
|
|
|
license = licenses.bsd2;
|
2024-09-19 14:19:46 +00:00
|
|
|
maintainers = [ ];
|
2024-02-29 20:09:43 +00:00
|
|
|
mainProgram = "dhcpcd";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|