NixOS/ja: Difference between revisions

Amai-ICE (talk | contribs)
リンク先をのミスを修正
FuzzyBot (talk | contribs)
Updating to match new version of source page
Tags: Mobile edit Mobile web edit
 
Line 1: Line 1:
<languages/>
<languages/>
{{Navbox Nix}}
{{Navbox Nix}}
{{Expansion|reason=新規ユーザーが最初に読む記事の一つなので、もっとわかりやすい紹介文にするべきです。そのため、この記事の内容を簡略化し、より複雑な話題は他の記事に移動する必要があります。}}
{{Expansion|reason=<span class="mw-translate-fuzzy">{{Navbox Nix}}
{{Expansion|reason=新規ユーザーが最初に読む記事の一つなので、もっとわかりやすい紹介文にするべきです。そのため、この記事の内容を簡略化し、より複雑な話題は他の記事に移動する必要があります。}}</span>}}


<div class="mw-translate-fuzzy">
[https://nixos.org/ NixOS]は[[Special:MyLanguage/Nix|Nix]]パッケージマネージャーとビルドシステムをベースにしたLinuxディストリビューションです。システム全体の[https://ja.wikipedia.org/wiki/%E5%AE%A3%E8%A8%80%E5%9E%8B%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%9F%E3%83%B3%E3%82%B0 宣言的]な[https://ja.wikipedia.org/wiki/%E6%A7%8B%E6%88%90%E7%AE%A1%E7%90%86 構成管理]、[https://ja.wikipedia.org/wiki/%E4%B8%8D%E5%8F%AF%E5%88%86%E6%93%8D%E4%BD%9C アトミック]な更新とロールバックに加え、[https://ja.wikipedia.org/wiki/%E5%91%BD%E4%BB%A4%E5%9E%8B%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%9F%E3%83%B3%E3%82%B0 命令形]のパッケージ/ユーザー管理が実現できます。
[https://nixos.org/ NixOS]は[[Special:MyLanguage/Nix|Nix]]パッケージマネージャーとビルドシステムをベースにしたLinuxディストリビューションです。システム全体の[https://ja.wikipedia.org/wiki/%E5%AE%A3%E8%A8%80%E5%9E%8B%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%9F%E3%83%B3%E3%82%B0 宣言的]な[https://ja.wikipedia.org/wiki/%E6%A7%8B%E6%88%90%E7%AE%A1%E7%90%86 構成管理]、[https://ja.wikipedia.org/wiki/%E4%B8%8D%E5%8F%AF%E5%88%86%E6%93%8D%E4%BD%9C アトミック]な更新とロールバックに加え、[https://ja.wikipedia.org/wiki/%E5%91%BD%E4%BB%A4%E5%9E%8B%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%9F%E3%83%B3%E3%82%B0 命令形]のパッケージ/ユーザー管理が実現できます。
NixOSでは[https://ja.wikipedia.org/wiki/Linux%E3%82%AB%E3%83%BC%E3%83%8D%E3%83%AB カーネル]、インストールする[https://ja.wikipedia.org/wiki/%E3%83%91%E3%83%83%E3%82%B1%E3%83%BC%E3%82%B8%E7%AE%A1%E7%90%86%E3%82%B7%E3%82%B9%E3%83%86%E3%83%A0 パッケージ]、コンフィグファイルなど、システムを構成するすべての要素が[[Special:MyLanguage/Nix Expression Language|Nix式]]と呼ばれる[https://en.wikipedia.org/wiki/Pure_function 純粋関数(英語)]によって構成されます。
NixOSでは[https://ja.wikipedia.org/wiki/Linux%E3%82%AB%E3%83%BC%E3%83%8D%E3%83%AB カーネル]、インストールする[https://ja.wikipedia.org/wiki/%E3%83%91%E3%83%83%E3%82%B1%E3%83%BC%E3%82%B8%E7%AE%A1%E7%90%86%E3%82%B7%E3%82%B9%E3%83%86%E3%83%A0 パッケージ]、コンフィグファイルなど、システムを構成するすべての要素が[[Special:MyLanguage/Nix Expression Language|Nix式]]と呼ばれる[https://en.wikipedia.org/wiki/Pure_function 純粋関数(英語)]によって構成されます。
</div>


<div class="mw-translate-fuzzy">
Nixでは[https://ja.wikipedia.org/wiki/%E5%AE%9F%E8%A1%8C%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB バイナリ]キャッシュを利用しているため、Debianのようなバイナリ指向ディストリビューションと、Gentooのような[https://ja.wikipedia.org/wiki/%E3%82%BD%E3%83%BC%E3%82%B9%E3%82%B3%E3%83%BC%E3%83%89 ソース]指向のディストリビューションの要素を併せ持った、独自の方式を提供しています。OSの根幹をなす一般的なパッケージにはバイナリをそのまま使用することができ、ビルド済みのバイナリが提供されていない独自のパッケージやモジュールについては、自動的にソースからビルドして使用します。
Nixでは[https://ja.wikipedia.org/wiki/%E5%AE%9F%E8%A1%8C%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB バイナリ]キャッシュを利用しているため、Debianのようなバイナリ指向ディストリビューションと、Gentooのような[https://ja.wikipedia.org/wiki/%E3%82%BD%E3%83%BC%E3%82%B9%E3%82%B3%E3%83%BC%E3%83%89 ソース]指向のディストリビューションの要素を併せ持った、独自の方式を提供しています。OSの根幹をなす一般的なパッケージにはバイナリをそのまま使用することができ、ビルド済みのバイナリが提供されていない独自のパッケージやモジュールについては、自動的にソースからビルドして使用します。
</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 66: Line 71:


{{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 75: Line 81:


{{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 84: Line 91:


{{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 93: Line 101:


{{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 103: Line 112:


<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 152: Line 162:


<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 168: Line 178:


<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 211: Line 221:
}
}
</nowiki>}}
</nowiki>}}
{{file|/etc/nixos/basic-webserver.nix|nix|<nowiki>
{{file|/etc/nixos/basic-webserver.nix|nix|<nowiki>
{
{
Line 219: Line 230:
}
}
</nowiki>}}
</nowiki>}}
{{file|/etc/nixos/blog.nix|nix|<nowiki>
{{file|/etc/nixos/blog.nix|nix|<nowiki>
{
{
Line 228: Line 240:


<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 243: Line 255:
</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 254: Line 264:
</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 262: Line 272:
</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 310: Line 319:
* [[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]]