Skip to content

Commit 7087daf

Browse files
authored
Merge branch 'main' into patch-1
2 parents 7c767db + a9ae344 commit 7087daf

File tree

4 files changed

+37
-13
lines changed

4 files changed

+37
-13
lines changed

docs/cli.md

Lines changed: 2 additions & 0 deletions
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

docs/quickstart.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,14 @@ line that reads:
6464
```
6565

6666
Replace the text `CHANGE` with your own SSH key. This is crucial, as you will
67-
not be able to log into the target machine post-installation without it.
67+
not be able to log into the target machine post-installation without it. If you
68+
have a .pem file you can run
69+
70+
```bash
71+
ssh-keygen -y -f /path/to/your/key.pem
72+
```
73+
74+
then paste the result in between the quotes like "ssh-rsa AAA..."
6875

6976
### 4. Configure Storage
7077

flake.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/nixos-anywhere.sh

Lines changed: 24 additions & 9 deletions
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
@@ -691,7 +702,7 @@ if [ ${copyHostKeys-n} = "y" ]; then
691702
cp -a "\$p" "/mnt/\$p"
692703
done
693704
fi
694-
nixos-install --no-root-passwd --no-channel-copy --system "$nixosSystem"
705+
NIXOS_NO_CHECK=1 nixos-install --no-root-passwd --no-channel-copy --system "$nixosSystem"
695706
if [[ ${phases[reboot]} == 1 ]]; then
696707
if command -v zpool >/dev/null && [ "\$(zpool list)" != "no pools available" ]; then
697708
# we always want to export the zfs pools so people can boot from it without force import
@@ -726,7 +737,9 @@ main() {
726737
if [[ ${phases[disko]} == 1 ]]; then
727738
diskoScript=$(nixBuild "${flake}#${flakeAttr}.system.build.${diskoMode}Script")
728739
fi
729-
nixosSystem=$(nixBuild "${flake}#${flakeAttr}.system.build.toplevel")
740+
if [[ ${phases[install]} == 1 ]]; then
741+
nixosSystem=$(nixBuild "${flake}#${flakeAttr}.system.build.toplevel")
742+
fi
730743
fi
731744
elif [[ -n ${diskoScript} ]] && [[ -n ${nixosSystem} ]]; then
732745
if [[ ! -e ${diskoScript} ]] || [[ ! -e ${nixosSystem} ]]; then
@@ -799,7 +812,9 @@ main() {
799812
if [[ ${phases[disko]} == 1 ]]; then
800813
diskoScript=$(nixBuild "${flake}#${flakeAttr}.system.build.${diskoMode}Script")
801814
fi
802-
nixosSystem=$(nixBuild "${flake}#${flakeAttr}.system.build.toplevel")
815+
if [[ ${phases[install]} == 1 ]]; then
816+
nixosSystem=$(nixBuild "${flake}#${flakeAttr}.system.build.toplevel")
817+
fi
803818
fi
804819
805820
# Installation will fail if non-root user is used for installer.

0 commit comments

Comments
 (0)