NixOS Installation Guide: Difference between revisions

Klinger (talk | contribs)
mNo edit summary
Rrdpad (talk | contribs)
Add blocks for console commands
Line 138: Line 138:
== Label partitions ==
== Label partitions ==


This is useful for having multiple setups and makes partitions easier to handle.
This is useful for having multiple setups and makes partitions easier to handle<syntaxhighlight lang="console">
* lsblk
$ lsblk
* sudo mkfs.fat -F 32 /dev/sdX1
$ sudo mkfs.fat -F 32 /dev/sdX1
* sudo fatlabel /dev/sdX1 NIXBOOT
$ sudo fatlabel /dev/sdX1 NIXBOOT
* sudo mkfs.ext4 /dev/sdX2 -L NIXROOT
$ sudo mkfs.ext4 /dev/sdX2 -L NIXROOT
* sudo mount /dev/disk/by-label/NIXROOT /mnt
$ sudo mount /dev/disk/by-label/NIXROOT /mnt
* sudo mkdir -p /mnt/boot
$ sudo mkdir -p /mnt/boot
* sudo mount /dev/disk/by-label/NIXBOOT /mnt/boot
$ sudo mount /dev/disk/by-label/NIXBOOT /mnt/boot
</syntaxhighlight>


== Swap file ==
== Swap file ==
* sudo dd if=/dev/zero of=/mnt/.swapfile bs=1024 count=2097152 (2GB size)
<syntaxhighlight lang="console">
* sudo chmod 600 /mnt/.swapfile
$ sudo dd if=/dev/zero of=/mnt/.swapfile bs=1024 count=2097152 (2GB size)
* sudo mkswap /mnt/.swapfile
$ sudo chmod 600 /mnt/.swapfile
* sudo swapon /mnt/.swapfile
$ sudo mkswap /mnt/.swapfile
$ sudo swapon /mnt/.swapfile
</syntaxhighlight>


== NixOS config ==
== NixOS config ==
* sudo nixos-generate-config --root /mnt
<syntaxhighlight lang="console">
* cd /mnt/etc/nixos/
$ sudo nixos-generate-config --root /mnt
* sudo vim configuration.nix
$ cd /mnt/etc/nixos/
Most essential changes:
$ sudo vim configuration.nix
</syntaxhighlight>Most essential changes:


* keyboard layout, ie <code>services.xserver.layout</code>
* keyboard layout, ie <code>[[Keyboard Layout Customization|services.xserver.xkb.layout]]</code>
* <code>users.users.user</code> with adding entry <code>initialPassword = "pw123";</code>
* <code>users.users.user</code> with adding entry <code>initialPassword = "pw123";</code>
* [[networking]] (wifi), see below for fix if it breaks
* [[networking]] (wifi), see below for fix if it breaks
Line 169: Line 173:


== NixOS installation ==
== NixOS installation ==
<syntaxhighlight lang="console">
$ cd /mnt
$ sudo nixos-install
</syntaxhighlight>after installation: Run <code>passwd</code> to change user password.


* cd /mnt
if internet broke/breaks, try one of the following:<syntaxhighlight lang="console">
* sudo nixos-install
$ nixos-rebuild switch --option substitute false # no downloads
after installation: Run <code>passwd</code> to change user password.
$ nixos-rebuild switch --option binary-caches "" # no downloads
 
</syntaxhighlight>
if internet broke/breaks, try one of the following:
 
* nixos-rebuild switch --option substitute false # no downloads
* nixos-rebuild switch --option binary-caches "" # no downloads
* wpa_supplicant flags to connect to wifi
* wpa_supplicant flags to connect to wifi


Line 187: Line 191:


* Blog post how to install NixOS on a [http://grahamc.com/blog/nixos-on-dell-9560 Dell 9560]
* Blog post how to install NixOS on a [http://grahamc.com/blog/nixos-on-dell-9560 Dell 9560]
* Brand servers may require extra kernel modules be included into initrd (boot.initrd.extraKernelModules in configuration.nix) For example HP Proliant needs "hpsa" module to see the disk drive.
* Brand servers may require extra kernel modules be included into initrd (<code>boot.initrd.extraKernelModules</code> in configuration.nix) For example HP Proliant needs "hpsa" module to see the disk drive.


[[Category:Guide]][[Category:Deployment]]
[[Category:Guide]][[Category:Deployment]]