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 ] ++ (lib.optionals stdenv.cc.isClang [
22 # https://github.com/wolfcw/libfaketime/issues/277
23 ./0001-Remove-unsupported-clang-flags.patch
24 ]);
25
26 postPatch = ''
27 patchShebangs test src
28 for a in test/functests/test_exclude_mono.sh src/faketime.c ; do
29 substituteInPlace $a \
30 --replace /bin/bash ${stdenv.shell}
31 done
32 substituteInPlace src/faketime.c --replace @DATE_CMD@ ${coreutils}/bin/date
33 '';
34
35 PREFIX = placeholder "out";
36 LIBDIRNAME = "/lib";
37
38 env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang "-Wno-error=cast-function-type -Wno-error=format-truncation";
39
40 nativeCheckInputs = [ perl ];
41
42 meta = with lib; {
43 description = "Report faked system time to programs without having to change the system-wide time";
44 homepage = "https://github.com/wolfcw/libfaketime/";
45 license = licenses.gpl2;
46 platforms = platforms.all;
47 maintainers = [ maintainers.bjornfor ];
48 mainProgram = "faketime";
49 };
50}