Make some apply defaults optional
This commit is contained in:
		| @@ -23,6 +23,12 @@ Normally the flake of the current working directory is used. But you can specify | ||||
| bij --flake /etc/nixos apply astatine | ||||
| ``` | ||||
|  | ||||
| Change some defaults if they don't fit. | ||||
|  | ||||
| ``` | ||||
| bij apply astatine --no-use-remote-sudo --no-use-substitutes | ||||
| ``` | ||||
|  | ||||
| Sometimes it is required to execute some commands on a host directly. | ||||
|  | ||||
| ``` | ||||
|   | ||||
							
								
								
									
										30
									
								
								bij.sh
									
									
									
									
									
								
							
							
						
						
									
										30
									
								
								bij.sh
									
									
									
									
									
								
							| @@ -4,6 +4,8 @@ set -euo pipefail | ||||
|  | ||||
| FLAKE= | ||||
| TARGET= | ||||
| USE_SUBSTITUTES="1" | ||||
| USE_REMOTE_SUDO="1" | ||||
|  | ||||
| ARGS=() | ||||
| OPTS=() | ||||
| @@ -20,6 +22,22 @@ while [[ $# -gt 0 ]]; do | ||||
| 		shift | ||||
| 		shift | ||||
| 		;; | ||||
| 	--use-substitutes) | ||||
| 		USE_SUBSTITUTES="1" | ||||
| 		shift | ||||
| 		;; | ||||
| 	--no-use-substitutes) | ||||
| 		USE_SUBSTITUTES="" | ||||
| 		shift | ||||
| 		;; | ||||
| 	--use-remote-sudo) | ||||
| 		USE_REMOTE_SUDO="1" | ||||
| 		shift | ||||
| 		;; | ||||
| 	--no-use-remote-sudo) | ||||
| 		USE_REMOTE_SUDO="" | ||||
| 		shift | ||||
| 		;; | ||||
| 	--) | ||||
| 		shift | ||||
| 		OPTS=( "$@" ) | ||||
| @@ -67,9 +85,19 @@ if [[ -z ${TARGET} ]]; then | ||||
| 	TARGET="$(nix --extra-experimental-features "nix-command flakes" eval --raw "${FLAKE_STORE_PATH}#nixosConfigurations.${HOST}" --apply "host: host.config.networking.fqdn")" | ||||
| fi | ||||
|  | ||||
| APPLY_OPTS=() | ||||
|  | ||||
| if [[ -n "${USE_SUBSTITUTES}" ]]; then | ||||
| 	APPLY_OPTS+=("--use-substitutes") | ||||
| fi | ||||
|  | ||||
| if [[ -n "${USE_REMOTE_SUDO}" ]]; then | ||||
| 	APPLY_OPTS+=("--use-remote-sudo") | ||||
| fi | ||||
|  | ||||
| case "${COMMAND}" in | ||||
| apply) | ||||
| 	nixos-rebuild switch --flake "${FLAKE_STORE_PATH}#${HOST}" --target-host "${TARGET}" --use-substitutes --use-remote-sudo | ||||
| 	nixos-rebuild switch --flake "${FLAKE_STORE_PATH}#${HOST}" --target-host "${TARGET}" "${APPLY_OPTS[@]}" | ||||
| 	;; | ||||
| build) | ||||
| 	nixos-rebuild build --flake "${FLAKE_STORE_PATH}#${HOST}" | ||||
|   | ||||
		Reference in New Issue
	
	Block a user