]>
git.immae.eu Git - perso/Immae/Config/Nix.git/blob - scripts/refresh_flakes
23 flake
="$(realpath $1)"
24 if [ "${refreshed[$flake]}" = 1 ]; then
27 pushd "$flake" 2>/dev
/null
>/dev
/null
28 if [ -z "$no_new_inputs" ]; then
29 nix
--no-warn-dirty flake lock
31 if [ ! -e "$flake/flake.lock" ]; then
32 popd 2>/dev
/null
>/dev
/null
37 deps
=$(jq -r '. as $root | .nodes[.root].inputs|values|to_entries|map({ key: .key, value: $root.nodes[.value].original.path })[]|select(.value
!= null
)|.key
+ " " + .value
' < flake.lock)
38 if [ -n "$deps" ]; then
39 while read depname deppath; do
40 refresh_deps "$deppath"
41 inputs+=(--update-input "$depname")
44 nix --no-warn-dirty flake lock "${inputs[@]}"
45 popd 2>/dev/null >/dev/null
49 git_dir=$(git rev-parse --show-toplevel)
51 # If argument is given (flake.nix or directory containing), refresh that argument
52 # Otherwise, if we are in a subdirectory containing a flake.nix, refresh that
53 # Otherwise, refresh all
54 if [ -n "$flake_or_dir" ]; then
55 if [ -d "$flake_or_dir" -a -e "$1/flake.nix" ]; then
56 refresh_deps "$flake_or_dir"
57 elif [ -f "$flake_or_dir" -a -e "$(dirname $flake_or_dir)/flake.nix" ]; then
58 refresh_deps "$(dirname $flake_or_dir)"
60 echo "No flake.nix file in specified location"
64 if [ "$(pwd)" != "$git_dir" -a -e "$(pwd)/flake.nix" ]; then
67 find $git_dir -name "flake.lock" | while read flake; do
68 refresh_deps "$(dirname $flake)"