modules/bindmounts: add module for home bind mounts

This commit is contained in:
Infinidoge 2021-11-10 11:50:39 -05:00
parent 3fb0e34ba0
commit fec66eeb42
2 changed files with 286 additions and 3 deletions

View file

@ -1,7 +1,33 @@
{ lib }:
lib.makeExtensible (self:
{
flattenListSet = imports: (lib.lists.flatten (builtins.concatLists (builtins.attrValues imports)));
flattenSetList = attrSet: (builtins.mapAttrs (name: value: lib.lists.flatten value) attrSet);
with lib;
rec {
flattenListSet = imports: (flatten (concatLists (attrValues imports)));
flattenSetList = attrSet: (mapAttrs (name: value: flatten value) attrSet);
# ["/home/user/" "/.screenrc"] -> ["home" "user" ".screenrc"]
splitPath = paths:
(filter
(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"
concatPaths = paths:
let
prefix = optionalString (hasPrefix "/" (head paths)) "/";
path = dirListToPath (splitPath paths);
in
prefix + path;
sanitizeName = name:
replaceStrings
[ "." ] [ "" ]
(strings.sanitizeDerivationName (removePrefix "/" name));
}
)