version.nix: extract revision-fetching function
This commit is contained in:
@@ -5,7 +5,6 @@ with lib;
|
||||
let
|
||||
cfg = config.system.nixos;
|
||||
|
||||
revisionFile = "${toString pkgs.path}/.git-revision";
|
||||
gitRepo = "${toString pkgs.path}/.git";
|
||||
gitCommitId = lib.substring 0 7 (commitIdFromGitRepo gitRepo);
|
||||
in
|
||||
@@ -37,9 +36,7 @@ in
|
||||
nixos.revision = mkOption {
|
||||
internal = true;
|
||||
type = types.str;
|
||||
default = if pathIsDirectory gitRepo then commitIdFromGitRepo gitRepo
|
||||
else if pathExists revisionFile then fileContents revisionFile
|
||||
else "master";
|
||||
default = lib.trivial.revisionWithDefault "master";
|
||||
description = "The Git revision from which this NixOS configuration was built.";
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user