nit(lib): reformat
This commit is contained in:
parent
82729bf336
commit
ff6a1940d6
1 changed files with 25 additions and 28 deletions
|
@ -1,35 +1,32 @@
|
||||||
{ lib }:
|
{ lib }:
|
||||||
lib.makeExtensible (self:
|
lib.makeExtensible (self:
|
||||||
|
with lib;
|
||||||
|
rec {
|
||||||
|
flattenListSet = imports: (flatten (concatLists (attrValues imports)));
|
||||||
|
flattenSetList = attrSet: (mapAttrs (name: value: flatten value) attrSet);
|
||||||
|
|
||||||
with lib;
|
# ["/home/user/" "/.screenrc"] -> ["home" "user" ".screenrc"]
|
||||||
rec {
|
splitPath = paths:
|
||||||
flattenListSet = imports: (flatten (concatLists (attrValues imports)));
|
(filter
|
||||||
flattenSetList = attrSet: (mapAttrs (name: value: flatten value) attrSet);
|
(s: builtins.typeOf s == "string" && s != "")
|
||||||
|
(concatMap (builtins.split "/") paths)
|
||||||
|
);
|
||||||
|
|
||||||
|
# ["home" "user" ".screenrc"] -> "home/user/.screenrc"
|
||||||
|
dirListToPath = dirList: (concatStringsSep "/" dirList);
|
||||||
|
|
||||||
# ["/home/user/" "/.screenrc"] -> ["home" "user" ".screenrc"]
|
# ["/home/user/" "/.screenrc"] -> "/home/user/.screenrc"
|
||||||
splitPath = paths:
|
concatPaths = paths:
|
||||||
(filter
|
let
|
||||||
(s: builtins.typeOf s == "string" && s != "")
|
prefix = optionalString (hasPrefix "/" (head paths)) "/";
|
||||||
(concatMap (builtins.split "/") paths)
|
path = dirListToPath (splitPath paths);
|
||||||
);
|
in
|
||||||
|
prefix + path;
|
||||||
|
|
||||||
# ["home" "user" ".screenrc"] -> "home/user/.screenrc"
|
sanitizeName = name:
|
||||||
dirListToPath = dirList: (concatStringsSep "/" dirList);
|
replaceStrings
|
||||||
|
[ "." ] [ "" ]
|
||||||
|
(strings.sanitizeDerivationName (removePrefix "/" name));
|
||||||
|
|
||||||
# ["/home/user/" "/.screenrc"] -> "/home/user/.screenrc"
|
getMainProgram = package: "${package}/bin/${attrByPath ["meta" "mainProgram"] package.pname package}";
|
||||||
concatPaths = paths:
|
})
|
||||||
let
|
|
||||||
prefix = optionalString (hasPrefix "/" (head paths)) "/";
|
|
||||||
path = dirListToPath (splitPath paths);
|
|
||||||
in
|
|
||||||
prefix + path;
|
|
||||||
|
|
||||||
sanitizeName = name:
|
|
||||||
replaceStrings
|
|
||||||
[ "." ] [ "" ]
|
|
||||||
(strings.sanitizeDerivationName (removePrefix "/" name));
|
|
||||||
|
|
||||||
getMainProgram = package: "${package}/bin/${attrByPath ["meta" "mainProgram"] package.pname package}";
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue