From c05cc615f2ef65d223700409fb91915bf83fab4d Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 10 Feb 2020 15:25:44 +0100 Subject: nixos.revision: Use null instead of "master" "master" is not a valid SHA-1 commit hash, and it's not even necessarily the branch used. 'nixos-version --revision' now returns an error if the commit hash is not known. --- nixos/modules/installer/tools/nixos-version.sh | 4 ++++ nixos/modules/misc/version.nix | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'nixos/modules') diff --git a/nixos/modules/installer/tools/nixos-version.sh b/nixos/modules/installer/tools/nixos-version.sh index 2711bc1e131e..bde6c9c30030 100644 --- a/nixos/modules/installer/tools/nixos-version.sh +++ b/nixos/modules/installer/tools/nixos-version.sh @@ -6,6 +6,10 @@ case "$1" in exit 1 ;; --hash|--revision) + if ! [[ @revision@ =~ /[0-9a-f]+/ ]]; then + echo "$0: Nixpkgs commit hash is unknown" + exit 1 + fi echo "@revision@" ;; --json) diff --git a/nixos/modules/misc/version.nix b/nixos/modules/misc/version.nix index 8dbbbe6761c4..c394ff592f49 100644 --- a/nixos/modules/misc/version.nix +++ b/nixos/modules/misc/version.nix @@ -42,8 +42,8 @@ in nixos.revision = mkOption { internal = true; - type = types.str; - default = trivial.revisionWithDefault "master"; + type = types.nullOr types.str; + default = trivial.revisionWithDefault null; description = "The Git revision from which this NixOS configuration was built."; }; -- cgit 1.4.1