Add option to apply configuration during next boot

This commit is contained in:
clerie 2024-08-24 17:23:59 +02:00
parent a1430c542e
commit 202f4a1a57
2 changed files with 18 additions and 1 deletions

View File

@ -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.
```

13
bij.sh
View File

@ -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}"