NixOS Installation Guide/ru: Difference between revisions

FuzzyBot (talk | contribs)
Updating to match new version of source page
FuzzyBot (talk | contribs)
Updating to match new version of source page
 
Line 1: Line 1:
<languages/>
<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
This guide is a companion guide for the [https://nixos.org/nixos/manual/index.html#ch-installation official manual]. It describes installation of [[NixOS]] as a complete operating system. For installation of [[Nix]] within an existing operating system, see [[Nix Installation Guide]].
This guide serves as a companion guide for the [https://nixos.org/nixos/manual/index.html#ch-installation official manual]. It describes installation of [[NixOS]] as a complete operating system. For instructions on installing [[Nix]] within an existing operating system, refer to the [[Nix Installation Guide]].
</div>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
In addition to describing the steps from the official manual, it provides known good instructions for common use cases. When there is a discrepancy between the manual and this guide, the supported case is the one described in the manual.
In addition to covering the steps from the official manual, it provides known good instructions for common use cases. When there is a discrepancy between the manual and this guide, the supported case is the one described in the manual.
</div>
 
<div lang="en" dir="ltr" class="mw-content-ltr">
Use this guide as a step-by-step guide, choices will be presented, use only the selected section, and continue at the section it tells you to at the end.
</div>
</div>


Line 122: Line 119:


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
Since the installation media is hybrid, it will boot both in legacy bios mode and UEFI mode.
The installation media is hybrid and is capable of booting in both legacy BIOS mode and [[UEFI]] mode.
</div>
</div>


Line 174: Line 171:


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
Network Manager is installed on the graphical ISO, meaning that it is possible to use <code>nmtui</code> on the command line to connect to a network.
[[NetworkManager]] is installed on the graphical ISO, meaning that it is possible to use <code>nmtui</code> on the command line to connect to a network.
</div>
</div>


Line 183: Line 180:


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
On the minimal ISO, or if you are more familiar with <code>wpa_supplicant</code> then you can also run <code>wpa_passphrase ESSID | sudo tee /etc/wpa_supplicant.conf</code>, then enter your password and <code>systemctl restart wpa_supplicant</code>.
On the minimal ISO, or if you are more familiar with [[wpa_supplicant]] then you can also run <code>wpa_passphrase ESSID | sudo tee /etc/wpa_supplicant.conf</code>, then enter your password and <code>systemctl restart wpa_supplicant</code>.
</div>
</div>


Line 191: Line 188:


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
To partition the persistent storage run <code>sudo fdisk /dev/diskX</code> and follow instructions for DOS or (U)EFI.
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:
</div>
 
<syntaxhighlight lang="console">
$ [ -d /sys/firmware/efi/efivars ] && echo "UEFI" || echo "Legacy"
</syntaxhighlight>
 
<div lang="en" dir="ltr" class="mw-content-ltr">
A very simple example setup is given here.
A very simple example setup is given here.
</div>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
=== DOS ===
=== Legacy Boot (MBR) ===
</div>
</div>


Line 235: Line 239:


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
== Label partitions ==
=== Format partitions ===
</div>
 
<div lang="en" dir="ltr" class="mw-content-ltr">
The example below uses the [[ext4]] filesystem format. If you wish to use other filesystem formats such as [[Btrfs]] or [[ZFS]]:
</div>
 
<div lang="en" dir="ltr" class="mw-content-ltr">
* [[Bcachefs#NixOS installation on bcachefs]]
* [[Btrfs#Installation of NixOS on btrfs]]
* [[LVM#Basic Setup]]
* [[ZFS#Simple NixOS ZFS on root installation]]
</div>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
This is useful for having multiple setups and makes partitions easier to handle<syntaxhighlight lang="console">
This is useful for having multiple setups and makes partitions easier to handle
$ lsblk
</div>
$ sudo mkfs.fat -F 32 /dev/sdX1
 
$ sudo fatlabel /dev/sdX1 NIXBOOT
<syntaxhighlight lang="console">
$ sudo mkfs.ext4 /dev/sdX2 -L NIXROOT
$ lsblk # lists current system block devices
$ sudo mount /dev/disk/by-label/NIXROOT /mnt
# mkfs.fat -F 32 -n boot /dev/sdX1
$ sudo mkdir -p /mnt/boot
# mkfs.ext4 /dev/sdX2 -L nixos
$ sudo mount /dev/disk/by-label/NIXBOOT /mnt/boot
# mount /dev/disk/by-label/nixos /mnt
# mkdir -p /mnt/boot
# mount /dev/disk/by-label/boot /mnt/boot
</syntaxhighlight>
</syntaxhighlight>
<div lang="en" dir="ltr" class="mw-content-ltr">
== NixOS configuration ==
</div>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
== Swap file ==
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]]:
</div>
 
<syntaxhighlight lang="console">
<syntaxhighlight lang="console">
$ sudo dd if=/dev/zero of=/mnt/.swapfile bs=1024 count=2097152 (2GB size)
# nixos-generate-config --root /mnt
$ sudo chmod 600 /mnt/.swapfile
# nano /mnt/etc/nixos/configuration.nix
$ sudo mkswap /mnt/.swapfile
$ sudo swapon /mnt/.swapfile
</syntaxhighlight>
</syntaxhighlight>
<div lang="en" dir="ltr" class="mw-content-ltr">
For information on working with a system configuration, see [[NixOS system configuration]]. For desktop-specific configurations, see [[NixOS as a desktop]].
</div>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
== NixOS config ==
Most essential changes:
<syntaxhighlight lang="console">
$ sudo nixos-generate-config --root /mnt
$ cd /mnt/etc/nixos/
$ sudo vim configuration.nix
</syntaxhighlight>Most essential changes:
</div>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
* keyboard layout, ie <code>[[Keyboard Layout Customization|services.xserver.xkb.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>
* [[networking]] (wifi), see below for fix if it breaks
* [[networking]] (wifi), see below for fix if it breaks
* <code>boot.loader.grub.device = "/dev/sda"; #or "nodev" for efi only</code>
* install [[:Category:Text Editor|editor]] to edit the configuration
* install editor to edit the configuration
* change hardware config to use labels
</div>
</div>


Line 281: Line 296:
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].
</div>
</div>
<div lang="en" dir="ltr" class="mw-content-ltr">
=== Swap file ===
</div>
<div lang="en" dir="ltr" class="mw-content-ltr">
For additional methods of configuring swap, see [[Swap]]. The following example demonstrates how to create and enable a [[Swap#Swap file|swap file]]:
</div>
{{file|/mnt/etc/nixos/configuration.nix|nix|
<nowiki>
  swapDevices = [{
    device = "/var/lib/swapfile";
    size = 16*1024; # 16 GB
  }];
</nowiki>
}}
<div lang="en" dir="ltr" class="mw-content-ltr">
=== Bootloader ===
</div>
<div lang="en" dir="ltr" class="mw-content-ltr">
NixOS supports multiple [[Bootloader|bootloaders]] such as [[GNU GRUB]] and [[Systemd/boot]].
</div>
<div lang="en" dir="ltr" class="mw-content-ltr">
Systemd-boot is the recommended bootloader. The following example demonstrates how to enable systemd-boot in your configuration:
</div>
{{file|/mnt/etc/nixos/configuration.nix|nix|
<nowiki>
  boot.loader.systemd-boot.enable = true;
</nowiki>
}}
<div lang="en" dir="ltr" class="mw-content-ltr">
You may also wish to configure [[Secure Boot]].
</div>
<div lang="en" dir="ltr" class="mw-content-ltr">
=== Users ===
</div>
<div lang="en" dir="ltr" class="mw-content-ltr">
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:
</div>
{{file|/mnt/etc/nixos/configuration.nix|nix|
<nowiki>
  users.users.alice = {
    isNormalUser = true;
    initialPassword = "pw123";
  };
</nowiki>
}}


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
== NixOS installation ==
== NixOS installation ==
</div>
<syntaxhighlight lang="console">
<syntaxhighlight lang="console">
$ cd /mnt
# cd /mnt
$ sudo nixos-install
# nixos-install
</syntaxhighlight>after installation: Run <code>passwd</code> to change user password.
</syntaxhighlight>
 
<div lang="en" dir="ltr" class="mw-content-ltr">
after installation: Run <code>passwd</code> to change user password.
</div>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
if internet broke/breaks, try one of the following:<syntaxhighlight lang="console">
if internet broke/breaks, try one of the following:
$ nixos-rebuild switch --option substitute false # no downloads
</div>
$ nixos-rebuild switch --option binary-caches "" # no downloads
 
<syntaxhighlight lang="console">
# nixos-rebuild switch --option substitute false # no downloads
# nixos-rebuild switch --option binary-caches "" # no downloads
</syntaxhighlight>
</syntaxhighlight>
<div lang="en" dir="ltr" class="mw-content-ltr">
* wpa_supplicant flags to connect to wifi
* wpa_supplicant flags to connect to wifi
</div>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<hr />
<hr />
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
Line 316: Line 395:


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
[[Category:Guide]][[Category:Deployment]]
[[Category:Guide]]
[[Category:Deployment]]
[[Category:NixOS]]
</div>
</div>