From 4c5fdf42ed3612db4532bc2259dd3f7c6847e077 Mon Sep 17 00:00:00 2001 From: obadz Date: Thu, 2 Jun 2016 16:03:35 +0100 Subject: nixos/modules/misc/version.nix: check that .git is a directory That's not the case for git submodules Fixes #15928 --- lib/sources.nix | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/sources.nix') diff --git a/lib/sources.nix b/lib/sources.nix index 6b19b192dfd..8e58e4b6a9d 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 commitIdFromGitRepo = -- cgit 1.4.1