about summary refs log tree commit diff stats
path: root/update_common_files.sh
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-04-02 13:15:35 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-04-02 13:24:34 +0200
commit7a366a44cf7f0aa2cb3471b9b03a83acba157707 (patch)
tree459d6fb8d965111414fb187415aad0d16dc64792 /update_common_files.sh
parentchore(version): v0.5.0 (diff)
downloadflake-templates-7a366a44cf7f0aa2cb3471b9b03a83acba157707.tar.gz
flake-templates-7a366a44cf7f0aa2cb3471b9b03a83acba157707.zip
build(update_common_files): Allow to specify which file to move where
Diffstat (limited to 'update_common_files.sh')
-rwxr-xr-xupdate_common_files.sh18
1 files changed, 13 insertions, 5 deletions
diff --git a/update_common_files.sh b/update_common_files.sh
index 3b7dddd..c9c06c0 100755
--- a/update_common_files.sh
+++ b/update_common_files.sh
@@ -5,14 +5,22 @@ ROOT="$(git rev-parse --show-toplevel)"
 # This results in fd returning relative paths
 cd "$ROOT/common" || echo "BUG, no root dir!"
 
-fd . "." --type file --hidden | while read -r file; do
+file_spec="$(nix eval --file "$ROOT/common/default.nix" --json)"
+
+echo "$file_spec" | jq --raw-output 'keys | join("\n")' | while read -r file; do
     [ -n "$first_run_done" ] && echo
     echo "Instantiating '$file'..."
-    fd . "../templates" --type directory --max-depth 1 | while read -r template; do
-        echo "   done in '$template'."
-        rm "$template$file"
-        cp "$file" "$template$file"
+
+    echo "$file_spec" | jq --raw-output ".[\"$file\"] | join(\"\n\")" | while read -r language; do
+        template="$ROOT/templates/$language";
+        echo "    done for '$language'."
+
+         mkdir --parents "$(dirname "$template/$file")"
+         rm "$template/$file"
+         cp "$file" "$template/$file"
     done
+
+
     first_run_done=yes
 done