Install NixOS on Hetzner Online: Difference between revisions

imported>Zimbatm
added Bootstrap from the Rescue System section
imported>Zimbatm
m fix formatting
Line 84: Line 84:
First, reboot the machine in Rescue mode. Make sure to select your SSH public key. SSH into the machine:
First, reboot the machine in Rescue mode. Make sure to select your SSH public key. SSH into the machine:


<nowiki>
<pre>
# Create a user, because the nix installer
# Create a user, because the nix installer
useradd foo
useradd foo
Line 114: Line 114:
# Switch to the new system
# Switch to the new system
./result
./result
</nowiki>
</pre>


At this point the shell should stop responding. Kill the shell and ssh back into the machine. The server public key will have changed.
At this point the shell should stop responding. Kill the shell and ssh back into the machine. The server public key will have changed.


<nowiki>
<pre>
format() {
format() {
   parted -s "$1" -- mklabel msdos
   parted -s "$1" -- mklabel msdos
Line 143: Line 143:
# Generate the NixOS configuration.
# Generate the NixOS configuration.
nixos-generate-config --root /mnt
nixos-generate-config --root /mnt
</nowiki>
</pre>


At this point, edit the /mnt/etc/nixos/configuration.nix and tune as needed. I just added the following lines:
At this point, edit the /mnt/etc/nixos/configuration.nix and tune as needed. I just added the following lines:
<nowiki>
<pre>
boot.loader.grub.device = "/dev/nvme0n1";
boot.loader.grub.device = "/dev/nvme0n1";
services.openssh.enable = true;
services.openssh.enable = true;
Line 152: Line 152:
   "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDGB1Pog97SWdV2UEA40V+3bML+lSZXEd48zCRlS/eGbY3rsXfgUXb5FIBulN9cET9g0OOAKeCZBR1Y2xXofiHDYkhk298rHDuir6cINuoMGUO7VsygUfKguBy63QMPHYnJBE1h+6sQGu/3X9G2o/0Ys2J+lZv4+N7Hqolhbg/Cu6/LUCsJM/udqTVwJGEqszDWPtuuTAIS6utB1QdL9EZT5WBb1nsNyHnIlCnoDKZvrrO9kM0FGKhjJG2skd3+NqmLhYIDhRhZvRnL9c8U8uozjbtj/N8L/2VCRzgzKmvu0Y1cZMWeAAdyqG6LoyE7xGO+SF4Vz1x6JjS9VxnZipIB zimbatm@nixos"
   "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDGB1Pog97SWdV2UEA40V+3bML+lSZXEd48zCRlS/eGbY3rsXfgUXb5FIBulN9cET9g0OOAKeCZBR1Y2xXofiHDYkhk298rHDuir6cINuoMGUO7VsygUfKguBy63QMPHYnJBE1h+6sQGu/3X9G2o/0Ys2J+lZv4+N7Hqolhbg/Cu6/LUCsJM/udqTVwJGEqszDWPtuuTAIS6utB1QdL9EZT5WBb1nsNyHnIlCnoDKZvrrO9kM0FGKhjJG2skd3+NqmLhYIDhRhZvRnL9c8U8uozjbtj/N8L/2VCRzgzKmvu0Y1cZMWeAAdyqG6LoyE7xGO+SF4Vz1x6JjS9VxnZipIB zimbatm@nixos"
];
];
</nowiki>
</pre>


Finally run `nixos-install`, and then reboot the machine.
Finally run `nixos-install`, and then reboot the machine.


Voila! (after 1000 steps)
Voila! (after 1000 steps)