mirror of
https://github.com/nix-community/impermanence
synced 2024-11-13 23:27:15 +00:00
22 lines
620 B
Nix
22 lines
620 B
Nix
{ lib }:
|
|
with lib;
|
|
let
|
|
# ["/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;
|
|
in
|
|
{ inherit splitPath dirListToPath concatPaths; }
|