Flakes: Difference between revisions
imported>Ajs124 update config for system-wide install and drop separate command |
imported>Fricklerhandwerk update installation methods |
||
Line 35: | Line 35: | ||
Flakes replace the nix-channels command and things like ad-hoc invocations of <code>builtins.fetchgit</code> - no more worrying about keeping your channels in sync, no more worrying about forgetting about a dependency deep down in your tree: everything's at hand right inside <code>flake.lock</code>. | Flakes replace the nix-channels command and things like ad-hoc invocations of <code>builtins.fetchgit</code> - no more worrying about keeping your channels in sync, no more worrying about forgetting about a dependency deep down in your tree: everything's at hand right inside <code>flake.lock</code>. | ||
== | == Using flakes == | ||
== | Flakes have been introduced with Nix 2.4 ([https://nixos.org/manual/nix/unstable/release-notes/rl-2.4.html release notes]). | ||
See [https://lazamar.co.uk/nix-versions/?channel=nixpkgs-unstable&package=nix Nix package versions] to find a channel or <code>nixpkgs</code> revision providing the required Nix version. | |||
==== | ===Temporary=== | ||
Add <code>--experimental-features 'nix-command flakes'</code> when calling the <code>nix</code> command. | |||
=== Permanent === | |||
Edit either <code>~/.config/nix/nix.conf</code> or <code>/etc/nix/nix.conf</code> and add: | Edit either <code>~/.config/nix/nix.conf</code> or <code>/etc/nix/nix.conf</code> and add: | ||
Line 60: | Line 53: | ||
</syntaxHighlight> | </syntaxHighlight> | ||
If the Nix installation is in multi-user mode, don’t forget to restart the <code>nix-daemon</code>. | |||
=== NixOS === | |||
On NixOS set the following options in <code>configuration.nix</code> and run <code>nixos-rebuild</code>. | |||
<syntaxHighlight lang=nix> | |||
{ pkgs, ... }: { | |||
nix.settings.experimental-features = [ "nix-command" "flakes" ]; | |||
} | |||
</syntaxHighlight> | |||
== Basic project usage == | == Basic project usage == |