base16-schemes: unstable-2024-06-21 -> unstable-2024-11-12
[NixPkgs.git] / pkgs / by-name / dh / dhcpcd / package.nix
blob2e0dbb90d63fc292f20739b1f9628dea09229e88
1 { lib
2 , stdenv
3 , fetchFromGitHub
4 , pkg-config
5 , udev
6 , freebsd
7 , runtimeShellPackage
8 , runtimeShell
9 , nixosTests
10 , enablePrivSep ? false
13 stdenv.mkDerivation rec {
14   pname = "dhcpcd";
15   version = "10.1.0";
17   src = fetchFromGitHub {
18     owner = "NetworkConfiguration";
19     repo = "dhcpcd";
20     rev = "v${version}";
21     sha256 = "sha256-Qtg9jOFMR/9oWJDmoNNcEAMxG6G1F187HF4MMBJIoTw=";
22   };
24   nativeBuildInputs = [ pkg-config ];
25   buildInputs = [
26     runtimeShellPackage # So patchShebangs finds a bash suitable for the installed scripts
27   ] ++ lib.optionals stdenv.hostPlatform.isLinux [
28     udev
29   ] ++ lib.optionals stdenv.hostPlatform.isFreeBSD [
30     freebsd.libcapsicum
31     freebsd.libcasper
32   ];
34   postPatch = ''
35     substituteInPlace hooks/dhcpcd-run-hooks.in --replace /bin/sh ${runtimeShell}
36   '';
38   configureFlags = [
39     "--sysconfdir=/etc"
40     "--localstatedir=/var"
41     "--disable-privsep"
42     "--dbdir=/var/lib/dhcpcd"
43     (lib.enableFeature enablePrivSep "privsep")
44   ] ++ lib.optional enablePrivSep "--privsepuser=dhcpcd";
46   makeFlags = [ "PREFIX=${placeholder "out"}" ];
48   # Hack to make installation succeed.  dhcpcd will still use /var/lib
49   # at runtime.
50   installFlags = [ "DBDIR=$(TMPDIR)/db" "SYSCONFDIR=${placeholder "out"}/etc" ];
52   # Check that the udev plugin got built.
53   postInstall = lib.optionalString (udev != null && stdenv.hostPlatform.isLinux) "[ -e ${placeholder "out"}/lib/dhcpcd/dev/udev.so ]";
55   passthru.tests = {
56     inherit (nixosTests.networking.scripted) macvlan dhcpSimple dhcpOneIf;
57   };
59   meta = with lib; {
60     description = "Client for the Dynamic Host Configuration Protocol (DHCP)";
61     homepage = "https://roy.marples.name/projects/dhcpcd";
62     platforms = platforms.linux ++ platforms.freebsd;
63     license = licenses.bsd2;
64     maintainers = [ ];
65     mainProgram = "dhcpcd";
66   };