about summary refs log tree commit diff
path: root/nixos/modules/misc/version.nix
diff options
context:
space:
mode:
authorelseym <elseym@me.com>2020-01-10 21:24:31 +0100
committerelseym <elseym@me.com>2020-01-10 22:29:48 +0100
commitc9214c394b248e1f26e45dbe1be2bd82363af3a6 (patch)
treef28e88086f844a4d781fc9eb23bf7c078814b963 /nixos/modules/misc/version.nix
parentb74c26a17f1856735577c29d92939721d542f0f5 (diff)
lib.commitIdFromGitRepo: support git-worktree
lib.commitIdFromGitRepo now resolves the refs from the
parent repository in case the supplied path is a file
containing the path to said repository. this adds support
for git-worktree and things alike. see gitrepository-layout(5).

this also:
- adds a new boolean function lib.pathIsRegularFile to
  check whether a path is a regular file
- patches lib.revisionWithDefault and
  the revision and versionSuffix attributes in
  config.system.nixos in order to support git-worktrees
Diffstat (limited to 'nixos/modules/misc/version.nix')
-rw-r--r--nixos/modules/misc/version.nix4
1 files changed, 2 insertions, 2 deletions
diff --git a/nixos/modules/misc/version.nix b/nixos/modules/misc/version.nix
index b85614771ee40..ddbd3963cc57a 100644
--- a/nixos/modules/misc/version.nix
+++ b/nixos/modules/misc/version.nix
@@ -91,8 +91,8 @@ in
       # These defaults are set here rather than up there so that
       # changing them would not rebuild the manual
       version = mkDefault (cfg.release + cfg.versionSuffix);
-      revision      = mkIf (pathIsDirectory gitRepo) (mkDefault            gitCommitId);
-      versionSuffix = mkIf (pathIsDirectory gitRepo) (mkDefault (".git." + gitCommitId));
+      revision      = mkIf (pathExists gitRepo) (mkDefault            gitCommitId);
+      versionSuffix = mkIf (pathExists gitRepo) (mkDefault (".git." + gitCommitId));
     };
 
     # Generate /etc/os-release.  See