Flakes vs Unfree Attributes

I’m trying to run an unfree application using the nixpkgs flake and there seems to be no way to do it, because all the ways to “configure” nixpkgs to allow evaluating unfree attributes are impurities that are ignored:

❯ NIXPKGS_ALLOW_UNFREE=1 nix run nixpkgs#zoom-us  
error: Package ‘zoom-5.10.6.3192’ in /nix/store/nbph6bdglyhaid9cfbwiwby0fpy6ga6y-source/pkgs/applications/networking/instant-messengers/zoom-us/default.nix:185 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

        Note: For `nix shell`, `nix build`, `nix develop` or any other Nix 2.4+
        (Flake) command, `--impure` must be passed in order to read this
        environment variable.

       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) [
             "zoom"
           ];
         }

       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)

Does anyone know how this is intended to be used?

With flakes you also need to use --impure to weaken the self containment.

That makes the command to run NIXPKGS_ALLOW_UNFREE=1 nix run --impure nixpkgs#zoom-us

2 Likes

In case you forget, the message also tells you that very explicitly:

Amusingly, your question contained its own answer :slight_smile: