aboutsummaryrefslogtreecommitdiff
path: root/scripts/update_flake
blob: 3a9cd17a3632f60ca9897e7942fd2dcea9dc5c00 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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