I’m trying to use nix flakes to package some development code and
provide the relevant development environment. However, one of the
python libraries I need uses mkl, and nix develop refuses to fully
evaluate because of this (as it’s unfree).
What then, should I do to enable the use of this unfree library in a
flake?
error: --- ThrownError -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- nix
Package ‘mkl-2020.1.217’ in /nix/store/2gvpjwk27dng6c6vw3q3dpfdbza91wmn-source/pkgs/development/libraries/science/math/mkl/default.nix:151 has an unfree license (‘issl’), refusing to evaluate.
a) For `nixos-rebuild` you can set
{ nixpkgs.config.allowUnfree = true; }
in configuration.nix to override this.
b) 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)
nix-shell with flake-compatibility works, however.
Flakes evaluations are pure and therefor don’t source configuration from the user’s home.
The issue is that when using nixpkgs.legacyPackages.x86_64-linux.mkl, that instance of nixpkgs has already been configured. Instead, try importing and constructing another instance of nixpkgs with allowUnfree = true; in the config.
Actually, I haven’t checked what it does with paths starting with ~/. But it’s not in the spirit of Flakes if it works.
One of the goals is to allow caching of evaluations, which requires to turn off sources of impurities. So builtins like builtins.currentTime, builtins.currentSystem, builtins.getEnv are also disabled or return default values.
One of the goals is to allow caching of evaluations, which requires to turn off sources of impurities. So builtins like builtins.currentTime , builtins.currentSystem , builtins.getEnv are also disabled or return default values.
I potentially care about more than one system type. I had been using
flake-utils and eachDefaultSystem. I ended up adding inherit system;
in the import nixpkgs... and it works.
Not something I am proud of but I prefer it to either using --impure or importing the pkgs with a proper config, I forked nixpkgs with allowUnfree in check-meta.nix that always returns true:
allowUnfree = config.allowUnfree or true
|| builtins.getEnv "NIXPKGS_ALLOW_UNFREE" == "1";
I found this post after hitting the same problem and searching on Google. If anyone else finds this in the future the below works for me. Note the inherit system in the nixpkgs argument