about summary refs log tree commit diff
path: root/nixos/modules
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2020-02-10 15:25:44 +0100
committerEelco Dolstra <edolstra@gmail.com>2020-02-10 15:45:15 +0100
commitc05cc615f2ef65d223700409fb91915bf83fab4d (patch)
treeb41e7078b7a3272bbe2990c90b60231b9f60105d /nixos/modules
parentb98ea4560899470536506426a74704a907fcfc8f (diff)
downloadnixlib-c05cc615f2ef65d223700409fb91915bf83fab4d.tar
nixlib-c05cc615f2ef65d223700409fb91915bf83fab4d.tar.gz
nixlib-c05cc615f2ef65d223700409fb91915bf83fab4d.tar.bz2
nixlib-c05cc615f2ef65d223700409fb91915bf83fab4d.tar.lz
nixlib-c05cc615f2ef65d223700409fb91915bf83fab4d.tar.xz
nixlib-c05cc615f2ef65d223700409fb91915bf83fab4d.tar.zst
nixlib-c05cc615f2ef65d223700409fb91915bf83fab4d.zip
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.
Diffstat (limited to 'nixos/modules')
-rw-r--r--nixos/modules/installer/tools/nixos-version.sh4
-rw-r--r--nixos/modules/misc/version.nix4
2 files changed, 6 insertions, 2 deletions
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.";
     };