This is more of a feature request than a real bug.
When trying to install the unfree package nixpkgs.vscode, I get quite a lengthy error message:
installing 'vscode-1.55.2'
error: while evaluating the attribute 'handled' at /nix/store/71n8j6r19b5xm5aagcva1qc2i0pgbaf4-nixpkgs-21.05pre286574.219cbedb694/nixpkgs/pkgs/stdenv/generic/check-meta.nix:301:7:
while evaluating 'handleEvalIssue' at /nix/store/71n8j6r19b5xm5aagcva1qc2i0pgbaf4-nixpkgs-21.05pre286574.219cbedb694/nixpkgs/pkgs/stdenv/generic/check-meta.nix:188:38, called from /nix/store/71n8j6r19b5xm5aagcva1qc2i0pgbaf4-nixpkgs-21.05pre286574.219cbedb694/nixpkgs/pkgs/stdenv/generic/check-meta.nix:302:14:
Package ‘vscode-1.55.2’ in /nix/store/71n8j6r19b5xm5aagcva1qc2i0pgbaf4-nixpkgs-21.05pre286574.219cbedb694/nixpkgs/pkgs/applications/editors/vscode/vscode.nix:44 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) [
"vscode"
];
}
c) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
{ allowUnfree = true; }
to ~/.config/nixpkgs/config.nix.
Traceback (most recent call last):
File "/nix/store/jh8k6qajpxxvcivrhhwqqqv363jm0hg9-nox-0.0.6/bin/.nox-wrapped", line 9, in <module>
sys.exit(main())
File "/nix/store/diazka9p575lw1vxy3x39xcjqpq74gp2-python3.8-click-7.1.2/lib/python3.8/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/nix/store/diazka9p575lw1vxy3x39xcjqpq74gp2-python3.8-click-7.1.2/lib/python3.8/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/nix/store/diazka9p575lw1vxy3x39xcjqpq74gp2-python3.8-click-7.1.2/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/nix/store/diazka9p575lw1vxy3x39xcjqpq74gp2-python3.8-click-7.1.2/lib/python3.8/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/nix/store/jh8k6qajpxxvcivrhhwqqqv363jm0hg9-nox-0.0.6/lib/python3.8/site-packages/nox/search.py", line 91, in main
subprocess.check_call(['nix-env', '-iA', '--show-trace'] + attributes)
File "/nix/store/q6gfck5czr67090pwm53xrdyhpg6bx67-python3-3.8.9/lib/python3.8/subprocess.py", line 364, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['nix-env', '-iA', '--show-trace', 'nixpkgs.vscode']' returned non-zero exit status 1.
It is of course possible to just run the command again like NIXPKGS_ALLOW_UNFREE=1 nox vscode.
A nicer fix would be to exit gracefully instead of with a length python traceback.
But considering the interactive nature of nox, the ideal solution would probably be to detect the message from nix-env and give the user the option to
not install the package
allow unfree packages temporarily
allow unfree packages permanently by adding { allowUnfree = true; } to ~/.config/nixpkgs/config.nix
This is more of a feature request than a real bug.
When trying to install the unfree package
nixpkgs.vscode
, I get quite a lengthy error message:It is of course possible to just run the command again like
NIXPKGS_ALLOW_UNFREE=1 nox vscode
. A nicer fix would be to exit gracefully instead of with a length python traceback.But considering the interactive nature of nox, the ideal solution would probably be to detect the message from
nix-env
and give the user the option to{ allowUnfree = true; }
to~/.config/nixpkgs/config.nix