Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 81 lines 2.5 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchFromGitHub, 5 fetchpatch, 6 perl, 7 coreutils, 8}: 9let 10 hashes = { 11 "0.9.10" = "sha256-DYRuQmIhQu0CNEboBAtHOr/NnWxoXecuPMSR/UQ/VIQ="; 12 "0.9.11" = "sha256-a0TjHYzwbkRQyvr9Sj/DqjgLBnE1Z8kjsTQxTfGqLjE="; 13 }; 14in 15 16stdenv.mkDerivation (finalAttrs: { 17 pname = "libfaketime"; 18 # 0.9.10 break dict-db-wiktionary and quartus-prime-lite on linux, 19 # and 0.9.11 break everything on darwin 20 version = if stdenv.hostPlatform.isDarwin then "0.9.10" else "0.9.11"; 21 22 src = fetchFromGitHub { 23 owner = "wolfcw"; 24 repo = "libfaketime"; 25 tag = "v${finalAttrs.version}"; 26 hash = hashes.${finalAttrs.version}; 27 }; 28 29 patches = [ 30 ./nix-store-date.patch 31 ] 32 ++ lib.optionals stdenv.hostPlatform.isDarwin [ 33 (fetchpatch { 34 name = "0001-libfaketime.c-wrap-timespec_get-in-TIME_UTC-macro.patch"; 35 url = "https://github.com/wolfcw/libfaketime/commit/e0e6b79568d36a8fd2b3c41f7214769221182128.patch"; 36 sha256 = "sha256-KwwP76v0DXNW73p/YBvwUOPdKMAcVdbQSKexD/uFOYo="; 37 }) 38 (fetchpatch { 39 name = "LFS64.patch"; 40 url = "https://github.com/wolfcw/libfaketime/commit/f32986867addc9d22b0fab29c1c927f079d44ac1.patch"; 41 hash = "sha256-fIXuxxcV9J2IcgwcwSrMo4maObkH9WYv1DC/wdtbq/g="; 42 }) 43 # https://github.com/wolfcw/libfaketime/issues/277 44 ./0001-Remove-unsupported-clang-flags.patch 45 ]; 46 47 postPatch = '' 48 patchShebangs test src 49 substituteInPlace test/functests/test_exclude_mono.sh src/faketime.c \ 50 --replace-fail /bin/bash ${stdenv.shell} 51 substituteInPlace src/faketime.c \ 52 --replace-fail @DATE_CMD@ ${lib.getExe' coreutils "date"} 53 ''; 54 55 PREFIX = placeholder "out"; 56 LIBDIRNAME = "/lib"; 57 58 env.NIX_CFLAGS_COMPILE = toString ( 59 lib.optionals stdenv.cc.isClang [ 60 "-Wno-error=cast-function-type" 61 "-Wno-error=format-truncation" 62 ] 63 # https://github.com/wolfcw/libfaketime/blob/6714b98794a9e8a413bf90d2927abf5d888ada99/README#L101-L104 64 ++ lib.optionals (stdenv.hostPlatform.isLoongArch64 || stdenv.hostPlatform.isRiscV64) [ 65 "-DFORCE_PTHREAD_NONVER" 66 ] 67 ); 68 69 nativeCheckInputs = [ perl ]; 70 71 doCheck = true; 72 73 meta = { 74 description = "Report faked system time to programs without having to change the system-wide time"; 75 homepage = "https://github.com/wolfcw/libfaketime/"; 76 license = lib.licenses.gpl2; 77 platforms = lib.platforms.all; 78 maintainers = [ lib.maintainers.bjornfor ]; 79 mainProgram = "faketime"; 80 }; 81})