mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-10 18:12:34 +09:00
lib.sources.pathType and co.: Move to lib.filesystem
These functions only work with the filesystem, they don't import anything as sources
This commit is contained in:
parent
a8e4f58d90
commit
c701a4dd29
3 changed files with 47 additions and 21 deletions
|
@ -117,10 +117,11 @@ let
|
||||||
inherit (self.meta) addMetaAttrs dontDistribute setName updateName
|
inherit (self.meta) addMetaAttrs dontDistribute setName updateName
|
||||||
appendToName mapDerivationAttrset setPrio lowPrio lowPrioSet hiPrio
|
appendToName mapDerivationAttrset setPrio lowPrio lowPrioSet hiPrio
|
||||||
hiPrioSet getLicenseFromSpdxId getExe;
|
hiPrioSet getLicenseFromSpdxId getExe;
|
||||||
inherit (self.sources) pathType pathIsDirectory cleanSourceFilter
|
inherit (self.filesystem) pathType pathIsDirectory pathIsRegularFile;
|
||||||
|
inherit (self.sources) cleanSourceFilter
|
||||||
cleanSource sourceByRegex sourceFilesBySuffices
|
cleanSource sourceByRegex sourceFilesBySuffices
|
||||||
commitIdFromGitRepo cleanSourceWith pathHasContext
|
commitIdFromGitRepo cleanSourceWith pathHasContext
|
||||||
canCleanSource pathIsRegularFile pathIsGitRepo;
|
canCleanSource pathIsGitRepo;
|
||||||
inherit (self.modules) evalModules setDefaultModuleLocation
|
inherit (self.modules) evalModules setDefaultModuleLocation
|
||||||
unifyModuleSyntax applyModuleArgsIfFunction mergeModules
|
unifyModuleSyntax applyModuleArgsIfFunction mergeModules
|
||||||
mergeModules' mergeOptionDecls evalOptionValue mergeDefinitions
|
mergeModules' mergeOptionDecls evalOptionValue mergeDefinitions
|
||||||
|
|
|
@ -2,12 +2,38 @@
|
||||||
{ lib }:
|
{ lib }:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
inherit (builtins)
|
||||||
|
getAttr
|
||||||
|
readDir
|
||||||
|
pathExists
|
||||||
|
;
|
||||||
|
|
||||||
inherit (lib.strings)
|
inherit (lib.strings)
|
||||||
hasPrefix
|
hasPrefix
|
||||||
;
|
;
|
||||||
|
|
||||||
|
inherit (lib.filesystem)
|
||||||
|
pathType
|
||||||
|
;
|
||||||
in
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/*
|
||||||
|
Returns the type of a path: regular (for file), symlink, or directory.
|
||||||
|
*/
|
||||||
|
pathType = path: getAttr (baseNameOf path) (readDir (dirOf path));
|
||||||
|
|
||||||
|
/*
|
||||||
|
Returns true if the path exists and is a directory, false otherwise.
|
||||||
|
*/
|
||||||
|
pathIsDirectory = path: if pathExists path then (pathType path) == "directory" else false;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Returns true if the path exists and is a regular file, false otherwise.
|
||||||
|
*/
|
||||||
|
pathIsRegularFile = path: if pathExists path then (pathType path) == "regular" else false;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
A map of all haskell packages defined in the given path,
|
A map of all haskell packages defined in the given path,
|
||||||
identified by having a cabal file with the same name as the
|
identified by having a cabal file with the same name as the
|
||||||
|
|
|
@ -18,21 +18,11 @@ let
|
||||||
pathExists
|
pathExists
|
||||||
readFile
|
readFile
|
||||||
;
|
;
|
||||||
|
inherit (lib.filesystem)
|
||||||
/*
|
pathType
|
||||||
Returns the type of a path: regular (for file), symlink, or directory.
|
pathIsDirectory
|
||||||
*/
|
pathIsRegularFile
|
||||||
pathType = path: getAttr (baseNameOf path) (readDir (dirOf path));
|
;
|
||||||
|
|
||||||
/*
|
|
||||||
Returns true if the path exists and is a directory, false otherwise.
|
|
||||||
*/
|
|
||||||
pathIsDirectory = path: if pathExists path then (pathType path) == "directory" else false;
|
|
||||||
|
|
||||||
/*
|
|
||||||
Returns true if the path exists and is a regular file, false otherwise.
|
|
||||||
*/
|
|
||||||
pathIsRegularFile = path: if pathExists path then (pathType path) == "regular" else false;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
A basic filter for `cleanSourceWith` that removes
|
A basic filter for `cleanSourceWith` that removes
|
||||||
|
@ -271,11 +261,20 @@ let
|
||||||
};
|
};
|
||||||
|
|
||||||
in {
|
in {
|
||||||
inherit
|
|
||||||
pathType
|
|
||||||
pathIsDirectory
|
|
||||||
pathIsRegularFile
|
|
||||||
|
|
||||||
|
pathType = lib.warnIf (lib.isInOldestRelease 2305)
|
||||||
|
"lib.sources.pathType has been moved to lib.filesystem.pathType."
|
||||||
|
lib.filesystem.pathType;
|
||||||
|
|
||||||
|
pathIsDirectory = lib.warnIf (lib.isInOldestRelease 2305)
|
||||||
|
"lib.sources.pathIsDirectory has been moved to lib.filesystem.pathIsDirectory."
|
||||||
|
lib.filesystem.pathIsDirectory;
|
||||||
|
|
||||||
|
pathIsRegularFile = lib.warnIf (lib.isInOldestRelease 2305)
|
||||||
|
"lib.sources.pathIsRegularFile has been moved to lib.filesystem.pathIsRegularFile."
|
||||||
|
lib.filesystem.pathIsRegularFile;
|
||||||
|
|
||||||
|
inherit
|
||||||
pathIsGitRepo
|
pathIsGitRepo
|
||||||
commitIdFromGitRepo
|
commitIdFromGitRepo
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue