Skip to content

Commit 40f5d37

Browse files
authored
Merge pull request #358 from aabccd021/main
Add option --ssh-store-settings
2 parents 711c816 + 6cd5f73 commit 40f5d37

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

docs/cli.md

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ Options:
2929
use another kexec tarball to bootstrap NixOS
3030
* --kexec-extra-flags
3131
extra flags to add into the call to kexec, e.g. "--no-sync"
32+
* --ssh-store-setting <key> <value>
33+
ssh store settings appended to the store URI, e.g. "compress true". <value> needs to be URI encoded.
3234
* --post-kexec-ssh-port <ssh_port>
3335
after kexec is executed, use a custom ssh port to connect. Defaults to 22
3436
* --copy-host-keys

src/nixos-anywhere.sh

+17-6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ flake=""
66
flakeAttr=""
77
kexecUrl=""
88
kexecExtraFlags=""
9+
sshStoreSettings=""
910
enableDebug=""
1011
nixBuildFlags=()
1112
diskoScript=""
@@ -94,6 +95,8 @@ Options:
9495
use another kexec tarball to bootstrap NixOS
9596
* --kexec-extra-flags
9697
extra flags to add into the call to kexec, e.g. "--no-sync"
98+
* --ssh-store-setting <key> <value>
99+
ssh store settings appended to the store URI, e.g. "compress true". <value> needs to be URI encoded.
97100
* --post-kexec-ssh-port <ssh_port>
98101
after kexec is executed, use a custom ssh port to connect. Defaults to 22
99102
* --copy-host-keys
@@ -213,6 +216,14 @@ parseArgs() {
213216
kexecExtraFlags=$2
214217
shift
215218
;;
219+
--ssh-store-setting)
220+
key=$2
221+
shift
222+
value=$2
223+
shift
224+
sshStoreSettings+="$sshStoreSettings$key=$value&"
225+
shift
226+
;;
216227
--post-kexec-ssh-port)
217228
postKexecSshPort=$2
218229
shift
@@ -628,17 +639,17 @@ runDisko() {
628639
runSsh "umask 077; mkdir -p \"$(dirname "$path")\"; cat > $path" <"${diskEncryptionKeys[$path]}"
629640
done
630641
if [[ -n ${diskoScript} ]]; then
631-
nixCopy --to "ssh://$sshConnection" "$diskoScript"
642+
nixCopy --to "ssh://$sshConnection?$sshStoreSettings" "$diskoScript"
632643
elif [[ ${buildOn} == "remote" ]]; then
633644
step Building disko script
634645
# We need to do a nix copy first because nix build doesn't have --no-check-sigs
635646
# Use ssh:// here to avoid https://github.com/NixOS/nix/issues/7359
636-
nixCopy --to "ssh://$sshConnection" "${flake}#${flakeAttr}.system.build.${diskoMode}Script" \
647+
nixCopy --to "ssh://$sshConnection?$sshStoreSettings" "${flake}#${flakeAttr}.system.build.${diskoMode}Script" \
637648
--derivation --no-check-sigs
638649
# If we don't use ssh-ng here, we get `error: operation 'getFSAccessor' is not supported by store`
639650
diskoScript=$(
640651
nixBuild "${flake}#${flakeAttr}.system.build.${diskoMode}Script" \
641-
--eval-store auto --store "ssh-ng://$sshConnection?ssh-key=$sshKeyDir/nixos-anywhere"
652+
--eval-store auto --store "ssh-ng://$sshConnection?ssh-key=$sshKeyDir%2Fnixos-anywhere&$sshStoreSettings"
642653
)
643654
fi
644655
@@ -650,17 +661,17 @@ nixosInstall() {
650661
local nixosSystem=$1
651662
if [[ -n ${nixosSystem} ]]; then
652663
step Uploading the system closure
653-
nixCopy --to "ssh://$sshConnection?remote-store=local?root=/mnt" "$nixosSystem"
664+
nixCopy --to "ssh://$sshConnection?remote-store=local%3Froot=%2Fmnt&$sshStoreSettings" "$nixosSystem"
654665
elif [[ ${buildOn} == "remote" ]]; then
655666
step Building the system closure
656667
# We need to do a nix copy first because nix build doesn't have --no-check-sigs
657668
# Use ssh:// here to avoid https://github.com/NixOS/nix/issues/7359
658-
nixCopy --to "ssh://$sshConnection?remote-store=local?root=/mnt" "${flake}#${flakeAttr}.system.build.toplevel" \
669+
nixCopy --to "ssh://$sshConnection?remote-store=local%3Froot=%2Fmnt&$sshStoreSettings" "${flake}#${flakeAttr}.system.build.toplevel" \
659670
--derivation --no-check-sigs
660671
# If we don't use ssh-ng here, we get `error: operation 'getFSAccessor' is not supported by store`
661672
nixosSystem=$(
662673
nixBuild "${flake}#${flakeAttr}.system.build.toplevel" \
663-
--eval-store auto --store "ssh-ng://$sshConnection?ssh-key=$sshKeyDir/nixos-anywhere&remote-store=local?root=/mnt"
674+
--eval-store auto --store "ssh-ng://$sshConnection?ssh-key=$sshKeyDir%2Fnixos-anywhere&remote-store=local%3Froot=%2Fmnt&$sshStoreSettings"
664675
)
665676
fi
666677

0 commit comments

Comments
 (0)