NixOS Installation Guide: Difference between revisions

Bzadm (talk | contribs)
fix typo
Ardenet (talk | contribs)
Marked this version for translation
Tags: Mobile edit Mobile web edit
 
(4 intermediate revisions by 4 users not shown)
Line 132: Line 132:
<!--T:45-->
<!--T:45-->
To partition the persistent storage run <code>sudo fdisk /dev/diskX</code> and follow instructions for MBR or (U)EFI. To determine which mode you are booted into, run:
To partition the persistent storage run <code>sudo fdisk /dev/diskX</code> and follow instructions for MBR or (U)EFI. To determine which mode you are booted into, run:
</translate>


<syntaxhighlight lang="console">
<syntaxhighlight lang="console">
Line 137: Line 138:
</syntaxhighlight>
</syntaxhighlight>


 
<translate>
<!--T:63-->
A very simple example setup is given here.
A very simple example setup is given here.


Line 175: Line 177:
=== Format partitions === <!--T:50-->
=== Format partitions === <!--T:50-->


<!--T:51-->
<!--T:64-->
The example below uses the [[ext4]] filesystem format. If you wish to use other filesystem formats such as [[Btrfs]] or [[ZFS]]:  
The example below uses the [[ext4]] filesystem format. If you wish to use other filesystem formats such as [[Btrfs]] or [[ZFS]]:  


<!--T:65-->
* [[Bcachefs#NixOS installation on bcachefs]]
* [[Bcachefs#NixOS installation on bcachefs]]
* [[Btrfs#Installation of NixOS on btrfs]]
* [[Btrfs#Installation of NixOS on btrfs]]
Line 183: Line 186:
* [[ZFS#Simple NixOS ZFS on root installation]]
* [[ZFS#Simple NixOS ZFS on root installation]]


This is useful for having multiple setups and makes partitions easier to handle<syntaxhighlight lang="console">
<!--T:51-->
This is useful for having multiple setups and makes partitions easier to handle
</translate>
 
<syntaxhighlight lang="console">
$ lsblk # lists current system block devices
$ lsblk # lists current system block devices
# mkfs.fat -F 32 -n boot /dev/sdX1
# mkfs.fat -F 32 -n boot /dev/sdX1
# mkfs.ext4 /dev/sdX2 -L nixos
# mkfs.ext4 /dev/sdX2 -L nixos
# mount /dev/disk/by-label/root /mnt
# mount /dev/disk/by-label/nixos /mnt
# mkdir -p /mnt/boot
# mkdir -p /mnt/boot
# mount /dev/disk/by-label/boot /mnt/boot
# mount /dev/disk/by-label/boot /mnt/boot
</syntaxhighlight>
</syntaxhighlight>


<!--T:53-->
<translate>
== NixOS configuration ==
== NixOS configuration == <!--T:53-->


<!--T:66-->
NixOS is configured through a [[Overview of the NixOS Linux distribution#Declarative Configuration|declarative configuration]] file. To generate a default config file, run [[nixos-generate-config]]:
NixOS is configured through a [[Overview of the NixOS Linux distribution#Declarative Configuration|declarative configuration]] file. To generate a default config file, run [[nixos-generate-config]]:
</translate>


<syntaxhighlight lang="console">
<syntaxhighlight lang="console">
Line 202: Line 211:
</syntaxhighlight>
</syntaxhighlight>


<translate>
<!--T:67-->
For information on working with a system configuration, see [[NixOS system configuration]]. For desktop-specific configurations, see [[NixOS as a desktop]].
<!--T:68-->
Most essential changes:
Most essential changes:


Line 212: Line 226:
The self-documenting NixOS options can be searched with [https://search.nixos.org/options NixOS options search].
The self-documenting NixOS options can be searched with [https://search.nixos.org/options NixOS options search].


<!--T:52-->
=== Swap file === <!--T:52-->
=== Swap file ===


<!--T:69-->
For additional methods of configuring swap, see [[Swap]]. The following example demonstrates how to create and enable a [[Swap#Swap file|swap file]]:
For additional methods of configuring swap, see [[Swap]]. The following example demonstrates how to create and enable a [[Swap#Swap file|swap file]]:
</translate>


{{file|/mnt/etc/nixos/configuration.nix|nix|
{{file|/mnt/etc/nixos/configuration.nix|nix|
Line 226: Line 241:
}}
}}


=== Bootloader ===
<translate>
=== Bootloader === <!--T:70-->


<!--T:71-->
NixOS supports multiple [[Bootloader|bootloaders]] such as [[GNU GRUB]] and [[Systemd/boot]].
NixOS supports multiple [[Bootloader|bootloaders]] such as [[GNU GRUB]] and [[Systemd/boot]].


Sysyemd-boot is the recommended bootloader. The following example demonstrates how to enable systemd-boot in your configuration:
<!--T:72-->
Systemd-boot is the recommended bootloader. The following example demonstrates how to enable systemd-boot in your configuration:
</translate>


{{file|/mnt/etc/nixos/configuration.nix|nix|
{{file|/mnt/etc/nixos/configuration.nix|nix|
Line 238: Line 257:
}}
}}


<translate>
<!--T:73-->
You may also wish to configure [[Secure Boot]].
You may also wish to configure [[Secure Boot]].


=== Users ===
=== Users === <!--T:74-->


<!--T:75-->
For information on creating and managing users, see [[User management]] and the {{NixOS Manual|name=NixOS Manual: Chapter - Package Management|anchor=#sec-user-management}}. See an example below:
For information on creating and managing users, see [[User management]] and the {{NixOS Manual|name=NixOS Manual: Chapter - Package Management|anchor=#sec-user-management}}. See an example below:
</translate>


{{file|/mnt/etc/nixos/configuration.nix|nix|
{{file|/mnt/etc/nixos/configuration.nix|nix|
Line 253: Line 276:
}}
}}


<!--T:56-->
<translate>
== NixOS installation ==
== NixOS installation == <!--T:56-->
</translate>
 
<syntaxhighlight lang="console">
<syntaxhighlight lang="console">
# cd /mnt
# cd /mnt
# nixos-install
# nixos-install
</syntaxhighlight>after installation: Run <code>passwd</code> to change user password.
</syntaxhighlight>
 
<translate>
<!--T:76-->
after installation: Run <code>passwd</code> to change user password.


<!--T:57-->
<!--T:57-->
if internet broke/breaks, try one of the following:<syntaxhighlight lang="console">
if internet broke/breaks, try one of the following:
</translate>
 
<syntaxhighlight lang="console">
# nixos-rebuild switch --option substitute false # no downloads
# nixos-rebuild switch --option substitute false # no downloads
# nixos-rebuild switch --option binary-caches "" # no downloads
# nixos-rebuild switch --option binary-caches "" # no downloads
</syntaxhighlight>
</syntaxhighlight>
<translate>
<!--T:58-->
* wpa_supplicant flags to connect to wifi
* wpa_supplicant flags to connect to wifi
</translate>


<!--T:58-->
<hr />
<hr />


<translate>
== Additional notes for specific hardware == <!--T:59-->
== Additional notes for specific hardware == <!--T:59-->