General: add remote build workaround to nixos-operations-script
This commit is contained in:
parent
15106e1a18
commit
aa1c55492b
|
@ -8,6 +8,7 @@ hostname=$(/run/current-system/sw/bin/hostname) # The name of the host to build
|
||||||
flakeDir="${FLAKE_DIR}" # Path to the flake file (and optionally the hostname)
|
flakeDir="${FLAKE_DIR}" # Path to the flake file (and optionally the hostname)
|
||||||
update=false # Whether to update and commmit flake.lock
|
update=false # Whether to update and commmit flake.lock
|
||||||
user=$(/run/current-system/sw/bin/whoami) # Which user account to use for git commands
|
user=$(/run/current-system/sw/bin/whoami) # Which user account to use for git commands
|
||||||
|
buildHost="" # Which host to use to generate the build (defaults to the local host)
|
||||||
remainingArgs="" # All remaining arguments that haven't yet been processed (will be passed to nixos-rebuild)
|
remainingArgs="" # All remaining arguments that haven't yet been processed (will be passed to nixos-rebuild)
|
||||||
|
|
||||||
function usage() {
|
function usage() {
|
||||||
|
@ -34,16 +35,21 @@ function usage() {
|
||||||
POSITIONAL_ARGS=()
|
POSITIONAL_ARGS=()
|
||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
|
--build-host)
|
||||||
|
buildHost="$2"
|
||||||
|
shift
|
||||||
|
shift
|
||||||
|
;;
|
||||||
--flake|-f)
|
--flake|-f)
|
||||||
flakeDir="$2"
|
flakeDir="$2"
|
||||||
shift
|
shift
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
--hostname|-h)
|
--hostname|-h)
|
||||||
hostname="$2"
|
hostname="$2"
|
||||||
shift
|
shift
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
--update|--upgrade|-U)
|
--update|--upgrade|-U)
|
||||||
update=true
|
update=true
|
||||||
shift
|
shift
|
||||||
|
@ -89,6 +95,12 @@ fi
|
||||||
|
|
||||||
options="--flake ${flakeDir}#${hostname} ${remainingArgs} --use-remote-sudo --log-format multiline-with-logs"
|
options="--flake ${flakeDir}#${hostname} ${remainingArgs} --use-remote-sudo --log-format multiline-with-logs"
|
||||||
|
|
||||||
|
if [[ -n "${buildHost}" && $operation != "build" && $operation != *"dry"* ]]; then
|
||||||
|
echo "Remote build detected, running this operation first: nixos-rebuild build ${options} --build-host $buildHost"
|
||||||
|
/run/current-system/sw/bin/nixos-rebuild build $options --build-host $buildHost
|
||||||
|
echo "Remote build complete!"
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Running this operation: nixos-rebuild ${operation} ${options}"
|
echo "Running this operation: nixos-rebuild ${operation} ${options}"
|
||||||
/run/current-system/sw/bin/nixos-rebuild $operation $options
|
/run/current-system/sw/bin/nixos-rebuild $operation $options
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue