From 202f4a1a5791c74a9b7d69a4e63e631bdbe36ba6 Mon Sep 17 00:00:00 2001 From: clerie Date: Sat, 24 Aug 2024 17:23:59 +0200 Subject: [PATCH] Add option to apply configuration during next boot --- README.md | 6 ++++++ bij.sh | 13 ++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b6be1da..dca1b84 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,12 @@ Change some defaults if they don't fit. bij apply astatine --no-use-remote-sudo --no-use-substitutes ``` +Apply change during next boot: + +``` +bij apply astatine --on-next-boot +``` + Sometimes it is required to execute some commands on a host directly. ``` diff --git a/bij.sh b/bij.sh index 1b0349c..a476ea0 100755 --- a/bij.sh +++ b/bij.sh @@ -4,6 +4,7 @@ set -euo pipefail FLAKE= TARGET= +ON_NEXT_BOOT= USE_SUBSTITUTES="1" USE_REMOTE_SUDO="1" @@ -22,6 +23,10 @@ while [[ $# -gt 0 ]]; do shift shift ;; + --on-next-boot) + ON_NEXT_BOOT="1" + shift + ;; --use-substitutes) USE_SUBSTITUTES="1" shift @@ -95,9 +100,15 @@ if [[ -n "${USE_REMOTE_SUDO}" ]]; then APPLY_OPTS+=("--use-remote-sudo") fi +APPLY_OPERATION="switch" + +if [[ -n "${ON_NEXT_BOOT}" ]]; then + APPLY_OPERATION="boot" +fi + case "${COMMAND}" in apply) - nixos-rebuild switch --flake "${FLAKE_STORE_PATH}#${HOST}" --target-host "${TARGET}" "${APPLY_OPTS[@]}" + nixos-rebuild "${APPLY_OPERATION}" --flake "${FLAKE_STORE_PATH}#${HOST}" --target-host "${TARGET}" "${APPLY_OPTS[@]}" ;; build) nixos-rebuild build --flake "${FLAKE_STORE_PATH}#${HOST}"