Hi all,
In the manual, it says:
You need to copy your ssh key to either /home/nixos/.ssh/authorized_keys
or /root/.ssh/authorized_keys
(Tip: For installers with a modifiable filesystem such as the sd-card installer image a key can be manually placed by mounting the image on a different machine).
I have just written the sdcard image to disk. Now I’m seeing two partitions: NIXOS_SD
and FIRMWARE
. The latter has a bunch of files and sounds like it would be the wrong one, but the other only has /nix/
and /boot/
, no /home/
folder. Do I just create one there and will it work?
And maybe for some context on what I’m trying to do: I’m hoping to get my feet wet using NixOS by installing it on my Raspberry Pi. However, I don’t have a keyboard I can connect to my Pi, so I was hoping to be able to SSH into it on first boot. Thus, I’d like to prepare the disk beforehand with NixOS and my SSH key, from my non-ARM non-NixOS laptop. Oh, and maybe relevant: the disk is an SSD drive connected through USB.
(Also, I have zero NixOS experience, and am getting a bit lost in the many different docs. I have been using Linux for years though, if that helps, the last few on Fedora Silverblue.)
Thanks in advance!
Short answer: probably you can just make /home and try it. But IDK if ssh server is enabled by default.
Long answer: I am not familiar with the sdcard image, so maybe this is wrong. But having only /nix and /boot is a common pattern on NixOS so I can guess what they are doing.
Every boot, NixOS is able to restore itself entirely by symlinking files out of the /nix directory. This is commonly used to achieve “impermanence.” You can look it up there is a lot of documentation on it. Having /nix and /boot are the minimum requirements for impermanence. So I am guessing the sd image is doing impermanence (but IDK for sure).
Anyway the big thing with impermanence is that the root filesystem is either setup on RAM so that it gets deleted on poweroff. Or is is setup on a partition or zfs dataset/btrfs subvolume that is deleted by a script on boot. Since /nix and /boot are on the same partition, and they can’t get deleted or else the system is bricked, make sure you put /home on the same partition as /nix and /boot.
Also there is a bigger problem of whether ssh server is enabled by default. It probably is but IDK (maybe there is some documentation that says if it is or not). Normally in this situation I would mount the sdcard image on my laptop and chroot in, enable the ssh server, and run nixos-rebuild (you use nixos-enter command to chroot into nixos). But since your laptop is x86 and the sdcard is ARM I don’t think that would work. So if ssh server is not setup by default then IDK how to help you.
Thank you! This referenced this PR to claim that SSH was enabled by default on the sdcard image, and… Indeed it now seems to work! So thanks for your help, and I’ve learned a bit already as well - indeed it seems that most other files have now been created on first boot. So now let’s get my feet wet 