1
0
Fork 0
mirror of https://github.com/LnL7/nix-darwin.git synced 2024-12-14 11:57:34 +00:00

improve git revision detection

lib.pathIsDirectory doesn't follow symlinks causing the git revision
detection to fail if NIX_PATH points to a symlink.
This commit is contained in:
Daiderd Jordan 2017-12-03 18:22:48 +01:00
parent 7045686b62
commit 2c6f80380f
No known key found for this signature in database
GPG key ID: D02435D05B810C96

View file

@ -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"; } ];