Announcing nixpkgs-unfree

Updated at
Feb 4, 2022 5:16 PM
Published at
February 4, 2022

Recently I was saying that we should avoid creating too many instances of nixpkgs. Either accept an argument or use the flake follows feature:

1000 instances of nixpkgs

There is just one problem with this claim; what if you need to access unfree packages? For example, try running:

$ nix run nixpkgs#slack

error: Package ‘slack-4.22.0’ in /nix/store/fbcgjqs34vllzzppa1y213fbxx01sxn7-source/pkgs/applications/networking/instant-messengers/slack/default.nix:83 has an unfree license (‘unfree’), refusing to evaluate.

       a) To temporarily allow unfree packages, you can use an environment variable
          for a single invocation of the nix tools.

            $ export NIXPKGS_ALLOW_UNFREE=1

       b) For `nixos-rebuild` you can set
         { nixpkgs.config.allowUnfree = true; }
       in configuration.nix to override this.

       Alternatively you can configure a predicate to allow specific packages:
         { nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [

       c) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
         { allowUnfree = true; }
       to ~/.config/nixpkgs/config.nix.
(use '--show-trace' to show detailed location information)


This whole error message is misleading. All the solutions proposed don’t work when using Flakes because Flakes evaluation is pure and doesn’t take your environment variables or config into account.

In order to fix that problem, allow me to introduce a new project:

It’s a small wrapper to nixpkgs with allowUnfree = true; enabled. I know I said not to create new instances of nixpkgs, but that’s the last one I promise 🙂

So now with that, you can run:

$ nix run --no-write-lock-file github:numtide/nixpkgs-unfree#slack

It’s also usable as a flake, so you can point nixpkgs to it:

  inputs.nixpkgs.url = "github:numtide/nixpkgs-unfree";

In the future, I also want to also keep the channels synchronized with nixpkgs so you can run nix run github:numtide/nixpkgs-unfree/<channel>. And potentially provide a binary cache for it.

That’s it for now, have a great weekend!


If you want to comment on the article, head over to the NixOS Discourse:

Addendum: how many instances of allowUnfree are there on GitHub?

Thanks to @tazjin for pointing me to a more usable code search:

At the time of writing, there are 218 results.