From 2c6f80380f897104f4e920265cc6a3040cfab909 Mon Sep 17 00:00:00 2001 From: Daiderd Jordan Date: Sun, 3 Dec 2017 18:22:48 +0100 Subject: [PATCH] improve git revision detection lib.pathIsDirectory doesn't follow symlinks causing the git revision detection to fail if NIX_PATH points to a symlink. --- modules/system/version.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/system/version.nix b/modules/system/version.nix index 087e8ddc..72aeea77 100644 --- a/modules/system/version.nix +++ b/modules/system/version.nix @@ -8,7 +8,7 @@ let defaultStateVersion = options.system.stateVersion.default; gitCommitId = lib.substring 0 7 (commitIdFromGitRepo gitRepo); - gitRepo = "${toString pkgs.path}/.git"; + gitRepo = "${toString pkgs.path}/.git/"; releaseFile = "${toString pkgs.path}/.version"; revisionFile = "${toString pkgs.path}/.git-revision"; suffixFile = "${toString pkgs.path}/.version-suffix"; @@ -71,8 +71,8 @@ in # These defaults are set here rather than up there so that # changing them would not rebuild the manual system.nixpkgsVersion = mkDefault (cfg.nixpkgsRelease + cfg.nixpkgsVersionSuffix); - system.nixpkgsRevision = mkIf (pathIsDirectory gitRepo) (mkDefault gitCommitId); - system.nixpkgsVersionSuffix = mkIf (pathIsDirectory gitRepo) (mkDefault (".git." + gitCommitId)); + system.nixpkgsRevision = mkIf (builtins.pathExists gitRepo) (mkDefault gitCommitId); + system.nixpkgsVersionSuffix = mkIf (builtins.pathExists gitRepo) (mkDefault (".git." + gitCommitId)); assertions = [ { assertion = cfg.stateVersion <= defaultStateVersion; message = "system.stateVersion = ${toString cfg.stateVersion}; is not a valid value"; } ];