nixos/modules/misc/version.nix: check that .git is a directory
That's not the case for git submodules Fixes #15928
This commit is contained in:
parent
30c94e10c3
commit
4c5fdf42ed
|
@ -4,6 +4,11 @@ let lib = import ./default.nix; in
|
||||||
|
|
||||||
rec {
|
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
|
# Bring in a path as a source, filtering out all Subversion and CVS
|
||||||
# directories, as well as backup files (*~).
|
# directories, as well as backup files (*~).
|
||||||
|
@ -29,6 +34,7 @@ rec {
|
||||||
in type == "directory" || lib.any (ext: lib.hasSuffix ext base) exts;
|
in type == "directory" || lib.any (ext: lib.hasSuffix ext base) exts;
|
||||||
in builtins.filterSource filter path;
|
in builtins.filterSource filter path;
|
||||||
|
|
||||||
|
|
||||||
# Get the commit id of a git repo
|
# Get the commit id of a git repo
|
||||||
# Example: commitIdFromGitRepo <nixpkgs/.git>
|
# Example: commitIdFromGitRepo <nixpkgs/.git>
|
||||||
commitIdFromGitRepo =
|
commitIdFromGitRepo =
|
||||||
|
|
|
@ -104,8 +104,8 @@ in
|
||||||
# changing them would not rebuild the manual
|
# changing them would not rebuild the manual
|
||||||
nixosLabel = mkDefault (maybeEnv "NIXOS_LABEL" cfg.nixosVersion);
|
nixosLabel = mkDefault (maybeEnv "NIXOS_LABEL" cfg.nixosVersion);
|
||||||
nixosVersion = mkDefault (maybeEnv "NIXOS_VERSION" (cfg.nixosRelease + cfg.nixosVersionSuffix));
|
nixosVersion = mkDefault (maybeEnv "NIXOS_VERSION" (cfg.nixosRelease + cfg.nixosVersionSuffix));
|
||||||
nixosRevision = mkIf (pathExists gitRepo) (mkDefault gitCommitId);
|
nixosRevision = mkIf (pathIsDirectory gitRepo) (mkDefault gitCommitId);
|
||||||
nixosVersionSuffix = mkIf (pathExists gitRepo) (mkDefault (".git." + gitCommitId));
|
nixosVersionSuffix = mkIf (pathIsDirectory gitRepo) (mkDefault (".git." + gitCommitId));
|
||||||
|
|
||||||
# Note: code names must only increase in alphabetical order.
|
# Note: code names must only increase in alphabetical order.
|
||||||
nixosCodeName = "Flounder";
|
nixosCodeName = "Flounder";
|
||||||
|
|
Loading…
Reference in New Issue