From d9ca24398ad71aca208c94a6399f13c46228b103 Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Thu, 15 Oct 2026 07:31:36 +0200 Subject: feat: set system.configurationRevision --- nixos/profiles/common/default.nix | 6 ++++++ nixos/rebuild | 7 +++++++ 2 files changed, 13 insertions(+) (limited to 'nixos') diff --git a/nixos/profiles/common/default.nix b/nixos/profiles/common/default.nix index 1705adf..0681dde 100644 --- a/nixos/profiles/common/default.nix +++ b/nixos/profiles/common/default.nix @@ -1,6 +1,12 @@ { config, pkgs, ... }: { + system.configurationRevision = + let + revision = builtins.getEnv "NIXOS_CONFIG_REVISION"; + in + if revision == "" then null else revision; + imports = let sources = import ; diff --git a/nixos/rebuild b/nixos/rebuild index bb44fe8..d714977 100755 --- a/nixos/rebuild +++ b/nixos/rebuild @@ -25,6 +25,13 @@ if [ ! -f "$configPath" ]; then exit 1 fi +# Make the configuration repository's commit available to the NixOS module. +export NIXOS_CONFIG_REVISION +NIXOS_CONFIG_REVISION=$(git -C "$top" rev-parse --verify HEAD) +if [[ -n $(git -C "$top" status --porcelain) ]]; then + NIXOS_CONFIG_REVISION+="-dirty" +fi + nixpkgsPath=$( cd "$top" && nix-instantiate --eval --raw \ -- cgit v1.3.1