Skip to content

Commit

Permalink
nix: Convert timestamp to iso date on build to prevent IFD
Browse files Browse the repository at this point in the history
  • Loading branch information
phlmn committed Jan 15, 2025
1 parent 98bf3ef commit b2e44db
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
};
});
Expand Down Expand Up @@ -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;
};
});
};
Expand Down
8 changes: 4 additions & 4 deletions nix/pkgs/frontend.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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}
'';
Expand Down

0 comments on commit b2e44db

Please sign in to comment.