summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorobadz <obadz-git@obadz.com>2016-06-02 16:03:35 +0100
committerobadz <obadz-git@obadz.com>2016-06-03 13:38:41 +0100
commit4c5fdf42ed3612db4532bc2259dd3f7c6847e077 (patch)
treefb49f82dd2791b1d7cb45c3f43ab0d9a23c1bbc3
parent30c94e10c3ab41d48db5fc45d6bc95491610d2d9 (diff)
nixos/modules/misc/version.nix: check that .git is a directory
That's not the case for git submodules Fixes #15928
-rw-r--r--lib/sources.nix6
-rw-r--r--nixos/modules/misc/version.nix4
2 files changed, 8 insertions, 2 deletions
diff --git a/lib/sources.nix b/lib/sources.nix
index 6b19b192dfd6..8e58e4b6a9dd 100644
--- a/lib/sources.nix
+++ b/lib/sources.nix
@@ -4,6 +4,11 @@ let lib = import ./default.nix; in
rec {
+ # Returns the type of a path: regular (for file), symlink, or directory
+ pathType = p: with builtins; getAttr (baseNameOf p) (readDir (dirOf p));
+
+ # Returns true if the path exists and is a directory, false otherwise
+ pathIsDirectory = p: if builtins.pathExists p then (pathType p) == "directory" else false;
# Bring in a path as a source, filtering out all Subversion and CVS
# directories, as well as backup files (*~).
@@ -29,6 +34,7 @@ rec {
in type == "directory" || lib.any (ext: lib.hasSuffix ext base) exts;
in builtins.filterSource filter path;
+
# Get the commit id of a git repo
# Example: commitIdFromGitRepo <nixpkgs/.git>
commitIdFromGitRepo =
diff --git a/nixos/modules/misc/version.nix b/nixos/modules/misc/version.nix
index fd7cadf76cc1..9a37f5950930 100644
--- a/nixos/modules/misc/version.nix
+++ b/nixos/modules/misc/version.nix
@@ -104,8 +104,8 @@ in
# changing them would not rebuild the manual
nixosLabel = mkDefault (maybeEnv "NIXOS_LABEL" cfg.nixosVersion);
nixosVersion = mkDefault (maybeEnv "NIXOS_VERSION" (cfg.nixosRelease + cfg.nixosVersionSuffix));
- nixosRevision = mkIf (pathExists gitRepo) (mkDefault gitCommitId);
- nixosVersionSuffix = mkIf (pathExists gitRepo) (mkDefault (".git." + gitCommitId));
+ nixosRevision = mkIf (pathIsDirectory gitRepo) (mkDefault gitCommitId);
+ nixosVersionSuffix = mkIf (pathIsDirectory gitRepo) (mkDefault (".git." + gitCommitId));
# Note: code names must only increase in alphabetical order.
nixosCodeName = "Flounder";