Flakes: Difference between revisions

imported>Jtbx
m Clarify
imported>Hypnosis2839
Enable unfree software: point to dedicated wiki page
Line 569: Line 569:
== Enable unfree software ==
== Enable unfree software ==


Because flake evalutations are hermetic, they will ignore the system configuration on nonfree software and the <code>NIXPKGS_ALLOW_UNFREE</code> environment variable by default.
Refer to [[Unfree Software]].
 
To use nonfree software with CLI tools like <code>nix shell</code> or <code>nix run</code>, the <code>--impure</code> flag must be used for Nixpkgs to access the current environment variables:
<syntaxHighlight lang=console>
$ NIXPKGS_ALLOW_UNFREE=1 nix run --impure nixpkgs#discord
</syntaxHighlight>
 
To use nonfree software in a flake, add <code>nixpkgs</code> as an input in your flake and import it with the <code>allowUnfree</code> option:
<syntaxHighlight lang=nix>
pkgs = import nixpkgs {
  system = "x86_64-linux";  # or something else
  config = { allowUnfree = true; };
};
</syntaxHighlight>
 
=== Enable unfree software in home-manager ===
 
If you want to install software using home-manager via nix flakes in non NixOS systems (like darwin) you can use the home-manager <code>nixpkgs.config</code> option for example
 
<syntaxHighlight lang=nix>
nixpkgs.config.allowUnfree = true;
</syntaxHighlight>


== Development tricks ==
== Development tricks ==