diff --git a/.envrc b/.envrc index 532f64c..04508df 100644 --- a/.envrc +++ b/.envrc @@ -21,7 +21,8 @@ if ! test -s .remote.toml; then else use flake .#envrc-remote echo - just list-remotes + just remote-current + just remote-list echo fi diff --git a/justfile b/justfile index 47b14bc..124cacf 100644 --- a/justfile +++ b/justfile @@ -1,10 +1,7 @@ -@_default: - #just --choose # TODO: achieve something better with `gum` - #just --list --list-prefix ' just ' - just "$(gum choose $(just --summary --unsorted))" +export GUM_FILTER_HEIGHT := "15" -@set-remote: - tomlq <.remote.toml '.hosts | to_entries[] | "remote-set \(.key+1) # -> \(.value.host)" | @sh "\(.)"' -r | xargs gum choose | sh +@_default: + just "$(gum filter --placeholder "Pick a recipie..." $(just --summary --unsorted))" eval hostname=`just _a-host`: nix eval .#nixosConfigurations.{{hostname}}.config.system.build.toplevel.outPath @@ -35,9 +32,22 @@ switch: boot: sudo nixos-rebuild boot --flake . -@list-remotes: - echo Current remote: $(remote-host) +@_a-host: + nix eval .#nixosHostnames --json 2>/dev/null | jq '.[]' -r | gum filter --placeholder "Pick a host..." + +@remote-current: + >&2 echo Current remote: $(remote-host) + +@remote-list: tomlq <.remote.toml '.hosts | to_entries[] | "remote-set \(.key+1) # -> \(.value.host)"' -r -@_a-host: - nix eval .#nixosHostnames --json 2>/dev/null | jq '.[]' -r | gum filter --height 10 --placeholder "Pick a host..." +@_a-remote-label: + just remote-list | gum filter --placeholder "Pick a remote..." | cut -d' ' -f2 + +@_a-remote-fqdn: + just remote-list | gum filter --placeholder "Pick a remote..." | cut -d' ' -f5- + +@remote-set remote=`just remote-current && just _a-remote-label`: + remote-set {{remote}} + +# nixos-rebuild --flake .# --target-host root@.nixos.org --use-substitutes switch