Difference between revisions of "Unfree Software"

From NixOS Wiki
Jump to: navigation, search
(no reboot required for nixpkgs.config.allowUnfree = true;)
m (rollback unauthorized mass edits)
Tag: Rollback
 
(12 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{FAQ/breadcrumb}}{{#tweekihide:firstHeading}}<onlyinclude>
 
== How can I install a proprietary or unfree package? ==
 
  
=== Configuration for a user ===
+
=== Per-package (Ideal) ===
 +
This method works for NixOS system level configuration and Home-Manager standalone
 +
<syntaxhighlight lang="nix">
 +
{lib, ...}: {
 +
  nixpkgs.config.allowUnfreePredicate = pkg:
 +
    builtins.elem (lib.getName pkg) [
 +
      # Add additional package names here
 +
      "hello-unfree"
 +
    ];
 +
}
 +
</syntaxhighlight>
 +
=== For all packages ===
 +
 
 +
This method allows unfree for nix-rebuild for NixOS system-level configuration:
 +
 
 +
<syntaxhighlight lang="nix">
 +
{
 +
  nixpkgs.config.allowUnfree = true;
 +
}
 +
</syntaxhighlight>
 +
 
 +
To fix other commands like nix-shell, see [[#Command Line]]
  
You won't be able to install or search for an unfree package as a user, unless you explicitly enable it in ''~/.config/nixpkgs/config.nix'' (the file and folder may need to be created):
+
If you use standalone Home-Manager, and you are on the stable (23.05) branch or any commit before [https://github.com/nix-community/home-manager/commit/b2a2133c9a0b0aa4d06d72b5891275f263ee08df this commit], use the following instead:
  
 
<syntaxhighlight lang="nix">
 
<syntaxhighlight lang="nix">
 
{
 
{
   # [...]
+
   nixpkgs.config.allowUnfreePredicate = _: true;
  allowUnfree = true;
 
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
  
=== System-level configuration (NixOS) ===
+
=== Command Line ===
  
When using NixOS, it is possible to enable unfree for eg. <code>environment.systemPackages</code> with the following  setting in your <code>/etc/nixos/configuration.nix</code>:
+
You won't be able to install or search for an unfree package as a user, unless you explicitly enable it in <code>~/.config/nixpkgs/config.nix</code> (the file and folder may need to be created):
  
 
<syntaxhighlight lang="nix">
 
<syntaxhighlight lang="nix">
 
{
 
{
   # [...]
+
   allowUnfree = true;
  nixpkgs.config.allowUnfree = true;
 
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
'''Note that this alone will not allow you to search for or install packages with nix-env without the user configured.''' See the previous section. No reboot is required for unfree to take effect, however you need to run <code>nixos-rebuild switch</code> just like for all other changes to your systems <code>configuration.nix</code>
+
 
  
 
=== Temporary allowing ===
 
=== Temporary allowing ===
  
For temporary allowing unfree packages you can set the environment variable ''NIXPKGS_ALLOW_UNFREE'', e.g.
+
For temporary allowing unfree packages you can set the environment variable <code>NIXPKGS_ALLOW_UNFREE</code>, e.g.
 +
 
 +
<syntaxhighlight lang="bash">$ NIXPKGS_ALLOW_UNFREE=1 nix-shell</syntaxhighlight>
  
<syntaxhighlight lang="bash">NIXPKGS_ALLOW_UNFREE=1 nix-env</syntaxhighlight>
+
Note for nix3 commands you need to pass <code>--impure</code> as well
  
 
=== More precision ===
 
=== More precision ===
  
For whitelisting '''only specific''' unfree packages or unfree licenses
+
For whitelisting '''only specific''' unfree licenses
 
see the [https://nixos.org/nixpkgs/manual/#sec-allow-unfree "Installing unfree packages" section]
 
see the [https://nixos.org/nixpkgs/manual/#sec-allow-unfree "Installing unfree packages" section]
 
of the Nixpkgs manual.
 
of the Nixpkgs manual.
Line 40: Line 59:
 
due to policy. Most unfree licenses prohibit us from either executing or
 
due to policy. Most unfree licenses prohibit us from either executing or
 
distributing the software.
 
distributing the software.
</onlyinclude>
 

Latest revision as of 10:56, 6 April 2024

Per-package (Ideal)

This method works for NixOS system level configuration and Home-Manager standalone

{lib, ...}: {
  nixpkgs.config.allowUnfreePredicate = pkg:
    builtins.elem (lib.getName pkg) [
      # Add additional package names here
      "hello-unfree"
    ];
}

For all packages

This method allows unfree for nix-rebuild for NixOS system-level configuration:

{
  nixpkgs.config.allowUnfree = true;
}

To fix other commands like nix-shell, see #Command Line

If you use standalone Home-Manager, and you are on the stable (23.05) branch or any commit before this commit, use the following instead:

{
  nixpkgs.config.allowUnfreePredicate = _: true;
}

Command Line

You won't be able to install or search for an unfree package as a user, unless you explicitly enable it in ~/.config/nixpkgs/config.nix (the file and folder may need to be created):

{
  allowUnfree = true;
}


Temporary allowing

For temporary allowing unfree packages you can set the environment variable NIXPKGS_ALLOW_UNFREE, e.g.

$ NIXPKGS_ALLOW_UNFREE=1 nix-shell

Note for nix3 commands you need to pass --impure as well

More precision

For whitelisting only specific unfree licenses see the "Installing unfree packages" section of the Nixpkgs manual.

Note that we are not able to test or build unfree software on Hydra due to policy. Most unfree licenses prohibit us from either executing or distributing the software.