This commit is contained in:
2025-04-23 12:14:27 +02:00
parent 2468624990
commit 8e5263b5d5

40
.envrc
View File

@@ -45,30 +45,32 @@ if [[ ! -s .direnv/pull-date || "$now" != "$(cat .direnv/pull-date)" ]]; then
direnv allow # :3
# nix flake update
declare -a update_args=()
readarray -td $'\n' update_args < <(
nix eval --file flake.nix --apply 'x: builtins.attrNames x.inputs' --json \
| jq .[] -r \
| grep -v '^nixpkgs-expensive$'
! declare -F update_flake >&/dev/null || ! echo >&2 "ERROR: update_flake() already declared!"
update_flake() (
set -euo pipefail
declare -a update_args=()
readarray -td $'\n' update_args <<<"$(
nix eval --file flake.nix --apply 'x: builtins.attrNames x.inputs' --json |
jq '.[]' -r |
grep -v '^nixpkgs-expensive$'
)"
# update_args+=(--output-lock-file "$tmp"/new-flake.lock)
set -x
nix flake update "${update_args[@]}" ||
nix flake update "${update_args[@]}" --option access-tokens ""
)
# update_args+=(--output-lock-file "$tmp"/new-flake.lock)
if command -v pueue >/dev/null && pueue status >&/dev/null; then
nix flake update "${update_args[@]}"
# update and build shell in background
echo >&2 "+ pueue add --immediate nix flake update ..."
pueue add --immediate "$(declare -f update_flake); update_flake \"\$@\"; set -x; nix print-dev-env \"$flake_shell\" >/dev/null"
else
(
echo >&2 "+ pueue add --escape --immediate nix flake update ..."
task_id=$(
pueue add --print-task-id --escape --immediate nix flake update "${update_args[@]}" \
| tee >(xargs -d'\n' printf >&2 "New task added (id %s).\n")
)
(set -x
pueue add --after="$task_id" --escape nix print-dev-env "$flake_shell"
)
)
# update while blocking
update_flake
fi
unset update_args
unset -f update_flake
printf "%s\n" "$now" > .direnv/pull-date
# TODO: move to pueue job?
printf "%s\n" "$now" >.direnv/pull-date
fi
# source env