Skip to content

Commit 809413a

Browse files
committed
allow to pass nix options
1 parent 524a0c9 commit 809413a

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/nixos-remote.sh

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ Options:
2828
disable passing --substitute-on-destination to nix-copy
2929
* --debug
3030
enable debug output
31+
* --option KEY VALUE
32+
nix option to pass to every nix related command
3133
USAGE
3234
}
3335

@@ -41,6 +43,10 @@ kexec_url="$default_kexec_url"
4143
enable_debug=""
4244
maybereboot="sleep 6 && reboot"
4345
substitute_on_destination="--substitute-on-destination"
46+
nix_options=(
47+
--extra-experimental-features 'nix-command flakes'
48+
"--no-write-lock-file"
49+
)
4450

4551
declare -A disk_encryption_keys
4652

@@ -90,6 +96,13 @@ while [[ $# -gt 0 ]]; do
9096
--no-reboot)
9197
maybereboot=""
9298
;;
99+
--option)
100+
key=$2
101+
shift
102+
value=$2
103+
shift
104+
nix_options+=("--option" "$key" "$value")
105+
;;
93106
--no-substitute-on-destination)
94107
substitute_on_destination=""
95108
;;
@@ -114,25 +127,20 @@ ssh_() {
114127
ssh -T -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no "$ssh_connection" "$@"
115128
}
116129

117-
nix_options=(
118-
--extra-experimental-features 'nix-command flakes'
119-
"--no-write-lock-file"
120-
)
121-
122130
if [[ ${print_build_logs-n} == "y" ]]; then
123131
nix_options+=("-L")
124132
fi
125133

126134
nix_copy() {
127135
NIX_SSHOPTS='-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' nix copy \
128-
"${nix_options[@]}" "${substitute_on_destination}" \
136+
"${substitute_on_destination}" "${nix_options[@]}" \
129137
"$@"
130138
}
131139
nix_build() {
132140
nix build \
133-
"${nix_options[@]}" \
134141
--print-out-paths \
135142
--no-link \
143+
"${nix_options[@]}" \
136144
"$@"
137145
}
138146

0 commit comments

Comments
 (0)