Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ fetchurl, fetchpatch, stdenv, systemd, lib }: 2 3stdenv.mkDerivation rec { 4 pname = "unscd"; 5 version = "0.54"; 6 7 src = fetchurl { 8 url = "https://busybox.net/~vda/unscd/nscd-${version}.c"; 9 sha256 = "0iv4iwgs3sjnqnwd7dpcw6s7i4ar9q89vgsms32clx14fdqjrqch"; 10 }; 11 12 unpackPhase = '' 13 runHook preUnpack 14 cp $src nscd.c 15 chmod u+w nscd.c 16 runHook postUnpack 17 ''; 18 19 patches = [ 20 # Patches from Debian that have not (yet) been included upstream, but are useful to us 21 (fetchpatch { 22 url = "https://sources.debian.org/data/main/u/${pname}/${version}-1/debian/patches/change_invalidate_request_info_output"; 23 sha256 = "17whakazpisiq9nnw3zybaf7v3lqkww7n6jkx0igxv4z2r3mby6l"; 24 }) 25 (fetchpatch { 26 url = "https://sources.debian.org/data/main/u/${pname}/${version}-1/debian/patches/support_large_numbers_in_config"; 27 sha256 = "0jrqb4cwclwirpqfb6cvnmiff3sm2jhxnjwxa7h0wx78sg0y3bpp"; 28 }) 29 (fetchpatch { 30 url = "https://sources.debian.org/data/main/u/${pname}/${version}-1/debian/patches/no_debug_on_invalidate"; 31 sha256 = "0znwzb522zgikb0mm7awzpvvmy0wf5z7l3jgjlkdpgj0scxgz86w"; 32 }) 33 (fetchpatch { 34 url = "https://sources.debian.org/data/main/u/${pname}/${version}-1/debian/patches/notify_systemd_about_successful_startup"; 35 sha256 = "1ipwmbfwm65yisy74nig9960vxpjx683l3skgxfgssfx1jb9z2mc"; 36 }) 37 38 # The original unscd would crash, because it is not allowed to create its 39 # legacy socket at /var/run/.nscd_socket. 40 # This socket is only required for very old glibc versions, but removing it 41 # is currently non-trivial, so we just move it somewhere, where it is 42 # allowed to be created. A patch has been submitted upstream to make this 43 # hack unnecessary. 44 # Also change /var/run to /run, since we shouldn't be using /var/run 45 # anymore. 46 # See also: http://lists.busybox.net/pipermail/busybox/2021-June/088866.html 47 ./0001-adjust-socket-paths-for-nixos.patch 48 ]; 49 50 buildInputs = [ systemd ]; 51 52 buildPhase = '' 53 runHook preBuild 54 gcc -Wall \ 55 -Wl,--sort-section -Wl,alignment \ 56 -Wl,--sort-common \ 57 -fomit-frame-pointer \ 58 -lsystemd \ 59 -o nscd nscd.c 60 runHook postBuild 61 ''; 62 63 installPhase = '' 64 runHook preInstall 65 install -Dm755 -t $out/bin nscd 66 runHook postInstall 67 ''; 68 69 meta = with lib; { 70 homepage = "https://busybox.net/~vda/unscd/"; 71 description = "Less buggy replacement for the glibc name service cache daemon"; 72 license = licenses.gpl2Only; 73 platforms = platforms.linux; 74 maintainers = with maintainers; [ ]; 75 }; 76}