Flakes/ja: Difference between revisions
Updating to match new version of source page |
Updating to match new version of source page |
||
| Line 4: | Line 4: | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
'''Nix flakes''' are an [ | '''Nix flakes''' are an [https://nix.dev/manual/nix/stable/contributing/experimental-features experimental feature] first introduced in the 2.4 [[Nix]] release,{{Cite manual|nix|development/experimental-features|number=13.8|title=Experimental Features|subsection=xp-feature-flakes|subtitle=flakes}}{{Cite manual|nix|release-notes/rl-2.4|number=14.27|title=Release 2.4 (2021-11-01)}} aiming to address a number of areas of improvement for the Nix ecosystem: they provide a uniform structure for Nix projects, allow for pinning specific versions of each dependencies, and sharing these dependencies via lock files, and overall make it more convenient to write reproducible Nix expressions. | ||
</div> | </div> | ||
| Line 120: | Line 120: | ||
</div> | </div> | ||
<div class="mw-translate-fuzzy"> | |||
{{注記: | [https://github.com/DeterminateSystems/nix-installer Determinate Nix Installer]ではデフォルトでflakesを有効化しています。}} | {{注記: | [https://github.com/DeterminateSystems/nix-installer Determinate Nix Installer]ではデフォルトでflakesを有効化しています。}} | ||
</div> | |||
次の内容を<code>~/.config/nix/nix.conf</code>または<code>/etc/nix/nix.conf</code>に追記してください: | 次の内容を<code>~/.config/nix/nix.conf</code>または<code>/etc/nix/nix.conf</code>に追記してください: | ||
| Line 179: | Line 181: | ||
description = "Example flake with a devShell"; | description = "Example flake with a devShell"; | ||
inputs.nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; | inputs.nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; | ||
outputs = { self, nixpkgs}: | outputs = { self, nixpkgs }: | ||
let | let | ||
system = "x86_64-linux"; | system = "x86_64-linux"; | ||
| Line 216: | Line 218: | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
Running <code>nix build</code> will look in the <code>legacyPackages</code> and <code>packages</code> output attributes for the corresponding [[derivation]] and then your system architecture and build the default output. If you want to specify a build attribute in a flake repository, you can run <code>nix build .#<attr></code>. In the example above, if you wanted to build the <code>packages.x86_64-linux.hello</code> attribute, run: | Running <code>nix build</code> will look in the <code>legacyPackages</code> and <code>packages</code> output attributes for the corresponding [[derivations|derivation]] and then your system architecture and build the default output. If you want to specify a build attribute in a flake repository, you can run <code>nix build .#<attr></code>. In the example above, if you wanted to build the <code>packages.x86_64-linux.hello</code> attribute, run: | ||
</div> | </div> | ||
| Line 311: | Line 313: | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
The output schema is described the [https://nix.dev/manual/nix/2.33/command-ref/new-cli/nix3-flake-check.html#evaluation-checks nix flake check manual page]. | |||
</div> | </div> | ||
| Line 408: | Line 410: | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
* <code>builtins.currentSystem</code> is non-hermetic and impure as it reflects the host system performing the | * <code>builtins.currentSystem</code> is non-hermetic and impure as it reflects the host system performing the evaluation. This can usually be avoided by passing the system (i.e., x86_64-linux) explicitly to derivations requiring it. | ||
</div> | </div> | ||