]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - scripts/update_flake
Squash changes containing private information
[perso/Immae/Config/Nix.git] / scripts / update_flake
diff --git a/scripts/update_flake b/scripts/update_flake
new file mode 100755 (executable)
index 0000000..3a9cd17
--- /dev/null
@@ -0,0 +1,18 @@
+#!/usr/bin/env bash
+
+searched_file="$1"
+
+get_inputs() {
+  flake=$1
+  name=$2
+  cat "$flake" | jq -r --arg name "$name" '.nodes|to_entries[]|select(.value.original.path != null and (.value.original.path|test("(../)+" + $name)))|.key'
+}
+
+find flakes -name "flake.lock" | while read flake; do
+  for input in $(get_inputs "$flake" "$searched_file"); do
+    echo "updating $input in $(dirname "$flake")"
+    pushd "$(dirname "$flake")" >/dev/null 2>/dev/null
+    nix flake update --update-input "$input"
+    popd >/dev/null 2>/dev/null
+  done
+done