diff options
Diffstat (limited to 'scripts/update_flake')
-rwxr-xr-x | scripts/update_flake | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/scripts/update_flake b/scripts/update_flake new file mode 100755 index 0000000..3a9cd17 --- /dev/null +++ b/scripts/update_flake | |||
@@ -0,0 +1,18 @@ | |||
1 | #!/usr/bin/env bash | ||
2 | |||
3 | searched_file="$1" | ||
4 | |||
5 | get_inputs() { | ||
6 | flake=$1 | ||
7 | name=$2 | ||
8 | cat "$flake" | jq -r --arg name "$name" '.nodes|to_entries[]|select(.value.original.path != null and (.value.original.path|test("(../)+" + $name)))|.key' | ||
9 | } | ||
10 | |||
11 | find flakes -name "flake.lock" | while read flake; do | ||
12 | for input in $(get_inputs "$flake" "$searched_file"); do | ||
13 | echo "updating $input in $(dirname "$flake")" | ||
14 | pushd "$(dirname "$flake")" >/dev/null 2>/dev/null | ||
15 | nix flake update --update-input "$input" | ||
16 | popd >/dev/null 2>/dev/null | ||
17 | done | ||
18 | done | ||