Unfree software: Difference between revisions

From NixOS Wiki
imported>GetPsyched
m Typo in commit
Sdht0 (talk | contribs)
General improvements
Line 1: Line 1:
Hydra does not test or build unfree software by policy. Most unfree licenses have restrictions on software distribution.


=== Per-package (Ideal) ===
=== Per-package (Ideal) ===
This method works for NixOS system level configuration and Home-Manager standalone
This method works for NixOS system level configuration and Home-Manager standalone
<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
{lib, ...}: {
{lib, ...}: {
Line 11: Line 13:
}
}
</syntaxhighlight>
</syntaxhighlight>
=== For all packages ===
=== For all packages ===


This method works for NixOS system-level configuration:
This method works for NixOS system-level configuration:


<syntaxhighlight lang="nix">
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
{
{
   nixpkgs.config.allowUnfree = true;
   nixpkgs.config.allowUnfree = true;
}
}
</syntaxhighlight>
</nowiki>}}
 
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">
{
  nixpkgs.config.allowUnfreePredicate = _: true;
}
</syntaxhighlight>


=== Command Line ===
=== Command Line ===


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):
You won't be able to install or search for an unfree package as a user unless you explicitly enable it:


<syntaxhighlight lang="nix">
{{file|~/.config/nixpkgs/config.nix|nix|<nowiki>
{
{
   allowUnfree = true;
   nixpkgs.config.allowUnfree = true;
}
}
</syntaxhighlight>
</nowiki>}}


=== Temporary allowing ===


=== Temporary allowing ===
For temporary allowing unfree packages, you can use an environment variable:


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 -p vscode
</syntaxhighlight>


<syntaxhighlight lang="bash">$ NIXPKGS_ALLOW_UNFREE=1 nix-shell</syntaxhighlight>
Note for the new nix3-style commands, you need to pass <code>--impure</code> as well:


Note for nix3 commands you need to pass <code>--impure</code> as well
<syntaxhighlight lang="bash">
$ NIXPKGS_ALLOW_UNFREE=1 nix run --impure "nixpkgs#vscode"
</syntaxhighlight>


=== More precision ===
=== More precision ===
Line 53: Line 53:
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.
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.

Revision as of 18:25, 6 April 2024

Hydra does not test or build unfree software by policy. Most unfree licenses have restrictions on software distribution.

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 works for NixOS system-level configuration:

/etc/nixos/configuration.nix
{
  nixpkgs.config.allowUnfree = true;
}

Command Line

You won't be able to install or search for an unfree package as a user unless you explicitly enable it:

~/.config/nixpkgs/config.nix
{
  nixpkgs.config.allowUnfree = true;
}

Temporary allowing

For temporary allowing unfree packages, you can use an environment variable:

$ NIXPKGS_ALLOW_UNFREE=1 nix-shell -p vscode

Note for the new nix3-style commands, you need to pass --impure as well:

$ NIXPKGS_ALLOW_UNFREE=1 nix run --impure "nixpkgs#vscode"

More precision

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