Unfree software
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. 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.
Configuring
For NixOS
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.
{ config, lib, pkgs, ... }: {
nixpkgs.config.allowUnfree = true; # Allows all packages that are marked unfree to be built.
environment.systemPackages = with pkgs; [
steam # No error!
];
}
You may instead configure this on a per-package basis via allowUnfreePredicate
.
{ 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"
];
}
For Nix CLI
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 ~/.config/nixpkgs/config.nix
.
~/.config/nixpkgs/config.nix
{
allowUnfree = true;
}
You can alternatively set the environment variable NIXPKGS_ALLOW_UNFREE=1
, which is automatically picked up by the Nix CLI. For newer nix3 commands, you will need to additionally pass --impure
, otherwise the environment variable is ignored.
$ export NIXPKGS_ALLOW_UNFREE=1
$ nix-shell -p vscode --command 'code' # nix-legacy
$ nix run --impure nixpkgs#vscode # nix3