Flakes: Difference between revisions

imported>Erikarvstedt
m Add `devShell` to example flake outputs
imported>Erikarvstedt
Add "extra command" installation option
Line 23: Line 23:
== Installing flakes ==
== Installing flakes ==


Currently flakes are available only in the '''unstable''' version of Nix and so they need to be explicitly enabled inside '''nix.conf'''.
Currently flakes are available only in the '''unstable''' version of Nix and need to be explicitly enabled inside '''nix.conf'''.


=== NixOS ===
=== NixOS ===
In NixOS this can be achieved with the following options in <code>configuration.nix</code>
In NixOS this can be achieved with the following options in <code>configuration.nix</code>.


===== System-wide installation =====
<syntaxHighlight lang=nix>
<syntaxHighlight lang=nix>
{ pkgs, ... }: {
{ pkgs, ... }: {
Line 36: Line 37:
     '';
     '';
   };
   };
}
</syntaxHighlight>
===== Installation as an extra command =====
Add command <code>nixFlakes</code> that serves as a flakes-enabled alias to the <code>nix</code> command.
<syntaxHighlight lang=nix>
{ pkgs, ... }: {
  environment.systemPackages = [
    (pkgs.writeScriptBin "nixFlakes" ''
      exec ${pkgs.nixFlakes}/bin/nix --experimental-features "nix-command flakes" "$@"
    '')
  ];
}
}
</syntaxHighlight>
</syntaxHighlight>