From b2e2f0422f23e5943fcccd5f067f756655327706 Mon Sep 17 00:00:00 2001 From: Finn Behrens Date: Fri, 5 Mar 2021 22:23:09 +0100 Subject: [PATCH] libfaketime: use date from nix store (#115212) Previously the faketime command used date (or gdate on darwin) from the environment. This led to issues when the date command was not available or did not behave as expected. Thus, we patch libfaketime to use the date binary from the Nix coreutils package, pulling it into the closure. --- .../libraries/libfaketime/default.nix | 4 ++- .../libfaketime/nix-store-date.patch | 29 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 pkgs/development/libraries/libfaketime/nix-store-date.patch diff --git a/pkgs/development/libraries/libfaketime/default.nix b/pkgs/development/libraries/libfaketime/default.nix index 27487c6a315..ced1c3e7bb9 100644 --- a/pkgs/development/libraries/libfaketime/default.nix +++ b/pkgs/development/libraries/libfaketime/default.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, fetchurl, perl }: +{ lib, stdenv, fetchurl, perl, coreutils }: stdenv.mkDerivation rec { pname = "libfaketime"; @@ -11,6 +11,7 @@ stdenv.mkDerivation rec { patches = [ ./no-date-in-gzip-man-page.patch + ./nix-store-date.patch ] ++ (lib.optionals stdenv.cc.isClang [ # https://github.com/wolfcw/libfaketime/issues/277 ./0001-Remove-unsupported-clang-flags.patch @@ -22,6 +23,7 @@ stdenv.mkDerivation rec { substituteInPlace $a \ --replace /bin/bash ${stdenv.shell} done + substituteInPlace src/faketime.c --replace @DATE_CMD@ ${coreutils}/bin/date ''; PREFIX = placeholder "out"; diff --git a/pkgs/development/libraries/libfaketime/nix-store-date.patch b/pkgs/development/libraries/libfaketime/nix-store-date.patch new file mode 100644 index 00000000000..b88245dfe8f --- /dev/null +++ b/pkgs/development/libraries/libfaketime/nix-store-date.patch @@ -0,0 +1,29 @@ +From abd7dd05b440e3dc9621a1579e4afb0267897d9c Mon Sep 17 00:00:00 2001 +From: Finn Behrens +Date: Fri, 5 Mar 2021 21:58:57 +0100 +Subject: [PATCH] use nix date path + +--- + src/faketime.c | 6 +----- + 1 file changed, 1 insertion(+), 5 deletions(-) + +diff --git a/src/faketime.c b/src/faketime.c +index af618f2..48e47da 100644 +--- a/src/faketime.c ++++ b/src/faketime.c +@@ -50,11 +50,7 @@ + + const char version[] = "0.9.9"; + +-#ifdef __APPLE__ +-static const char *date_cmd = "gdate"; +-#else +-static const char *date_cmd = "date"; +-#endif ++static const char *date_cmd = "@DATE_CMD@"; + + #define PATH_BUFSIZE 4096 + +-- +2.24.3 (Apple Git-128) +