From b2e44db3934f6d31db88c9871900cb2929b05613 Mon Sep 17 00:00:00 2001 From: Philipp Mandler Date: Wed, 15 Jan 2025 19:09:19 +0100 Subject: [PATCH] nix: Convert timestamp to iso date on build to prevent IFD --- flake.nix | 4 ++-- nix/pkgs/frontend.nix | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/flake.nix b/flake.nix index 6c13f447..f26ec96e 100644 --- a/flake.nix +++ b/flake.nix @@ -52,7 +52,7 @@ versionInfo = { commitHash = if (self ? rev) then self.rev else self.dirtyRev; - commitDate = lib.readFile "${prev.runCommand "timestamp" { env.when = self.lastModified; } "echo -n `date -d @$when --iso-8601=s` > $out"}"; + commitDate = self.lastModified; }; }; }); @@ -85,7 +85,7 @@ inherit pkgs lib; versionInfo = { commitHash = if (self ? rev) then self.rev else self.dirtyRev; - commitDate = lib.readFile "${pkgs.runCommand "timestamp" { env.when = self.lastModified; } "echo -n `date -d @$when --iso-8601=s` > $out"}"; + commitDate = self.lastModified; }; }); }; diff --git a/nix/pkgs/frontend.nix b/nix/pkgs/frontend.nix index e90f2aec..3f4caa2b 100644 --- a/nix/pkgs/frontend.nix +++ b/nix/pkgs/frontend.nix @@ -41,10 +41,10 @@ pkgs.buildNpmPackage (lib.fix (self: { }; preBuild = let - versionExports = ([ ] ++ (lib.optional (versionInfo ? commitHash) - ''export COMMIT_HASH="${versionInfo.commitHash}"'') - ++ (lib.optional (versionInfo ? commitDate) - ''export COMMIT_DATE="${versionInfo.commitDate}"'')); + versionExports = ([ ] + ++ (lib.optional (versionInfo ? commitHash) ''export COMMIT_HASH="${versionInfo.commitHash}"'') + ++ (lib.optional (versionInfo ? commitDate) ''export COMMIT_DATE="$(date -d @${builtins.toString versionInfo.commitDate} --iso-8601=s)"'') + ); in '' ${lib.concatStringsSep "\n" versionExports} '';