diff options
| author | Martin Fischer <martin@push-f.com> | 2026-10-15 07:31:36 +0200 |
|---|---|---|
| committer | Martin Fischer <martin@push-f.com> | 2026-10-21 18:14:14 +0200 |
| commit | 08554702113f33ec63e9bd88337e3a272234a141 (patch) | |
| tree | a7ab91f76d67dd7603629c054b7b61e13513157a /nixos | |
| parent | ee650f182186ebe141135c3a122c2743e8c4d7a9 (diff) | |
feat(common): set system.configurationRevision
Diffstat (limited to 'nixos')
| -rw-r--r-- | nixos/profiles/common/default.nix | 6 | ||||
| -rwxr-xr-x | nixos/rebuild | 7 |
2 files changed, 13 insertions, 0 deletions
diff --git a/nixos/profiles/common/default.nix b/nixos/profiles/common/default.nix index d891879..d94db86 100644 --- a/nixos/profiles/common/default.nix +++ b/nixos/profiles/common/default.nix @@ -6,4 +6,10 @@ ./basics.nix "${sources.agenix}/modules/age.nix" ]; + + system.configurationRevision = + let + revision = builtins.getEnv "NIXOS_CONFIG_REVISION"; + in + if revision == "" then null else revision; } diff --git a/nixos/rebuild b/nixos/rebuild index 395f78d..3589dc4 100755 --- a/nixos/rebuild +++ b/nixos/rebuild @@ -9,6 +9,13 @@ if [ ! -d "$hostDir" ]; 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 + ( # The result symlink created in the current directory is registered as a root of the Nix # garbage collector, so it's important that we call nixos-rebuild from the host directory. |
