2022-08-05 23:42:18 +03:00
|
|
|
{ lib, fetchAsset, runCommandNoCC }:
|
|
|
|
|
|
|
|
rootDir: let
|
|
|
|
|
2022-10-17 15:38:55 +03:00
|
|
|
prefix = (toString rootDir) + "/";
|
2022-08-05 23:42:18 +03:00
|
|
|
|
|
|
|
files = lib.filesystem.listFilesRecursive rootDir;
|
|
|
|
|
|
|
|
hydrate = index: fetchAsset { inherit index; };
|
|
|
|
|
2023-10-20 16:07:54 +03:00
|
|
|
isDvc = file: lib.strings.hasSuffix ".dvc" (toString file);
|
2022-08-05 23:42:18 +03:00
|
|
|
|
|
|
|
relative = file: lib.strings.removePrefix prefix (toString file);
|
|
|
|
|
|
|
|
files' = builtins.partition isDvc files;
|
|
|
|
|
|
|
|
filesRaw = map relative files'.wrong;
|
|
|
|
|
|
|
|
filesDvc = map (file: rec {
|
|
|
|
dvc = hydrate file;
|
|
|
|
installPath = (builtins.dirOf (relative file)) + "/${dvc.name}";
|
|
|
|
}) files'.right;
|
|
|
|
|
|
|
|
installFile = file: "install -Dm644 ${file} $out/${file}";
|
|
|
|
|
|
|
|
installDvc = dvc: "install -Dm644 ${dvc.dvc} $out/${dvc.installPath}";
|
|
|
|
|
|
|
|
in runCommandNoCC (builtins.baseNameOf rootDir) {} ''
|
|
|
|
cd ${rootDir}
|
|
|
|
mkdir $out
|
|
|
|
${lib.concatStringsSep "\n" (map installFile filesRaw)}
|
|
|
|
${lib.concatStringsSep "\n" (map installDvc filesDvc)}
|
|
|
|
''
|