just
This commit is contained in:
@@ -54,6 +54,7 @@
|
|||||||
|
|
||||||
environment.systemPackages = [
|
environment.systemPackages = [
|
||||||
pkgs.cemu
|
pkgs.cemu
|
||||||
|
pkgs.superTuxKart
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
66
justfile
66
justfile
@@ -1,3 +1,5 @@
|
|||||||
|
set positional-arguments # makes variables accesible as $1 $2 $@
|
||||||
|
export invokedir := invocation_directory()
|
||||||
export GUM_CHOOSE_HEIGHT := "15"
|
export GUM_CHOOSE_HEIGHT := "15"
|
||||||
export GUM_FILTER_HEIGHT := "15"
|
export GUM_FILTER_HEIGHT := "15"
|
||||||
|
|
||||||
@@ -32,16 +34,18 @@ update:
|
|||||||
@update-select:
|
@update-select:
|
||||||
git reset flake.lock
|
git reset flake.lock
|
||||||
git restore flake.lock
|
git restore flake.lock
|
||||||
nix eval .#inputs --apply builtins.attrNames --json 2>/dev/null \
|
nix eval --file flake.nix --apply 'x: builtins.attrNames x.inputs' --json \
|
||||||
| (printf "%s\n" --commit-lock-file; jq '.[]' -r | tr '0123456789' '9876543210' | sort | tr '0123456789' '9876543210' | grep -v "^self$") \
|
| (printf "%s\n" --commit-lock-file; jq '.[]' -r | tr '0123456789' '9876543210' | sort | tr '0123456789' '9876543210' | grep -v "^self$") \
|
||||||
| gum choose --no-limit \
|
| gum choose --no-limit \
|
||||||
| xargs nix flake update
|
| xargs nix flake update
|
||||||
git add flake.lock
|
git add flake.lock
|
||||||
|
|
||||||
|
# todo: support system-manager
|
||||||
#build hostname=`if test -z "${IS_REMOTE_ENV:-}"; then just _a_host_timeout; else printf "\n"; fi`:
|
#build hostname=`if test -z "${IS_REMOTE_ENV:-}"; then just _a_host_timeout; else printf "\n"; fi`:
|
||||||
build hostname="":
|
build hostname="":
|
||||||
nixos-rebuild build --accept-flake-config --show-trace --flake .#"{{hostname}}"
|
nixos-rebuild build --accept-flake-config --show-trace --flake .#"{{hostname}}"
|
||||||
|
|
||||||
|
# todo: support system-manager
|
||||||
#build-no-remote-builders hostname=`if test -z "$IS_REMOTE_ENV"; then just _a_host_timeout; else printf "\n"; fi`:
|
#build-no-remote-builders hostname=`if test -z "$IS_REMOTE_ENV"; then just _a_host_timeout; else printf "\n"; fi`:
|
||||||
build-no-remote-builders hostname="":
|
build-no-remote-builders hostname="":
|
||||||
nixos-rebuild build --accept-flake-config --show-trace --flake .#"{{hostname}}" --builders ""
|
nixos-rebuild build --accept-flake-config --show-trace --flake .#"{{hostname}}" --builders ""
|
||||||
@@ -78,31 +82,36 @@ inspect:
|
|||||||
inspect-config host=`just _a_host` prefix="":
|
inspect-config host=`just _a_host` prefix="":
|
||||||
nix run -- nixpkgs#nix-inspect -e '(builtins.getFlake "'"$PWD"'").nixosConfigurations."{{host}}".config{{ if prefix == "" { "" } else { "." + prefix } }}'
|
nix run -- nixpkgs#nix-inspect -e '(builtins.getFlake "'"$PWD"'").nixosConfigurations."{{host}}".config{{ if prefix == "" { "" } else { "." + prefix } }}'
|
||||||
|
|
||||||
@_a_host:
|
_a_host:
|
||||||
hostnames="$(nix eval .#nixosConfigurations --apply builtins.attrNames --json 2>/dev/null | jq '.[]' -r)"; \
|
#!/usr/bin/env -S bash -euo pipefail
|
||||||
if test "$(grep <<<"$hostnames" "^$(just remote-current)$" | wc -l)" -eq 1; then hostnames="$(just remote-current; grep <<<"$hostnames" -v "^$(just remote-current)$")"; fi; \
|
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; \
|
if test "$(grep <<<"$hostnames" "^$(just remote-current)$" | wc -l)" -eq 1; then hostnames="$(just remote-current; grep <<<"$hostnames" -v "^$(just remote-current)$")"; fi
|
||||||
|
if test "$(grep <<<"$hostnames" "^$(hostname)$" | wc -l)" -eq 1; then hostnames="$(hostname; grep <<<"$hostnames" -v "^$(hostname)$")"; fi
|
||||||
gum <<<"$hostnames" filter --placeholder "Pick a host..."
|
gum <<<"$hostnames" filter --placeholder "Pick a host..."
|
||||||
|
|
||||||
# ctrl-c is counted as a timeout...
|
# ctrl-c is counted as a timeout...
|
||||||
@_a_host_timeout:
|
_a_host_timeout:
|
||||||
hostnames="$(nix eval .#nixosConfigurations --apply builtins.attrNames --json 2>/dev/null | jq '.[]' -r)"; \
|
#!/usr/bin/env -S bash -euo pipefail
|
||||||
if test "$(grep <<<"$hostnames" "^$(hostname)$" | wc -l)" -eq 1; then hostnames="$(hostname; grep <<<"$hostnames" -v "^$(hostname)$")"; fi; \
|
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
|
gum <<<"$hostnames" filter --placeholder "Pick a host..." --timeout 5s || hostname
|
||||||
|
|
||||||
@_some_hosts:
|
_some_hosts:
|
||||||
hostnames="$(nix eval .#nixosConfigurations --apply builtins.attrNames --json 2>/dev/null | jq '.[]' -r)"; \
|
#!/usr/bin/env -S bash -euo pipefail
|
||||||
if test "$(grep <<<"$hostnames" "^$(hostname)$" | wc -l)" -eq 1; then hostnames="$(hostname; grep <<<"$hostnames" -v "^$(hostname)$")"; fi; \
|
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
|
gum <<<"$hostnames" filter --placeholder "Pick a host..." --no-limit
|
||||||
|
|
||||||
@_a_fqdn:
|
_a_fqdn:
|
||||||
hostnames="$(nix eval .#nixosConfigurations --apply 'c: builtins.attrValues (builtins.mapAttrs (_: x: x.config.networking.fqdn) c)' --json 2>/dev/null | jq '.[]' -r)"; \
|
#!/usr/bin/env -S bash -euo pipefail
|
||||||
if test "$(grep <<<"$hostnames" "^$(hostname --fqdn)$" | wc -l)" -eq 1; then hostnames="$(hostname --fqdn; grep <<<"$hostnames" -v "^$(hostname --fqdn)$")"; fi; \
|
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..."
|
gum <<<"$hostnames" filter --placeholder "Pick a host..."
|
||||||
|
|
||||||
@_some_fqdns:
|
_some_fqdns:
|
||||||
hostnames="$(nix eval .#nixosConfigurations --apply 'c: builtins.attrValues (builtins.mapAttrs (_: x: x.config.networking.fqdn) c)' --json 2>/dev/null | jq '.[]' -r)"; \
|
#!/usr/bin/env -S bash -euo pipefail
|
||||||
if test "$(grep <<<"$hostnames" "^$(hostname --fqdn)$" | wc -l)" -eq 1; then hostnames="$(hostname --fqdn; grep <<<"$hostnames" -v "^$(hostname --fqdn)$")"; fi; \
|
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
|
gum <<<"$hostnames" filter --placeholder "Pick a host..." --no-limit
|
||||||
|
|
||||||
@remote-current:
|
@remote-current:
|
||||||
@@ -116,13 +125,14 @@ inspect-config host=`just _a_host` prefix="":
|
|||||||
@remote-set remote=`just remote-current >&2 && just _a_remote_label`:
|
@remote-set remote=`just remote-current >&2 && just _a_remote_label`:
|
||||||
remote-set "{{remote}}"
|
remote-set "{{remote}}"
|
||||||
|
|
||||||
@motd:
|
motd:
|
||||||
|
#!/usr/bin/env -S bash -euo pipefail
|
||||||
printf "%s\n" "Current remote: $(just remote-current)"
|
printf "%s\n" "Current remote: $(just remote-current)"
|
||||||
just remote-list
|
just remote-list
|
||||||
printf "\n"; \
|
printf "\n"
|
||||||
todos=$(rg 'TODO' | wc -l); \
|
todos=$(rg 'TODO' | wc -l)
|
||||||
if [[ "$todos" -gt 10 ]]; then \
|
if [[ "$todos" -gt 10 ]]; then
|
||||||
printf "%s\n" "There are $todos 'TODO's"; \
|
printf "%s\n" "There are $todos 'TODO's"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@_a_remote_label:
|
@_a_remote_label:
|
||||||
@@ -137,10 +147,14 @@ inspect-config host=`just _a_host` prefix="":
|
|||||||
@_some_remote_fqdns:
|
@_some_remote_fqdns:
|
||||||
just remote-list | gum filter --placeholder "Pick remote..." --no-limit | cut -d' ' -f5-
|
just remote-list | gum filter --placeholder "Pick remote..." --no-limit | cut -d' ' -f5-
|
||||||
|
|
||||||
@_remote_ensure hostname=`just _a_fqdn`:
|
_remote_ensure $hostname=`just _a_fqdn`:
|
||||||
if test ! -s .remote.toml; then remote-init "{{ hostname }}"; \
|
#!/usr/bin/env -S bash -euo pipefail
|
||||||
elif tomlq <.remote.toml '.hosts | to_entries[] |.value.host' -r | grep -q "{{ hostname }}"; then true; \
|
if test ! -s .remote.toml; then
|
||||||
else remote-add "{{ hostname }}"; \
|
remote-init "$hostname"
|
||||||
|
elif tomlq <.remote.toml '.hosts | to_entries[] |.value.host' -r | grep -q "$hostname"; then
|
||||||
|
true
|
||||||
|
else
|
||||||
|
remote-add "$hostname"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@_remote_label_from_fqdn hostname=`just _a_fqdn`:
|
@_remote_label_from_fqdn hostname=`just _a_fqdn`:
|
||||||
|
|||||||
Reference in New Issue
Block a user