Unfree software: Difference between revisions

From NixOS Wiki
imported>GetPsyched
m (Typo in commit)
m (Tomodachi94 moved page Unfree Software to Unfree software: use sentance case)
 
(10 intermediate revisions by 5 users not shown)
Line 1: Line 1:
'''Unfree software''', sometimes called '''nonfree software''', is software that cannot be freely modified or distributed. [[Nixpkgs]] provides packages for unfree software, but additional configuration is required before they can be used.


=== Per-package (Ideal) ===
== Using unfree packages ==
This method works for NixOS system level configuration and Home-Manager standalone
=== Per-package (preferred) ===
<syntaxhighlight lang="nix">
This method works for both NixOS system level configuration and [[Home Manager]]:
{lib, ...}: {
 
   nixpkgs.config.allowUnfreePredicate = pkg:
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
    builtins.elem (lib.getName pkg) [
{
      # Add additional package names here
   nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
      "hello-unfree"
    "vscode"
    ];
  ];
}
}
</syntaxhighlight>
 
</nowiki>}}
 
=== For all packages ===
=== For all packages ===


This method works for NixOS system-level configuration:
This method works for both NixOS system level configuration and [[Home Manager]]:


<syntaxhighlight lang="nix">
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
{
{
   nixpkgs.config.allowUnfree = true;
   nixpkgs.config.allowUnfree = true;
}
}
</syntaxhighlight>
</nowiki>}}
 
=== Command line ===


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:
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>
{
{
   nixpkgs.config.allowUnfreePredicate = _: true;
   allowUnfree = true;
}
}
</syntaxhighlight>
</nowiki>}}


=== Command Line ===
=== Temporarily allowing ===


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):
For temporary allowing unfree packages, you can use an environment variable:


<syntaxhighlight lang="nix">
<syntaxhighlight lang="bash">
{
$ NIXPKGS_ALLOW_UNFREE=1 nix-shell -p vscode
  allowUnfree = true;
}
</syntaxhighlight>
</syntaxhighlight>


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


=== Temporary allowing ===
<syntaxhighlight lang="bash">
 
$ NIXPKGS_ALLOW_UNFREE=1 nix run nixpkgs#vscode --impure
For temporary allowing unfree packages you can set the environment variable <code>NIXPKGS_ALLOW_UNFREE</code>, e.g.
</syntaxhighlight>


<syntaxhighlight lang="bash">$ NIXPKGS_ALLOW_UNFREE=1 nix-shell</syntaxhighlight>
== Hydra ==


Note for nix3 commands you need to pass <code>--impure</code> as well
[[Hydra]] does not build unfree software, and unfree software is unavailable in <code>cache.nixos.org</code>.


=== More precision ===
== See also ==


For whitelisting '''only specific''' unfree licenses
* [https://nixos.org/nixpkgs/manual/#sec-allow-unfree Nixpkgs manual on allowing unfree packages]
see the [https://nixos.org/nixpkgs/manual/#sec-allow-unfree "Installing unfree packages" section]
of the Nixpkgs manual.


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

Latest revision as of 05:59, 21 June 2024

Unfree software, sometimes called nonfree software, is software that cannot be freely modified or distributed. Nixpkgs provides packages for unfree software, but additional configuration is required before they can be used.

Using unfree packages

Per-package (preferred)

This method works for both NixOS system level configuration and Home Manager:

/etc/nixos/configuration.nix
{
  nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
    "vscode"
  ];
}

For all packages

This method works for both NixOS system level configuration and Home Manager:

/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
{
  allowUnfree = true;
}

Temporarily 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 nixpkgs#vscode --impure

Hydra

Hydra does not build unfree software, and unfree software is unavailable in cache.nixos.org.

See also