2024-02-22 20:47:56 +01:00
|
|
|
export GUM_FILTER_HEIGHT := "15"
|
2024-01-27 04:55:16 +01:00
|
|
|
|
2024-02-22 20:47:56 +01:00
|
|
|
@_default:
|
|
|
|
just "$(gum filter --placeholder "Pick a recipie..." $(just --summary --unsorted))"
|
2024-02-01 02:06:03 +01:00
|
|
|
|
2024-08-10 17:00:03 +02:00
|
|
|
eval hostname=`just _a_host`:
|
2024-10-07 11:39:30 +02:00
|
|
|
nix eval .#nixosConfigurations."{{hostname}}".config.system.build.toplevel.outPath --show-trace
|
2024-02-18 22:14:40 +01:00
|
|
|
|
2024-08-10 17:00:03 +02:00
|
|
|
report hostname=`just _a_host`:
|
2024-09-13 18:25:22 +02:00
|
|
|
nix eval .#nixosReports."{{hostname}}" --json | yq . --yaml-output | bat --language yaml --style plain --paging never
|
2024-02-18 22:14:40 +01:00
|
|
|
|
|
|
|
reports:
|
|
|
|
nix eval .#nixosReports --json | yq . --yaml-output | bat --language yaml --style plain --paging never
|
2024-01-27 04:55:16 +01:00
|
|
|
|
|
|
|
update:
|
|
|
|
git reset flake.lock
|
|
|
|
git restore flake.lock
|
|
|
|
git pull --rebase --autostash
|
|
|
|
nix flake update --commit-lock-file
|
|
|
|
@mkdir -p .direnv/
|
|
|
|
@echo "$(date +%Y-%m-%d)" > .direnv/pull-date
|
|
|
|
|
2024-08-16 00:41:59 +02:00
|
|
|
@update-select:
|
|
|
|
git reset flake.lock
|
|
|
|
git restore flake.lock
|
|
|
|
nix eval .#inputs --apply builtins.attrNames --json \
|
|
|
|
| jq '.[]' -r \
|
|
|
|
| gum choose --no-limit --height=15 \
|
|
|
|
| xargs nix flake update --commit-lock-file
|
|
|
|
|
2024-10-10 21:08:00 +02:00
|
|
|
#build hostname=`if test -z "${IS_REMOTE_ENV:-}"; then just _a_host_timeout; else echo; fi`:
|
|
|
|
build hostname="":
|
2024-09-13 18:25:22 +02:00
|
|
|
nixos-rebuild build --accept-flake-config --show-trace --flake .#"{{hostname}}"
|
|
|
|
|
2024-10-10 21:08:00 +02:00
|
|
|
#build-no-remote-builders hostname=`if test -z "$IS_REMOTE_ENV"; then just _a_host_timeout; else echo; fi`:
|
|
|
|
build-no-remote-builders hostname="":
|
2024-09-15 22:02:35 +02:00
|
|
|
nixos-rebuild build --accept-flake-config --show-trace --flake .#"{{hostname}}" --builders ""
|
|
|
|
|
2024-09-13 18:25:22 +02:00
|
|
|
build-vm hostname=`just _a_host`:
|
|
|
|
nixos-rebuild build-vm --accept-flake-config --show-trace --flake .#"{{hostname}}"
|
2024-01-27 04:55:16 +01:00
|
|
|
|
|
|
|
test:
|
2024-08-05 00:02:20 +02:00
|
|
|
sudo nixos-rebuild test --accept-flake-config --show-trace --flake .
|
2024-01-27 04:55:16 +01:00
|
|
|
|
|
|
|
switch:
|
2024-08-05 00:02:20 +02:00
|
|
|
sudo nixos-rebuild switch --accept-flake-config --show-trace --flake .
|
2024-01-27 04:55:16 +01:00
|
|
|
|
|
|
|
boot:
|
2024-08-05 00:02:20 +02:00
|
|
|
sudo nixos-rebuild boot --accept-flake-config --show-trace --flake .
|
2024-02-01 02:06:03 +01:00
|
|
|
|
2024-08-16 23:46:54 +02:00
|
|
|
boot-and-reboot:
|
|
|
|
sudo nixos-rebuild boot --accept-flake-config --show-trace --flake .
|
|
|
|
sudo reboot
|
|
|
|
|
2024-08-10 17:00:03 +02:00
|
|
|
push hostname=`just _a_host` cmd=`gum choose test switch boot --header "Select mode..."`:
|
2024-03-02 15:16:04 +01:00
|
|
|
nixos-rebuild build --flake .#{{hostname}}
|
|
|
|
@echo pushing...
|
2024-08-16 23:46:54 +02:00
|
|
|
NIX_NO_NOM=1 nixos-rebuild {{cmd}} --flake .#{{hostname}} --target-host root@$(nix eval .#nixosConfigurations.{{hostname}}.config.networking.fqdn --json | jq . -r) --use-substitutes
|
|
|
|
#NIX_NO_NOM=1 NIX_SSHOPTS="-tt" nixos-rebuild {{cmd}} --flake .#{{hostname}} --use-remote-sudo --target-host $(nix eval .#nixosReports.{{hostname}}.fqdn --json | jq . -r) --use-substitutes
|
2024-02-29 18:39:57 +01:00
|
|
|
|
2024-08-10 17:00:17 +02:00
|
|
|
inspect:
|
|
|
|
nix run -- nixpkgs#nix-inspect -p .
|
|
|
|
|
2024-09-27 18:07:05 +02:00
|
|
|
inspect-config host=`just _a_host` prefix="":
|
|
|
|
nix run -- nixpkgs#nix-inspect -e '(builtins.getFlake "'"$PWD"'").nixosConfigurations.{{host}}.config{{ if prefix == "" { "" } else { "." + prefix } }}'
|
2024-09-13 18:25:22 +02:00
|
|
|
|
2024-08-10 17:00:03 +02:00
|
|
|
@_a_host:
|
2024-09-13 18:25:22 +02:00
|
|
|
hostnames="$(nix eval .#nixosConfigurations --apply builtins.attrNames --json 2>/dev/null | jq '.[]' -r)"; \
|
|
|
|
if test "$(grep <<<"$hostnames" "^$(hostname)$" | wc -l)" -eq 1; then hostnames="$(hostname; grep <<<"$hostnames" -v "^$(hostname)$")"; fi; \
|
|
|
|
gum <<<"$hostnames" filter --placeholder "Pick a host..."
|
|
|
|
|
2024-10-10 21:08:00 +02:00
|
|
|
# ctrl-c is counted as a timeout...
|
|
|
|
@_a_host_timeout:
|
|
|
|
hostnames="$(nix eval .#nixosConfigurations --apply builtins.attrNames --json 2>/dev/null | jq '.[]' -r)"; \
|
|
|
|
if test "$(grep <<<"$hostnames" "^$(hostname)$" | wc -l)" -eq 1; then hostnames="$(hostname; grep <<<"$hostnames" -v "^$(hostname)$")"; fi; \
|
|
|
|
gum <<<"$hostnames" filter --placeholder "Pick a host..." --timeout 5s || hostname
|
|
|
|
|
2024-09-15 22:02:35 +02:00
|
|
|
@_some_hosts:
|
|
|
|
hostnames="$(nix eval .#nixosConfigurations --apply builtins.attrNames --json 2>/dev/null | jq '.[]' -r)"; \
|
|
|
|
if test "$(grep <<<"$hostnames" "^$(hostname)$" | wc -l)" -eq 1; then hostnames="$(hostname; grep <<<"$hostnames" -v "^$(hostname)$")"; fi; \
|
|
|
|
gum <<<"$hostnames" filter --placeholder "Pick a host..." --no-limit
|
|
|
|
|
2024-09-13 18:25:22 +02:00
|
|
|
@_a_fqdn:
|
|
|
|
hostnames="$(nix eval .#nixosConfigurations --apply 'c: builtins.attrValues (builtins.mapAttrs (_: x: x.config.networking.fqdn) c)' --json 2>/dev/null | jq '.[]' -r)"; \
|
|
|
|
if test "$(grep <<<"$hostnames" "^$(hostname --fqdn)$" | wc -l)" -eq 1; then hostnames="$(hostname --fqdn; grep <<<"$hostnames" -v "^$(hostname --fqdn)$")"; fi; \
|
|
|
|
gum <<<"$hostnames" filter --placeholder "Pick a host..."
|
2024-02-22 20:47:56 +01:00
|
|
|
|
2024-09-15 22:02:35 +02:00
|
|
|
@_some_fqdns:
|
|
|
|
hostnames="$(nix eval .#nixosConfigurations --apply 'c: builtins.attrValues (builtins.mapAttrs (_: x: x.config.networking.fqdn) c)' --json 2>/dev/null | jq '.[]' -r)"; \
|
|
|
|
if test "$(grep <<<"$hostnames" "^$(hostname --fqdn)$" | wc -l)" -eq 1; then hostnames="$(hostname --fqdn; grep <<<"$hostnames" -v "^$(hostname --fqdn)$")"; fi; \
|
|
|
|
gum <<<"$hostnames" filter --placeholder "Pick a host..." --no-limit
|
|
|
|
|
2024-02-22 20:47:56 +01:00
|
|
|
@remote-current:
|
|
|
|
>&2 echo Current remote: $(remote-host)
|
|
|
|
|
|
|
|
@remote-list:
|
2024-02-01 02:06:03 +01:00
|
|
|
tomlq <.remote.toml '.hosts | to_entries[] | "remote-set \(.key+1) # -> \(.value.host)"' -r
|
2024-02-18 22:14:40 +01:00
|
|
|
|
2024-09-15 22:02:35 +02:00
|
|
|
@remote-set remote=`just remote-current && just _a_remote_label`:
|
2024-09-13 18:25:22 +02:00
|
|
|
remote-set {{remote}}
|
|
|
|
|
2024-09-15 22:02:35 +02:00
|
|
|
@_a_remote_label:
|
2024-02-22 20:47:56 +01:00
|
|
|
just remote-list | gum filter --placeholder "Pick a remote..." | cut -d' ' -f2
|
|
|
|
|
2024-09-15 22:02:35 +02:00
|
|
|
@_some_remote_labels:
|
|
|
|
just remote-list | gum filter --placeholder "Pick remotes..." --no-limit | cut -d' ' -f2
|
|
|
|
|
|
|
|
@_a_remote_fqdn:
|
2024-02-22 20:47:56 +01:00
|
|
|
just remote-list | gum filter --placeholder "Pick a remote..." | cut -d' ' -f5-
|
|
|
|
|
2024-09-15 22:02:35 +02:00
|
|
|
@_some_remote_fqdns:
|
|
|
|
just remote-list | gum filter --placeholder "Pick remote..." --no-limit | cut -d' ' -f5-
|
|
|
|
|
2024-09-13 18:25:22 +02:00
|
|
|
@_remote_ensure hostname=`just _a_fqdn`:
|
|
|
|
if test ! -s .remote.toml; then remote-init "{{ hostname }}"; \
|
|
|
|
elif tomlq <.remote.toml '.hosts | to_entries[] |.value.host' -r | grep -q "{{ hostname }}"; then true; \
|
|
|
|
else remote-add "{{ hostname }}"; \
|
|
|
|
fi
|
|
|
|
|
|
|
|
@_remote_label_from_fqdn hostname=`just _a_fqdn`:
|
2024-09-15 22:02:35 +02:00
|
|
|
tomlq <.remote.toml '.hosts | to_entries[] | select(.value.host == "{{ hostname }}") | .key+1' -r
|
|
|
|
|
|
|
|
@remote-mprocs +$cmd=`printf "just %s\n" $(just --summary --unsorted) | gum filter --placeholder "Pick a recipie..."`:
|
|
|
|
just _some_remote_labels | sed -E 's/(.*)/remote --label="\1" "env NIX_NO_NOM=1 $cmd"/g' | xargs -d'\n' mprocs
|
2024-09-13 18:25:22 +02:00
|
|
|
|
2024-09-15 22:02:35 +02:00
|
|
|
@remote-mprocs-new +$cmd=`printf "just %s\n" $(just --summary --unsorted) | gum filter --placeholder "Pick a recipie..."`:
|
|
|
|
just _some_fqdns | xe -s 'just _remote_ensure "$1"; just _remote_label_from_fqdn "$1"' | sed -E 's/(.*)/remote --label="\1" "env NIX_NO_NOM=1 $cmd"/g' | xargs -d'\n' mprocs
|
2024-02-22 20:47:56 +01:00
|
|
|
|
2024-07-08 22:30:59 +02:00
|
|
|
# TODO: support multiple labels, run in tmux
|
2024-09-15 22:02:35 +02:00
|
|
|
#remote label=`just _a_remote_label` cmd=`printf "just %s\n" $(just --summary --unsorted) | gum filter --placeholder "Pick a recipie..."`:
|
|
|
|
# remote --label={{label}} {{cmd}}
|
2024-07-08 22:30:59 +02:00
|
|
|
|
2024-08-10 17:00:03 +02:00
|
|
|
# TODO: packaged as nix-web
|
2024-02-25 21:26:02 +01:00
|
|
|
@gorgon:
|
|
|
|
# https://codeberg.org/gorgon/gorgon/src/branch/main/nix-web
|
|
|
|
# https://discourse.nixos.org/t/a-web-ui-for-the-nix-store-early-beta/35762
|
|
|
|
nix run 'git+https://codeberg.org/gorgon/gorgon#nix-web'
|