NixOS: Difference between revisions

DHCP (talk | contribs)
m use "console" as syntax highlighting language for shell commands (Note: comments that start at beginnig of line aren't highlighted as comments, it's aka superuser sign. The use of `sudo cmd` vs `# cmd` across the wiki is inconsistent and `#` being used for comments is definitely more common. Can we somehow tweak the <syntaxhighlight> to treat `#` as comment and ask editors to use `sudo` to mark privilege escalation?)
Ardenet (talk | contribs)
Adjust the position of translation tags and delete some translation units for code
 
Line 1: Line 1:
<languages/>
<languages/>
<translate>
<!--T:1-->
{{Navbox Nix}}
{{Navbox Nix}}
{{Expansion|reason=It needs to be an easy introduction, because its one of the first articles new users read here. Thats why it needs to be simplified a bit and more complex topics should be moved to other articles.}}
{{Expansion|reason=<translate><!--T:1--> It needs to be an easy introduction, because its one of the first articles new users read here. Thats why it needs to be simplified a bit and more complex topics should be moved to other articles.</translate>}}


<translate>
<!--T:2-->
<!--T:2-->
[https://nixos.org/ NixOS] is a Linux distribution based on the [[Special:MyLanguage/Nix|Nix]] package manager and build system. It supports [[Wikipedia:Declarative programming|declarative]] system-wide [[Wikipedia:Configuration management|configuration management]] as well as [[Wikipedia:Atomicity (database_systems)|atomic]] upgrades and rollbacks, although it can additionally support [[Wikipedia:Imperative programming|imperative]] package and user management. In NixOS, all components of the distribution &mdash; including the [[Wikipedia:Linux kernel|kernel]], installed [[Wikipedia:Package manager|packages]] and system configuration files &mdash; are built by [[Special:MyLanguage/Nix|Nix]] from [[Wikipedia:Pure function|pure functions]] called [[Special:MyLanguage/Nix (language)|Nix expressions]].
[https://nixos.org/ NixOS] is a Linux distribution based on the [[Special:MyLanguage/Nix|Nix]] package manager and build system. It supports [[Wikipedia:Declarative programming|declarative]] system-wide [[Wikipedia:Configuration management|configuration management]] as well as [[Wikipedia:Atomicity (database_systems)|atomic]] upgrades and rollbacks, although it can additionally support [[Wikipedia:Imperative programming|imperative]] package and user management. In NixOS, all components of the distribution &mdash; including the [[Wikipedia:Linux kernel|kernel]], installed [[Wikipedia:Package manager|packages]] and system configuration files &mdash; are built by [[Special:MyLanguage/Nix|Nix]] from [[Wikipedia:Pure function|pure functions]] called [[Special:MyLanguage/Nix (language)|Nix expressions]].
Line 48: Line 47:


==== 32-bit ARM architectures ==== <!--T:17-->
==== 32-bit ARM architectures ==== <!--T:17-->
</translate>


</translate>
{{Main|NixOS on ARM}}
{{Main|NixOS on ARM}}
<translate>
<translate>
<!--T:18-->
<!--T:18-->
Line 56: Line 56:


==== 64-bit ARM architectures ==== <!--T:19-->
==== 64-bit ARM architectures ==== <!--T:19-->
</translate>


</translate>
{{Main|NixOS on ARM}}
{{Main|NixOS on ARM}}
<translate>
<translate>
<!--T:20-->
<!--T:20-->
Line 64: Line 65:


==== MIPS architectures ==== <!--T:21-->
==== MIPS architectures ==== <!--T:21-->
</translate>


</translate>
{{Main|NixOS on MIPS}}
{{Main|NixOS on MIPS}}
<translate>
<translate>
<!--T:22-->
<!--T:22-->
Line 72: Line 74:


==== RISC-V architectures ==== <!--T:64-->
==== RISC-V architectures ==== <!--T:64-->
</translate>


</translate>
{{Main|RISC-V}}
{{Main|RISC-V}}
<translate>
<translate>


Line 81: Line 84:


== Usage == <!--T:23-->
== Usage == <!--T:23-->
</translate>


</translate>
<span id="declarative-configuration"></span>
<span id="declarative-configuration"></span>
<translate>
<translate>
=== Declarative Configuration === <!--T:24-->
=== Declarative Configuration === <!--T:24-->
Line 151: Line 155:
<!--T:48-->
<!--T:48-->
The NixOS module system implements a typing system which allows typechecking of option settings. It also enables options defined in multiple places to be merged automatically. This allows you to spread your configuration over multiple files, and the options you set across all of those files will be merged together:
The NixOS module system implements a typing system which allows typechecking of option settings. It also enables options defined in multiple places to be merged automatically. This allows you to spread your configuration over multiple files, and the options you set across all of those files will be merged together:
</translate>


</translate>
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
{
{
Line 161: Line 165:
}
}
</nowiki>}}
</nowiki>}}
{{file|/etc/nixos/basic-webserver.nix|nix|<nowiki>
{{file|/etc/nixos/basic-webserver.nix|nix|<nowiki>
{
{
Line 169: Line 174:
}
}
</nowiki>}}
</nowiki>}}
{{file|/etc/nixos/blog.nix|nix|<nowiki>
{{file|/etc/nixos/blog.nix|nix|<nowiki>
{
{
Line 176: Line 182:
}
}
</nowiki>}}
</nowiki>}}
<translate>
<translate>
<!--T:49-->
<!--T:49-->
See the [https://nixos.org/manual/nixos/stable/index.html#sec-writing-modules Modules section of the NixOS Manual] for more details.
See the [https://nixos.org/manual/nixos/stable/index.html#sec-writing-modules Modules section of the NixOS Manual] for more details.
Line 188: Line 194:
<!--T:52-->
<!--T:52-->
You can roll back via:
You can roll back via:
</translate>


<!--T:53-->
<syntaxHighlight lang=console>
<syntaxHighlight lang=console>
$ nix-env --rollback              # roll back a user environment
$ nix-env --rollback              # roll back a user environment
Line 195: Line 201:
</syntaxHighlight>
</syntaxHighlight>


<translate>
<!--T:54-->
<!--T:54-->
NixOS also places entries for previous generations in the bootloader menu, so as a last resort you can always revert to a previous configuration by rebooting. To set the currently booted generation as the default run
NixOS also places entries for previous generations in the bootloader menu, so as a last resort you can always revert to a previous configuration by rebooting. To set the currently booted generation as the default run
Line 206: Line 213:
<!--T:55-->
<!--T:55-->
Because NixOS keeps previous generations of system state available in case rollback is desired, old package versions aren't deleted from your system immediately after an update. You can delete old generations manually:
Because NixOS keeps previous generations of system state available in case rollback is desired, old package versions aren't deleted from your system immediately after an update. You can delete old generations manually:
</translate>


<!--T:56-->
<syntaxHighlight lang=console>
<syntaxHighlight lang=console>
$ # delete generations older than 30 days
$ # delete generations older than 30 days
$ nix-collect-garbage --delete-older-than 30d
$ nix-collect-garbage --delete-older-than 30d


<!--T:57-->
$ # delete ALL previous generations - you can no longer rollback after running this
$ # delete ALL previous generations - you can no longer rollback after running this
$ nix-collect-garbage -d                       
$ nix-collect-garbage -d                       
</syntaxHighlight>
</syntaxHighlight>


<translate>
<!--T:58-->
<!--T:58-->
List generations:
List generations:
</translate>
<syntaxHighlight lang=console>
<syntaxHighlight lang=console>
$ # as root
$ # as root
Line 224: Line 233:
</syntaxHighlight>
</syntaxHighlight>


<translate>
<!--T:59-->
<!--T:59-->
Switch generations:
Switch generations:
</translate>
<syntaxHighlight lang=console>
<syntaxHighlight lang=console>
$ # as root switch to generation 204
$ # as root switch to generation 204
Line 231: Line 243:
</syntaxHighlight>
</syntaxHighlight>


<translate>
<!--T:60-->
<!--T:60-->
delete broken generation(s):
delete broken generation(s):
</translate>
<syntaxHighlight lang=console>
<syntaxHighlight lang=console>
$ # as root delete broken generations 205 and 206  
$ # as root delete broken generations 205 and 206  
Line 238: Line 253:
</syntaxHighlight>
</syntaxHighlight>


<translate>
<!--T:61-->
<!--T:61-->
You can configure automatic garbage collection by setting the [https://search.nixos.org/options?query=nix.gc nix.gc] options in <code>/etc/nixos/configuration.nix</code>. This is recommended, as it keeps the size of the Nix store down.
You can configure automatic garbage collection by setting the [https://search.nixos.org/options?query=nix.gc nix.gc] options in <code>/etc/nixos/configuration.nix</code>. This is recommended, as it keeps the size of the Nix store down.
Line 247: Line 263:
* [[Special:MyLanguage/NixOS VM tests|NixOS VM tests]], a library for creating reproducible infrastructure tests, based on [[Special:MyLanguage/Nixpkgs|Nixpkgs]], [[Special:MyLanguage/NixOS|NixOS]], QEMU and Perl.
* [[Special:MyLanguage/NixOS VM tests|NixOS VM tests]], a library for creating reproducible infrastructure tests, based on [[Special:MyLanguage/Nixpkgs|Nixpkgs]], [[Special:MyLanguage/NixOS|NixOS]], QEMU and Perl.
* [https://github.com/ryan4yin/nixos-and-flakes-book NixOS & Flakes Book] (Ryan4yin, 2023) - 🛠️ ❤️ An unofficial NixOS & Flakes book for beginners.
* [https://github.com/ryan4yin/nixos-and-flakes-book NixOS & Flakes Book] (Ryan4yin, 2023) - 🛠️ ❤️ An unofficial NixOS & Flakes book for beginners.
</translate>


</translate>
[[Category:Pedias]]
[[Category:Pedias]]
[[Category:NixOS]]
[[Category:NixOS]]
[[Category:Nix{{#translation:}}]]
[[Category:Nix]]