mirror of
https://git.pvv.ntnu.no/Drift/pvv-nixos-config.git
synced 2025-06-05 21:25:22 +02:00
justfil: _a_machine: remember last choice
This commit is contained in:
parent
48a5f4e79e
commit
4e44da29b5
20
justfile
20
justfile
@ -21,5 +21,23 @@ run-vm machine=`just _a_machine`:
|
|||||||
| xargs -L 1 nix flake lock --update-input
|
| xargs -L 1 nix flake lock --update-input
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# helpers
|
||||||
|
|
||||||
|
[no-exit-message]
|
||||||
_a_machine:
|
_a_machine:
|
||||||
nix eval .#nixosConfigurations --apply builtins.attrNames --json | jq .[] -r | gum filter
|
#!/usr/bin/env -S sh -euo pipefail
|
||||||
|
machines="$(
|
||||||
|
nix eval {{nix_eval_opts}} .#nixosConfigurations --apply builtins.attrNames --json | jq .[] -r
|
||||||
|
)"
|
||||||
|
[ -n "$machines" ] || { echo >&2 "ERROR: no machines found"; false; }
|
||||||
|
if [ -s .direnv/vars/last-machine.txt ]; then
|
||||||
|
machines="$(
|
||||||
|
grep <<<"$machines" -xF "$(cat .direnv/vars/last-machine.txt)" ||:
|
||||||
|
grep <<<"$machines" -xFv "$(cat .direnv/vars/last-machine.txt)" ||:
|
||||||
|
)"
|
||||||
|
fi
|
||||||
|
choice="$(gum filter <<<"$machines")"
|
||||||
|
mkdir -p .direnv/vars
|
||||||
|
cat <<<"$choice" >.direnv/vars/last-machine.txt
|
||||||
|
cat <<<"$choice"
|
||||||
|
Loading…
Reference in New Issue
Block a user