Embed the source Git revision in future Mercurius generations #1

Open
opened 2026-11-19 12:40:25 +01:00 by pti · 0 comments
Owner

Why

The Mercurius asset-roster pilot records the active NixOS generation separately from a pinned nixos-config Git commit. The current remote main flake defines nixosConfigurations.mercurius but does not explicitly set system.configurationRevision; a generation store path alone does not establish which commit was used for deployment. We should make future generations report their source revision without claiming this retroactively fixes existing generations.

Related pilot decision: pti/infrastructure-asset-register#11

Proposed work

  • In the nixos-config flake's Mercurius NixOS module, set system.configurationRevision from the top-level flake's clean Git revision (for example, self.rev or null). Do not substitute dirtyRev, the current checkout HEAD at inspection time, or the nixpkgs input revision as though it identified the committed system source.
  • Decide and document the dirty/uncommitted-source behavior explicitly: report unknown (or fail a deployment preflight), rather than silently attributing uncommitted bytes to a clean commit. Keep the flake lockfile pinned with the source commit.
  • Add a short read-only provenance runbook: record the full source commit, evaluated top-level output path and post-activation /run/current-system path; read the revision from the active generation (for example, /run/current-system/sw/bin/nixos-version --configuration-revision). Distinguish an embedded revision/output-path match from authenticated evidence of the historical deployment action.
  • Implement and review the source change separately from any live nixos-rebuild switch; do not change the live host merely to backfill pilot evidence.

Acceptance criteria

  • A clean, revision-pinned evaluation of nixosConfigurations.mercurius.config.system.configurationRevision yields the expected full top-level flake commit SHA; a dirty/uncommitted evaluation cannot misleadingly report that SHA as covering uncommitted changes.
  • The system builds/checks from the reviewed source, and tests/documentation cover the chosen dirty-tree behavior.
  • After a separately approved future activation, read back the embedded revision from the active generation and record it alongside the current-system store path and the deployment record. Until then, mark live verification pending, not complete.

Reference: NixOS's system.configurationRevision option is the Git revision of the top-level flake and defaults to null: https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/misc/version.nix

## Why The Mercurius asset-roster pilot records the active NixOS generation separately from a pinned `nixos-config` Git commit. The current remote `main` flake defines `nixosConfigurations.mercurius` but does not explicitly set `system.configurationRevision`; a generation store path alone does not establish which commit was used for deployment. We should make future generations report their source revision without claiming this retroactively fixes existing generations. Related pilot decision: https://forge.snamellit.com/pti/infrastructure-asset-register/pulls/11 ## Proposed work - In the `nixos-config` flake's Mercurius NixOS module, set `system.configurationRevision` from the top-level flake's clean Git revision (for example, `self.rev or null`). Do **not** substitute `dirtyRev`, the current checkout HEAD at inspection time, or the `nixpkgs` input revision as though it identified the committed system source. - Decide and document the dirty/uncommitted-source behavior explicitly: report unknown (or fail a deployment preflight), rather than silently attributing uncommitted bytes to a clean commit. Keep the flake lockfile pinned with the source commit. - Add a short read-only provenance runbook: record the full source commit, evaluated top-level output path and post-activation `/run/current-system` path; read the revision from the active generation (for example, `/run/current-system/sw/bin/nixos-version --configuration-revision`). Distinguish an embedded revision/output-path match from authenticated evidence of the historical deployment action. - Implement and review the source change separately from any live `nixos-rebuild switch`; do not change the live host merely to backfill pilot evidence. ## Acceptance criteria - A clean, revision-pinned evaluation of `nixosConfigurations.mercurius.config.system.configurationRevision` yields the expected full top-level flake commit SHA; a dirty/uncommitted evaluation cannot misleadingly report that SHA as covering uncommitted changes. - The system builds/checks from the reviewed source, and tests/documentation cover the chosen dirty-tree behavior. - After a separately approved future activation, read back the embedded revision from the **active generation** and record it alongside the current-system store path and the deployment record. Until then, mark live verification pending, not complete. Reference: NixOS's `system.configurationRevision` option is the Git revision of the top-level flake and defaults to `null`: https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/misc/version.nix
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
pti/nixos-config#1
No description provided.