diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2020-02-10 15:25:44 +0100 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2020-02-10 15:45:15 +0100 |
commit | c05cc615f2ef65d223700409fb91915bf83fab4d (patch) | |
tree | b41e7078b7a3272bbe2990c90b60231b9f60105d | |
parent | b98ea4560899470536506426a74704a907fcfc8f (diff) |
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.
-rw-r--r-- | nixos/modules/installer/tools/nixos-version.sh | 4 | ||||
-rw-r--r-- | nixos/modules/misc/version.nix | 4 |
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."; }; |