Jump to content

Unfree software: Difference between revisions

From NixOS Wiki
Frontear (talk | contribs)
m clarify description about configuring nixpkgs
DoggoBit (talk | contribs)
m Standalone Home Manager: Fix nowiki tag
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
Unfree software refers to software that has restrictive licensing on modification and/or redistribution. These types of software cannot be freely provided or distributed in an official capacity, which means that they are neither built by [[Hydra]], nor as they cached on the official [[Binary Cache|binary cache]]. Despite this, Nixpkgs offers a very large collection of unfree software as derivations, however they cannot be used by default without configuring Nixpkgs and opting in to unfree software usage.
{{expansion}}


== Configuring ==
Unfree software refers to software that has restrictive licensing on modification and/or redistribution. This type of software cannot be freely provided or distributed in an official capacity, which means that unfree software is neither built by [[Hydra]], nor cached on the official [[Binary Cache|binary cache]]. Despite this, Nixpkgs offers a very large collection of unfree software as derivations, however they cannot be used by default without configuring Nixpkgs and opting in to unfree software usage.


=== For NixOS ===
[https://nixos.org/manual/nixpkgs/stable/#sec-allow-unfree Nixpkgs manual on allowing unfree packages]
[[NixOS]] offers a module that can configure Nixpkgs, which will retroactively change the pkgs across your configuration to use the new settings, including allowing for unfree packages.<syntaxhighlight lang="nixos">
{ config, lib, pkgs, ... }: {
  nixpkgs.config.allowUnfree = true; # Allows all packages that are marked unfree to be built.


  environment.systemPackages = with pkgs; [
== Allowing unfree software ==
    steam # No error!
By default, nix will refuse to evaluate any [[Derivations|derivation]] containing unfree software, prompting the user to read the manual for more details. This behaviour can be configured in different ways depending on the context of the derivation.
  ];
}
</syntaxhighlight>You may instead configure this on a per-package basis via <code>allowUnfreePredicate</code>.
{{Note|Please note that this function has awkward semantics and occasionally doesn't work as expected. Issues like this should be raised directly in [https://github.com/NixOS/nixpkgs/issues Nixpkgs].}}<syntaxhighlight lang="nixos">
{ config, lib, pkgs, ... }: {
  # Add packages by their "derivation name" here.
  # Find the derivation name from https://search.nixos.org/
  nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
    "steam"
  ];
}
</syntaxhighlight>


=== For Nix CLI ===
=== Unfree software using Home Manager ===
As you may have noticed, the above configuration does not apply globally to your NixOS system (and is not applicable for non-NixOS users). Instead, you can configure Nixpkgs at a user level by writing your configuration in <code>~/.config/nixpkgs/config.nix</code>.
Depending on your [[Home Manager]] installation, there are multiple ways to allow unfree software.
{{Note|This file is ignored using nix3 commands, leaving you with the environment variable technique as the easiest resort.}}{{file|~/.config/nixpkgs/config.nix|nix|3={
  allowUnfree = true;
<nowiki>}</nowiki>}}You can alternatively set the environment variable <code>NIXPKGS_ALLOW_UNFREE=1</code>, which is automatically picked up by the Nix CLI. For newer nix3 commands, you will need to additionally pass <code>--impure</code>, otherwise the environment variable is ignored.<syntaxhighlight lang="bash">
$ export NIXPKGS_ALLOW_UNFREE=1
$ nix-shell -p vscode --command 'code' # nix-legacy
$ nix run --impure nixpkgs#vscode # nix3
</syntaxhighlight>
 
== See also ==
 
* [https://nixos.org/nixpkgs/manual/#sec-allow-unfree Nixpkgs manual on allowing unfree packages]


==== Standalone Home Manager ====
If your Home Manager configuration isn't integrated into your [[NixOS]] configuration (i.e. you switch generations using <code>home-manager switch</code> and not by rebuilding the whole system), then you may allow unfree software by setting the nixpkgs option in your config:
{{File|3=<nowiki>{ ... }:
{
  ...
  nixpkgs.config.allowUnfree = true;
}</nowiki>|name=home.nix|lang=nix}}
[[Category:Software]]
[[Category:Software]]
[[Category:Nixpkgs]]
[[Category:Nixpkgs]]

Latest revision as of 16:36, 14 June 2025

☶︎
This article or section needs to be expanded. Further information may be found in the related discussion page. Please consult the pedia article metapage for guidelines on contributing.

Unfree software refers to software that has restrictive licensing on modification and/or redistribution. This type of software cannot be freely provided or distributed in an official capacity, which means that unfree software is neither built by Hydra, nor cached on the official binary cache. Despite this, Nixpkgs offers a very large collection of unfree software as derivations, however they cannot be used by default without configuring Nixpkgs and opting in to unfree software usage.

Nixpkgs manual on allowing unfree packages

Allowing unfree software

By default, nix will refuse to evaluate any derivation containing unfree software, prompting the user to read the manual for more details. This behaviour can be configured in different ways depending on the context of the derivation.

Unfree software using Home Manager

Depending on your Home Manager installation, there are multiple ways to allow unfree software.

Standalone Home Manager

If your Home Manager configuration isn't integrated into your NixOS configuration (i.e. you switch generations using home-manager switch and not by rebuilding the whole system), then you may allow unfree software by setting the nixpkgs option in your config:

❄︎ home.nix
{ ... }:
{
  ...
  nixpkgs.config.allowUnfree = true;
}