summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2025-01-21 05:15:06 -0500
committerBen Sima <ben@bsima.me>2025-01-21 05:15:06 -0500
commitef1f2a3caf9f2224bf5dddd04bd0c70e299db5e2 (patch)
tree877cd245b14f11df62584d1eb46eba75a2350c10
parente19708a249140d22c8d7a2245c7c11d7b15ef048 (diff)
Switch inside a systemd-run on push
This guards against network failures that may put the system in an unusable state. It's included in nixos-rebuild, so I should include it here in some form too. https://github.com/NixOS/nixpkgs/pull/258571
-rwxr-xr-xOmni/Ide/push.sh16
1 files changed, 15 insertions, 1 deletions
diff --git a/Omni/Ide/push.sh b/Omni/Ide/push.sh
index e16b26a..5c22e07 100755
--- a/Omni/Ide/push.sh
+++ b/Omni/Ide/push.sh
@@ -16,5 +16,19 @@ where=$(rg --only-matching --replace '$2' --regexp '(domainname ")(.*)(")' \
"$what/etc/systemd/system/domainname.service")
nix copy --to ssh://"$USER"@"$where" "$what"
ssh "$USER"@"$where" sudo nix-env --profile /nix/var/nix/profiles/system --set "$what"
-ssh "$USER"@"$where" sudo "$what"/bin/switch-to-configuration switch
+switch_cmd=(
+ systemd-run
+ -E LOCALE_ARCHIVE
+ --collect
+ --no-ask-password
+ --pipe
+ --quiet
+ --service-type=exec
+ --unit=push-switch-to-configuration
+ --wait
+ "$what/bin/switch-to-configuration"
+ "switch"
+)
+# shellcheck disable=SC2029
+ssh "$USER"@"$where" sudo "${switch_cmd[@]}"
echo "${GRN}good: push: $target${NC}"