NixOS/pt-br: Difference between revisions

Victru (talk | contribs)
Created page with "[https://nixos.org/ NixOS] é uma distribuição Linux baseada no gerenciador de pacotes e sistema de builds Nix. Ele suporta uma configuração [https://en.wikipedia.org/wiki/Declarative_programming declarativa] assim como atualizações e rollbacks [https://en.wikipedia.org/wiki/Atomicity_(database_systems) atomicos], entretanto ele também suporta gerenciamento de pacotes e usuários de maneira [https://en.wikipedia.org/wiki/Imperative_progr..."
 
FuzzyBot (talk | contribs)
Updating to match new version of source page
Tags: Mobile edit Mobile web edit
 
(5 intermediate revisions by one other user not shown)
Line 1: Line 1:
<languages/>
<languages/>
<div lang="en" dir="ltr" class="mw-content-ltr">
{{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=<span lang="en" dir="ltr" class="mw-content-ltr">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.</span>}}
 
<div class="mw-translate-fuzzy">
[https://nixos.org/ NixOS] é uma distribuição Linux baseada no gerenciador de pacotes e sistema de builds [[Special:MyLanguage/Nix|Nix]]. Ele suporta o gerenciamento [https://en.wikipedia.org/wiki/Declarative_programming declarativo] de configurações de todo o sistema, bem como atualizações e reversões (rollbacks) [https://en.wikipedia.org/wiki/Atomicity_(database_systems) atômicas]; embora também possa suportar, adicionalmente, o gerenciamento [https://en.wikipedia.org/wiki/Imperative_programming imperativo] de pacotes e usuários. No NixOS, todos os componentes da distribuição &mdash; incluindo o [https://en.wikipedia.org/wiki/Linux_kernel kernel], [https://en.wikipedia.org/wiki/Package_manager pacotes] instalados e arquivos de configuração do sistema &mdash; são construídos pelo [[Special:MyLanguage/Nix|Nix]] através de [[Wikipedia:Pure function|funções puras]] chamadas de [[Special:MyLanguage/Nix Expression Language|expressões Nix]].
</div>
</div>
[https://nixos.org/ NixOS] é uma distribuição Linux baseada no gerenciador de pacotes e sistema de builds [[Special:MyLanguage/Nix|Nix]]. Ele suporta uma configuração [https://en.wikipedia.org/wiki/Declarative_programming declarativa] assim como atualizações e rollbacks [https://en.wikipedia.org/wiki/Atomicity_(database_systems) atomicos], entretanto ele também suporta gerenciamento de pacotes e usuários de maneira [https://en.wikipedia.org/wiki/Imperative_programming imperativa]. No NixOS, todos os componentes da distribuição &mdash; incluindo o [https://en.wikipedia.org/wiki/Linux_kernel kernel], [https://en.wikipedia.org/wiki/Package_manager pacotes] instalados e configurações do sistema de arquivos &mdash; são construídos pelo [[Special:MyLanguage/Nix|Nix]] através de [[Wikipedia:Pure function|funções puras]] chamadas de [[Special:MyLanguage/Nix Expression Language|Nix expressions]]


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
Since Nix uses [https://en.wikipedia.org/wiki/Executable binary] caching, this provides a unique compromise between the binary-oriented approach used by distributions such as Debian and the [https://en.wikipedia.org/wiki/Source_code source]-oriented approach used by distributions such as Gentoo. Binaries can be used for standard components, and custom-built packages and modules can be used automatically when a pre-built binary is not available.
Since Nix uses [[Wikipedia:Executable|binary]] caching, this provides a unique compromise between the binary-oriented approach used by distributions such as Debian and the [[Wikipedia:Source code|source]]-oriented approach used by distributions such as Gentoo. Binaries can be used for standard components, and custom-built packages and modules can be used automatically when a pre-built binary is not available.
</div>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
Stable NixOS releases are delivered twice a year (around the end of May and the end of November). NixOS was created by [https://edolstra.github.io/ Eelco Dolstra] and [https://en.wikipedia.org/wiki/Armijn_Hemel Armijn Hemel], and initially released in 2003. It is community developed and maintained under the stewardship of the [[Special:MyLanguage/Nix_Community#NixOS_Foundation|NixOS Foundation]].
Stable NixOS releases are delivered twice a year (around the end of May and the end of November). NixOS was created by [https://edolstra.github.io/ Eelco Dolstra] and [[Wikipedia:Armijn Hemel|Armijn Hemel]], and initially released in 2003. It is community developed and maintained under the stewardship of the [[Special:MyLanguage/Nix_Community#NixOS_Foundation|NixOS Foundation]].
</div>
</div>


Line 69: Line 69:


{{Main|NixOS on ARM}}
{{Main|NixOS on ARM}}
<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
NixOS isn't officially supported on ARM32 devices (e.g. <code>armv6</code> and <code>armv7l</code>), however, for some of these devices, there may be community support.
NixOS isn't officially supported on ARM32 devices (e.g. <code>armv6</code> and <code>armv7l</code>), however, for some of these devices, there may be community support.
Line 78: Line 79:


{{Main|NixOS on ARM}}
{{Main|NixOS on ARM}}
<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
As long as a device supports the generic systemd boot process, NixOS should run out of the box. However, specific devices with proprietary bootloaders may have issues running it.
As long as a device supports the generic systemd boot process, NixOS should run out of the box. However, specific devices with proprietary bootloaders may have issues running it.
Line 87: Line 89:


{{Main|NixOS on MIPS}}
{{Main|NixOS on MIPS}}
<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
There used to be limited support for MIPS architectures in NixOS, and remnants of this support may still be found in Nixpkgs. However, there is no official support.
There used to be limited support for MIPS architectures in NixOS, and remnants of this support may still be found in Nixpkgs. However, there is no official support.
Line 96: Line 99:


{{Main|RISC-V}}
{{Main|RISC-V}}


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
Line 106: Line 110:


<span id="declarative-configuration"></span>
<span id="declarative-configuration"></span>
<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
=== Declarative Configuration ===
=== Declarative Configuration ===
Line 155: Line 160:


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
For more information on using and configuring nix channels, refer to [[Special:MyLanguage/channel branches|channel branches]].
For more information on using and configuring nix channels, refer to [[Special:MyLanguage/Channel branches|channel branches]].
</div>
</div>


Line 171: Line 176:


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
The main difference between NixOS and other Linux distributions is that NixOS does not follow the [https://en.wikipedia.org/wiki/Linux_Standard_Base Linux Standard Base] file system structure. On LSB-compliant systems software is stored under <code>/{,usr}/{bin,lib,share}</code> and configuration is generally stored in <code>/etc</code>. Software binaries are available in the user environment if they are placed in one of the LSB's <code>/bin</code> directories. When a program references dynamic libraries it will search for the required libraries in the LSB folders (<code>/lib</code>, <code>/usr/lib</code>).
The main difference between NixOS and other Linux distributions is that NixOS does not follow the [[Wikipedia:Linux Standard Base |Linux Standard Base ]] file system structure. On LSB-compliant systems software is stored under <code>/{,usr}/{bin,lib,share}</code> and configuration is generally stored in <code>/etc</code>. Software binaries are available in the user environment if they are placed in one of the LSB's <code>/bin</code> directories. When a program references dynamic libraries it will search for the required libraries in the LSB folders (<code>/lib</code>, <code>/usr/lib</code>).
</div>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
In NixOS however <code>/lib</code> and <code>/usr/lib</code> do not exist. Instead all system libraries, binaries, kernels, firmware and configuration files are placed in the [[Special:MyLanguage/Nix#Nix store|Nix store]]. The files and directories in <code>/nix/store</code> are named by hashes of the information describing the built data. All of the files and directories placed in the Nix store are immutable. <code>/bin</code> and <code>/usr/bin</code> are almost absent: they contain only <code>/bin/sh</code> and <code>/usr/bin/env</code> respectively, to provide minimal compatibility with existing scripts using shebang lines. User-level environments are implemented using a large number of symbolic links to all required packages and auxiliary files. These environments are called [[Special:MyLanguage/Nix#Profiles|profiles]] and are stored in <code>/nix/var/nix/profiles</code>, each user having their own profiles. Structuring the system in this way is how NixOS obtains its key advantages over conventional Linux distributions, such as atomicity and rollback support.
In NixOS however <code>/lib</code> and <code>/usr/lib</code> do not exist. Instead all system libraries, binaries, kernels, firmware and configuration files are placed in the [[Special:MyLanguage/Nix (package_manager)#Nix store|Nix store]]. The files and directories in <code>/nix/store</code> are named by hashes of the information describing the built data. All of the files and directories placed in the Nix store are immutable. <code>/bin</code> and <code>/usr/bin</code> are almost absent: they contain only <code>/bin/sh</code> and <code>/usr/bin/env</code> respectively, to provide minimal compatibility with existing scripts using shebang lines. User-level environments are implemented using a large number of symbolic links to all required packages and auxiliary files. These environments are called [[Special:MyLanguage/Nix#Profiles|profiles]] and are stored in <code>/nix/var/nix/profiles</code>, each user having their own profiles. Structuring the system in this way is how NixOS obtains its key advantages over conventional Linux distributions, such as atomicity and rollback support.
</div>
</div>


Line 214: Line 219:
}
}
</nowiki>}}
</nowiki>}}
{{file|/etc/nixos/basic-webserver.nix|nix|<nowiki>
{{file|/etc/nixos/basic-webserver.nix|nix|<nowiki>
{
{
Line 222: Line 228:
}
}
</nowiki>}}
</nowiki>}}
{{file|/etc/nixos/blog.nix|nix|<nowiki>
{{file|/etc/nixos/blog.nix|nix|<nowiki>
{
{
Line 231: Line 238:


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
See the [https://nixos.org/nixos/manual/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.
</div>
</div>


Line 246: Line 253:
</div>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<syntaxHighlight lang=console>
<syntaxHighlight lang=shell>
$ nix-env --rollback              # roll back a user environment
$ nix-env --rollback              # roll back a user environment
$ nixos-rebuild switch --rollback  # roll back a system environment
$ nixos-rebuild switch --rollback  # roll back a system environment
</syntaxHighlight>
</syntaxHighlight>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
Line 257: Line 262:
</div>
</div>


<syntaxHighlight lang=shell>
<syntaxHighlight lang=console>
$ /run/current-system/bin/switch-to-configuration boot
$ /run/current-system/bin/switch-to-configuration boot
</syntaxHighlight>
</syntaxHighlight>
Line 265: Line 270:
</div>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<syntaxHighlight lang=console>
<syntaxHighlight lang=shell>
$ # 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
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
$ # 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>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
List generations:
List generations:
<syntaxHighlight lang=shell>
</div>
# as root
 
<syntaxHighlight lang=console>
$ # as root
$ nix-env --list-generations --profile /nix/var/nix/profiles/system
$ nix-env --list-generations --profile /nix/var/nix/profiles/system
</syntaxHighlight>
</syntaxHighlight>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
Switch generations:
Switch generations:
<syntaxHighlight lang=shell>
</div>
# as root switch to generation 204
 
<syntaxHighlight lang=console>
$ # as root switch to generation 204
$ nix-env --profile /nix/var/nix/profiles/system --switch-generation 204
$ nix-env --profile /nix/var/nix/profiles/system --switch-generation 204
</syntaxHighlight>
</syntaxHighlight>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
delete broken generation(s):
delete broken generation(s):
<syntaxHighlight lang=shell>
</div>
# as root delete broken generations 205 and 206  
 
<syntaxHighlight lang=console>
$ # as root delete broken generations 205 and 206  
$ nix-env --profile /nix/var/nix/profiles/system --delete-generations 205 206
$ nix-env --profile /nix/var/nix/profiles/system --delete-generations 205 206
</syntaxHighlight>
</syntaxHighlight>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
Line 313: Line 317:
* [[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.
</div>  
</div>


[[Category:Pedias]]
[[Category:Pedias]]
[[Category:NixOS]]
[[Category:NixOS]]
[[Category:Nix{{#translation:}}]]
[[Category:Nix]]