From 6682530ea572201b16454ff6e8164329acc560d9 Mon Sep 17 00:00:00 2001 From: Samuel Meenzen Date: Wed, 16 Jul 2025 17:16:52 +0200 Subject: [PATCH] feat: add commit timestamp to oci-image --- nix/pkgs/oci-image/default.nix | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/nix/pkgs/oci-image/default.nix b/nix/pkgs/oci-image/default.nix index f27c45c0..1224d41c 100644 --- a/nix/pkgs/oci-image/default.nix +++ b/nix/pkgs/oci-image/default.nix @@ -1,6 +1,7 @@ # Keep sorted { default , dockerTools +, inputs , lib , pkgs }: @@ -13,10 +14,27 @@ let }) ]; }; + + # This is a unix timestamp of the last commit + timestamp = inputs.self.lastModified; + + # Convert the timestamp to an ISO 8601 string + iso = builtins.readFile ( + pkgs.runCommand "timestamp" { + when = timestamp; + nativeBuildInputs = [ pkgs.coreutils ]; + } '' + date -u -d "@$when" +%Y-%m-%dT%H:%M:%SZ > $out + '' + ); + + # Remove trailing newline + isoTrimmed = lib.strings.trim iso; in dockerTools.buildImage { name = default.pname; tag = "next"; + created = isoTrimmed; copyToRoot = [ dockerTools.caCertificates ];