add mprocs remote runner
This commit is contained in:
parent
64dbfdc3cf
commit
d125eec709
1
.gitignore
vendored
1
.gitignore
vendored
@ -5,3 +5,4 @@ result
|
||||
.remote.toml
|
||||
_*
|
||||
/logs
|
||||
mprocs.log
|
||||
|
@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
export HOST_SHELL="$(command -v "$SHELL")"
|
||||
export IS_REMOTE_ENV=1
|
||||
eval "$(nix print-dev-env .#remoteenv)"
|
||||
echo Entered "$(hostname --fqdn)"
|
||||
df -h /nix/store
|
||||
|
@ -321,9 +321,9 @@
|
||||
# TODO: get faketty to work ${expect}/bin/unbuffer is bad
|
||||
nixos-rebuild-nom = pkgs.writeScriptBin "nixos-rebuild" ''
|
||||
if test -t 1 && test -z "''${NIX_NO_NOM-}"; then
|
||||
exec ${lib.getExe pkgs.nixos-rebuild} "$@" -L |& ${lib.getExe pkgs.nix-output-monitor}
|
||||
exec ${lib.getExe pkgs.nixos-rebuild} -L "$@" |& ${lib.getExe pkgs.nix-output-monitor}
|
||||
else
|
||||
exec ${lib.getExe pkgs.nixos-rebuild} "$@" -L
|
||||
exec ${lib.getExe pkgs.nixos-rebuild} -L "$@"
|
||||
fi
|
||||
'';
|
||||
|
||||
@ -383,6 +383,7 @@
|
||||
pkgs.ssh-to-age
|
||||
pkgs.just
|
||||
pkgs.gum
|
||||
pkgs.mprocs
|
||||
];
|
||||
in {
|
||||
envrc-local = mkShell envrc-pkgs;
|
||||
|
38
justfile
38
justfile
@ -28,9 +28,12 @@ update:
|
||||
| gum choose --no-limit --height=15 \
|
||||
| xargs nix flake update --commit-lock-file
|
||||
|
||||
build hostname=`just _a_host`:
|
||||
build hostname=`if test -z "$IS_REMOTE_ENV"; then just _a_host; else echo; fi`:
|
||||
nixos-rebuild build --accept-flake-config --show-trace --flake .#"{{hostname}}"
|
||||
|
||||
build-no-remote-builders hostname=`if test -z "$IS_REMOTE_ENV"; then just _a_host; else echo; fi`:
|
||||
nixos-rebuild build --accept-flake-config --show-trace --flake .#"{{hostname}}" --builders ""
|
||||
|
||||
build-vm hostname=`just _a_host`:
|
||||
nixos-rebuild build-vm --accept-flake-config --show-trace --flake .#"{{hostname}}"
|
||||
|
||||
@ -64,26 +67,42 @@ inspect-config host=`just _a_host`:
|
||||
if test "$(grep <<<"$hostnames" "^$(hostname)$" | wc -l)" -eq 1; then hostnames="$(hostname; grep <<<"$hostnames" -v "^$(hostname)$")"; fi; \
|
||||
gum <<<"$hostnames" filter --placeholder "Pick a host..."
|
||||
|
||||
@_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
|
||||
|
||||
@_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..."
|
||||
|
||||
@_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
|
||||
|
||||
@remote-current:
|
||||
>&2 echo Current remote: $(remote-host)
|
||||
|
||||
@remote-list:
|
||||
tomlq <.remote.toml '.hosts | to_entries[] | "remote-set \(.key+1) # -> \(.value.host)"' -r
|
||||
|
||||
@remote-set remote=`just remote-current && just _a-remote-label`:
|
||||
@remote-set remote=`just remote-current && just _a_remote_label`:
|
||||
remote-set {{remote}}
|
||||
|
||||
@_a-remote-label:
|
||||
@_a_remote_label:
|
||||
just remote-list | gum filter --placeholder "Pick a remote..." | cut -d' ' -f2
|
||||
|
||||
@_a-remote-fqdn:
|
||||
@_some_remote_labels:
|
||||
just remote-list | gum filter --placeholder "Pick remotes..." --no-limit | cut -d' ' -f2
|
||||
|
||||
@_a_remote_fqdn:
|
||||
just remote-list | gum filter --placeholder "Pick a remote..." | cut -d' ' -f5-
|
||||
|
||||
@_some_remote_fqdns:
|
||||
just remote-list | gum filter --placeholder "Pick remote..." --no-limit | cut -d' ' -f5-
|
||||
|
||||
@_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; \
|
||||
@ -91,12 +110,17 @@ inspect-config host=`just _a_host`:
|
||||
fi
|
||||
|
||||
@_remote_label_from_fqdn hostname=`just _a_fqdn`:
|
||||
tomlq <.remote.toml '.hosts | to_entries[] | select(.value.host == "{{ hostname }}") | .key' -r
|
||||
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
|
||||
|
||||
@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
|
||||
|
||||
# TODO: support multiple labels, run in tmux
|
||||
remote label=`just _a-remote-label` cmd=`printf "just %s\n" $(just --summary --unsorted) | gum filter --placeholder "Pick a recipie..."`:
|
||||
remote --label={{label}} {{cmd}}
|
||||
#remote label=`just _a_remote_label` cmd=`printf "just %s\n" $(just --summary --unsorted) | gum filter --placeholder "Pick a recipie..."`:
|
||||
# remote --label={{label}} {{cmd}}
|
||||
|
||||
# TODO: packaged as nix-web
|
||||
@gorgon:
|
||||
|
Loading…
Reference in New Issue
Block a user