mirror of
https://github.com/nix-community/dream2nix.git
synced 2024-12-24 06:52:09 +03:00
fix and improve prepareSourceTree
This commit is contained in:
parent
42507e645c
commit
2afaae4f5b
@ -71,7 +71,7 @@ let
|
|||||||
if prefix == "" then
|
if prefix == "" then
|
||||||
name
|
name
|
||||||
else
|
else
|
||||||
"${prefix}/name";
|
"${prefix}/${name}";
|
||||||
|
|
||||||
directories =
|
directories =
|
||||||
l.mapAttrs
|
l.mapAttrs
|
||||||
@ -85,19 +85,41 @@ let
|
|||||||
|
|
||||||
files =
|
files =
|
||||||
l.mapAttrs
|
l.mapAttrs
|
||||||
(fname: _: l.trace fname rec {
|
(fname: _: rec {
|
||||||
name = fname;
|
name = fname;
|
||||||
fullPath = "${fullPath'}/${fname}";
|
fullPath = "${fullPath'}/${fname}";
|
||||||
relPath = makeNewPath relPath fname;
|
relPath = makeNewPath relPath' fname;
|
||||||
content = readTextFile fullPath;
|
content = readTextFile fullPath;
|
||||||
jsonContent = l.fromJSON content;
|
jsonContent = l.fromJSON content;
|
||||||
tomlContent = l.fromTOML content;
|
tomlContent = l.fromTOML content;
|
||||||
})
|
})
|
||||||
fileNames;
|
fileNames;
|
||||||
|
|
||||||
|
getNodeFromPath = path:
|
||||||
|
let
|
||||||
|
pathSplit = l.splitString "/" path;
|
||||||
|
dirSplit = l.init pathSplit;
|
||||||
|
leaf = l.last pathSplit;
|
||||||
|
|
||||||
|
dirAttrPath =
|
||||||
|
l.init
|
||||||
|
(l.concatMap
|
||||||
|
(x: [x] ++ ["directories"])
|
||||||
|
dirSplit);
|
||||||
|
|
||||||
|
dir = l.getAttrFromPath dirAttrPath directories;
|
||||||
|
|
||||||
|
in
|
||||||
|
if dir ? directories."${leaf}" then
|
||||||
|
dir.directories."${leaf}"
|
||||||
|
else if dir ? files."${leaf}" then
|
||||||
|
dir.files."${leaf}"
|
||||||
|
else
|
||||||
|
throw "could not find file or directory ${path} in ${fullPath'}";
|
||||||
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
inherit name files relPath;
|
inherit files getNodeFromPath name relPath;
|
||||||
|
|
||||||
fullPath = fullPath';
|
fullPath = fullPath';
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user