Install NixOS on Hetzner Cloud: Difference between revisions
Clean out uneccesray Beiwerk |
m →Hetnzer base configuration: Fix typo |
||
| (6 intermediate revisions by 3 users not shown) | |||
| Line 51: | Line 51: | ||
Once installed, unmount the ISO and reboot. | Once installed, unmount the ISO and reboot. | ||
===== | ===== Hetzner base configuration ===== | ||
In the example below, the id would be `hetzner-x86_64`. | In the example below, the id would be `hetzner-x86_64`. | ||
| Line 158: | Line 158: | ||
]; | ]; | ||
networking.useDHCP = lib.mkDefault true; | networking.useDHCP = lib.mkDefault true; | ||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; | nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; | ||
| Line 269: | Line 264: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
#To build NixOS from the flake run:<syntaxhighlight lang="shell"> | #To build NixOS from the flake run:<syntaxhighlight lang="shell"> | ||
nix run --extra-experimental-features 'nix-command flakes' github:nix-community/nixos-anywhere --flake /tmp/my- | nix run --extra-experimental-features 'nix-command flakes' github:nix-community/nixos-anywhere -- --flake /tmp/my-hetzner-vm#my-hetzner-vm --target-host root@0.0.0.0 --build-on-remote | ||
</syntaxhighlight>'''Note''': replace <code>0.0.0.0</code> with an IP address obtained during an earlier step. | </syntaxhighlight>'''Note''': replace <code>0.0.0.0</code> with an IP address obtained during an earlier step. | ||
The NixOS on Hetzner is installed! | The NixOS on Hetzner is installed! | ||
| Line 279: | Line 274: | ||
references: | references: | ||
* [[Disko]] | |||
* [https://github.com/feelssexy/hetzner-auto-nixos/blob/main/hardware-configuration.nix sample regular hardware config] | * [https://github.com/feelssexy/hetzner-auto-nixos/blob/main/hardware-configuration.nix sample regular hardware config] | ||
* [https://github.com/LGUG2Z/nixos-hetzner-cloud-starter/blob/master/disk-config.nix sample config using disko] | * [https://github.com/LGUG2Z/nixos-hetzner-cloud-starter/blob/master/disk-config.nix sample config using disko] | ||
| Line 297: | Line 293: | ||
* Run following script. Replace <code>NIX_CHANNEL</code> variable with the version string you wish to install. | * Run following script. Replace <code>NIX_CHANNEL</code> variable with the version string you wish to install. | ||
<syntaxHighlight lang=bash> | <syntaxHighlight lang=bash> | ||
curl https://raw.githubusercontent.com/elitak/nixos-infect/master/nixos-infect | NIX_CHANNEL=nixos- | curl https://raw.githubusercontent.com/elitak/nixos-infect/master/nixos-infect | NIX_CHANNEL=nixos-24.11 bash -x | ||
</syntaxHighlight> | </syntaxHighlight> | ||
* Reboot into NixOS | * Reboot into NixOS | ||
| Line 312: | Line 308: | ||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
systemd.network.enable = true; | |||
systemd.network.networks."30-wan" = { | |||
matchConfig.Name = "ens3"; # either ens3 or enp1s0, check 'ip addr' | |||
networkConfig.DHCP = "ipv4"; | |||
address = [ | |||
# replace this subnet with the one assigned to your instance | |||
"2a01:4f8:aaaa:bbbb::1/64" | |||
]; | |||
routes = [ | |||
{ Gateway = "fe80::1"; } | |||
]; | |||
}; | |||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 331: | Line 326: | ||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
systemd.network.networks."30-wan" = { | |||
matchConfig.Name = "ens3"; # either ens3 (amd64) or enp1s0 (arm64) | |||
networkConfig.DHCP = "no"; | |||
address = [ | |||
# replace this address with the one assigned to your instance | |||
"A.B.C.D/32" | |||
# replace this subnet with the one assigned to your instance | |||
"2a01:4f8:AAAA:BBBB::1/64" | |||
]; | |||
routes = [ | |||
{ Gateway = "172.31.1.1"; GatewayOnLink = true; } | |||
{ Gateway = "fe80::1"; } | |||
]; | |||
}; | |||
</syntaxhighlight> | </syntaxhighlight> | ||