1{ lib, stdenv, fetchFromGitHub, fetchpatch, perl, coreutils }:
2
3stdenv.mkDerivation rec {
4 pname = "libfaketime";
5 version = "0.9.10";
6
7 src = fetchFromGitHub {
8 owner = "wolfcw";
9 repo = "libfaketime";
10 rev = "v${version}";
11 sha256 = "sha256-DYRuQmIhQu0CNEboBAtHOr/NnWxoXecuPMSR/UQ/VIQ=";
12 };
13
14 patches = [
15 ./nix-store-date.patch
16 (fetchpatch {
17 name = "0001-libfaketime.c-wrap-timespec_get-in-TIME_UTC-macro.patch";
18 url = "https://github.com/wolfcw/libfaketime/commit/e0e6b79568d36a8fd2b3c41f7214769221182128.patch";
19 sha256 = "sha256-KwwP76v0DXNW73p/YBvwUOPdKMAcVdbQSKexD/uFOYo=";
20 })
21 (fetchpatch {
22 name = "LFS64.patch";
23 url = "https://github.com/wolfcw/libfaketime/commit/f32986867addc9d22b0fab29c1c927f079d44ac1.patch";
24 hash = "sha256-fIXuxxcV9J2IcgwcwSrMo4maObkH9WYv1DC/wdtbq/g=";
25 })
26 ] ++ (lib.optionals stdenv.cc.isClang [
27 # https://github.com/wolfcw/libfaketime/issues/277
28 ./0001-Remove-unsupported-clang-flags.patch
29 ]);
30
31 postPatch = ''
32 patchShebangs test src
33 for a in test/functests/test_exclude_mono.sh src/faketime.c ; do
34 substituteInPlace $a \
35 --replace /bin/bash ${stdenv.shell}
36 done
37 substituteInPlace src/faketime.c --replace @DATE_CMD@ ${coreutils}/bin/date
38 '';
39
40 PREFIX = placeholder "out";
41 LIBDIRNAME = "/lib";
42
43 env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang "-Wno-error=cast-function-type -Wno-error=format-truncation";
44
45 nativeCheckInputs = [ perl ];
46
47 meta = with lib; {
48 description = "Report faked system time to programs without having to change the system-wide time";
49 homepage = "https://github.com/wolfcw/libfaketime/";
50 license = licenses.gpl2;
51 platforms = platforms.all;
52 maintainers = [ maintainers.bjornfor ];
53 mainProgram = "faketime";
54 };
55}