Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow to pass nix options #44

Merged
merged 1 commit into from
Jan 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 15 additions & 7 deletions src/nixos-remote.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ Options:
disable passing --substitute-on-destination to nix-copy
* --debug
enable debug output
* --option KEY VALUE
nix option to pass to every nix related command
USAGE
}

Expand All @@ -41,6 +43,10 @@ kexec_url="$default_kexec_url"
enable_debug=""
maybereboot="sleep 6 && reboot"
substitute_on_destination="--substitute-on-destination"
nix_options=(
--extra-experimental-features 'nix-command flakes'
"--no-write-lock-file"
)

declare -A disk_encryption_keys

Expand Down Expand Up @@ -90,6 +96,13 @@ while [[ $# -gt 0 ]]; do
--no-reboot)
maybereboot=""
;;
--option)
key=$2
shift
value=$2
shift
nix_options+=("--option" "$key" "$value")
;;
--no-substitute-on-destination)
substitute_on_destination=""
;;
Expand All @@ -114,25 +127,20 @@ ssh_() {
ssh -T -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no "$ssh_connection" "$@"
}

nix_options=(
--extra-experimental-features 'nix-command flakes'
"--no-write-lock-file"
)

if [[ ${print_build_logs-n} == "y" ]]; then
nix_options+=("-L")
fi

nix_copy() {
NIX_SSHOPTS='-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' nix copy \
"${nix_options[@]}" "${substitute_on_destination}" \
"${substitute_on_destination}" "${nix_options[@]}" \
"$@"
}
nix_build() {
nix build \
"${nix_options[@]}" \
--print-out-paths \
--no-link \
"${nix_options[@]}" \
"$@"
}

Expand Down