nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at devShellTools-shell 82 lines 2.0 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchFromGitHub, 5 pkg-config, 6 udev, 7 freebsd, 8 runtimeShellPackage, 9 runtimeShell, 10 nixosTests, 11 # Always tries to do dynamic linking for udev. 12 withUdev ? stdenv.hostPlatform.isLinux && !stdenv.hostPlatform.isStatic, 13 enablePrivSep ? false, 14}: 15 16stdenv.mkDerivation rec { 17 pname = "dhcpcd"; 18 version = "10.2.4"; 19 20 src = fetchFromGitHub { 21 owner = "NetworkConfiguration"; 22 repo = "dhcpcd"; 23 rev = "v${version}"; 24 sha256 = "sha256-ysaKgF4Cu/S6yhSn/4glA0+Ey54KNp3/1Oh82yE0/PY="; 25 }; 26 27 nativeBuildInputs = [ pkg-config ]; 28 buildInputs = [ 29 runtimeShellPackage # So patchShebangs finds a bash suitable for the installed scripts 30 ] 31 ++ lib.optionals withUdev [ 32 udev 33 ] 34 ++ lib.optionals stdenv.hostPlatform.isFreeBSD [ 35 freebsd.libcapsicum 36 freebsd.libcasper 37 ]; 38 39 postPatch = '' 40 substituteInPlace hooks/dhcpcd-run-hooks.in --replace /bin/sh ${runtimeShell} 41 ''; 42 43 configureFlags = [ 44 "--sysconfdir=/etc" 45 "--localstatedir=/var" 46 "--disable-privsep" 47 "--dbdir=/var/lib/dhcpcd" 48 "--with-default-hostname=nixos" 49 (lib.enableFeature enablePrivSep "privsep") 50 ] 51 ++ lib.optional enablePrivSep "--privsepuser=dhcpcd"; 52 53 makeFlags = [ "PREFIX=${placeholder "out"}" ]; 54 55 # Hack to make installation succeed. dhcpcd will still use /var/lib 56 # at runtime. 57 installFlags = [ 58 "DBDIR=$(TMPDIR)/db" 59 "SYSCONFDIR=${placeholder "out"}/etc" 60 ]; 61 62 # Check that the udev plugin got built. 63 postInstall = lib.optionalString withUdev "[ -e ${placeholder "out"}/lib/dhcpcd/dev/udev.so ]"; 64 65 passthru.tests = { 66 inherit (nixosTests.networking.scripted) 67 macvlan 68 dhcpSimple 69 dhcpHostname 70 dhcpOneIf 71 ; 72 }; 73 74 meta = with lib; { 75 description = "Client for the Dynamic Host Configuration Protocol (DHCP)"; 76 homepage = "https://roy.marples.name/projects/dhcpcd"; 77 platforms = platforms.linux ++ platforms.freebsd ++ platforms.openbsd; 78 license = licenses.bsd2; 79 maintainers = [ ]; 80 mainProgram = "dhcpcd"; 81 }; 82}