Running Unfree Packages in Nix Flake Shells
When you have Nix Flakes enabled, trying to
run unfree packages (packages with proprietary code) in the terminal with
nix shell
or nix run
, it will result in an error.
The error will helpfully point out that setting the NIXPKGS_ALLOW_UNFREE=1
environment variable will fix this.
Only it doesn’t actually work. The reason is that Flake packages are evaluated in a pure environment by default, which doesn’t get access to the shell environment variables.
To fix this, one must supply the --impure
flag to the command.
This will work just fine:
NIXPKGS_ALLOW_UNFREE=1 nix run --impure nixpkgs#cloud-sql-proxy