Flakes/ja: Difference between revisions

Haruki7049 (talk | contribs)
Created page with "== Flakeスキーマ =="
Natsukium (talk | contribs)
No edit summary
Tags: Mobile edit Mobile web edit
 
(16 intermediate revisions by 2 users not shown)
Line 7: Line 7:
Nix flakesはNixのプロジェクトに一定の構造を強制し、ロックファイルを用いて依存するプロジェクトのバージョンを指定することでより便利に再現可能なNix式を記述できるようにします。
Nix flakesはNixのプロジェクトに一定の構造を強制し、ロックファイルを用いて依存するプロジェクトのバージョンを指定することでより便利に再現可能なNix式を記述できるようにします。


<div lang="en" dir="ltr" class="mw-content-ltr">
* [https://nixos.org/manual/nix/unstable/command-ref/new-cli/nix3-flake.html#description Flake]とは<code>flake.nix</code>というのNixファイルをルートに持つファイルシステムツリーを指します。
* A [https://nixos.org/manual/nix/unstable/command-ref/new-cli/nix3-flake.html#description flake] refers to a file-system tree whose root directory contains the Nix file specification called <code>flake.nix</code>.
</div>


* <code>flake.nix</code>ファイルの内容は、Nix言語でパッケージとその依存関係を宣言するための統一された命名スキーマに従っています。
* <code>flake.nix</code>ファイルの内容は、Nix言語でパッケージとその依存関係を宣言するための統一された命名スキーマに従っています。


<div lang="en" dir="ltr" class="mw-content-ltr">
Flakeは外部のソースを指定するために[https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-flake.html#flake-references URLのような構文]を提供しています。
Flakes introduce a [https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-flake.html#flake-references URL-like syntax] for specifying remote sources.
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
* 長いURL構文を簡易にするために[https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-registry.html Flakeはレジストリを使用]して短い記号として登録できます。
* To simplify the long URL syntax with shorter names, [https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-registry.html flakes uses a registry] of symbolic identifiers.
</div>


* また、Flakesは参照(Gitのrefsの事)とバージョンを固定することができ、それらをプログラムによって照会したり更新したりすることができます。
* また、Flakesは参照(Gitのrefsの事)とバージョンを固定することができ、それらをプログラムによって照会したり更新したりすることができます。


<div lang="en" dir="ltr" class="mw-content-ltr">
* [https://nixos.org/manual/nix/stable/command-ref/new-cli/nix.html 実験的なコマンドラインインタフェース]はFlakeの参照を受け取りパッケージのビルド、実行やデプロイができます。
* An [https://nixos.org/manual/nix/stable/command-ref/new-cli/nix.html experimental command-line interface] accepts flake references for expressions that build, run, and deploy packages.
</div>


<span id="Enable_flakes_temporarily"></span>
<span id="Enable_flakes_temporarily"></span>
Line 94: Line 86:
</syntaxHighlight>
</syntaxHighlight>


<span id="Flake_schema"></span>
== Flake schema ==
== Flakeスキーマ ==


<div lang="en" dir="ltr" class="mw-content-ltr">
flake.nixファイルはNixファイルですが、特殊な制限が設けられています(これについては後述します)。
The flake.nix file is a Nix file but that has special restrictions (more on that later).
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
Flakeは4つのトップレベルアトリビュートを持ちます:
It has 4 top-level attributes:
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
* <code>description</code>はflakeを説明する文字列です。
* <code>description</code> is a string describing the flake.
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
* <code>inputs</code>はflakeの依存関係をアトリビュートセットとして記述したものです。下にスキーマを記述しています。
* <code>inputs</code> is an attribute set of all the dependencies of the flake. The schema is described below.
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
* <code>outputs</code>はすべてのrealizeされたinputを受け取り、下に記述されたスキーマのようにアトリビュートセットを返す関数です。
* <code>outputs</code> is a function of one argument that takes an attribute set of all the realized inputs, and outputs another attribute set whose schema is described below.
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
* <code>nixConfig</code>[https://nixos.org/manual/nix/stable/command-ref/conf-file.html nix.confに使用できる値]を反映しています。これを用いてこのflake特有の設定を反映させることができます。例としてバイナリキャッシュを設定できます。
* <code>nixConfig</code> is an attribute set of values which reflect the [https://nixos.org/manual/nix/stable/command-ref/conf-file.html values given to nix.conf]. This can extend the normal behavior of a user's nix experience by adding flake-specific configuration, such as a binary cache.
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<span id="Input_schema"></span>
=== Input schema ===
=== Input スキーマ ===
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
[https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-flake.html#flake-inputs Nixのflake inputsのマニュアル].
[https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-flake.html#flake-inputs The nix flake inputs manual].
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
[https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-flake.html#flake-references Nix flake referencesのマニュアル].
[https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-flake.html#flake-references The nix flake references manual].
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
inputsアトリビュートはflakeの依存関係を定義します。例えば、システムflakeではシステムをビルドするためにnixpkgsに依存しています。
The inputs attribute defines the dependencies of the flake. For example, nixpkgs has to be defined as a dependency for a system flake in order for the system to build properly.
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
Nixpkgsは以下のコードで定義できます:
Nixpkgs can be defined using the following code:
</div>


<code>inputs.nixpkgs.url = "github:NixOS/nixpkgs/<branch name>";</code>
<code>inputs.nixpkgs.url = "github:NixOS/nixpkgs/<branch name>";</code>