tldr: I can’t build flakes that depend on allowUnfree = true
Hello. Not sure if it relates to nix or nixpkgs, so posting here again.
For context, I’m trying to set up a development environment for my project using nix
with flakes. In particular, I intend to use the latter for 1) pinning versions of dependencies, 2) composing projects from different repos. Previously I used niv
in this project.
One of the dependencies I need is nixpkgs#python3Packages.pytorch-bin
which has an unfree license. The combination of niv
and nix-shell
/nix-build
respected the allowUnfree = true;
in my ~/.config/nixpkgs/config.nix
and worked fine. This is not so for flake-based nix build
which can’t rely on my system’s configuration and instead ensure hermetic builds. So, nix build
aborts with an error message about allowUnfree
. Further, running nix build nixpkgs#python3Packages.pytorch-bin
shuts down in the same manner.
From this point, however, I am not sure what am I supposed to do, as my goal is to describe
- a "flake with an output that only supports systems with
allowUnfree = true
" - a "flake that would refuse to build on systems with
allowUnfree = false
" - a "flake that depends on
nixpkgs
withconfig.allowUnfree = true
"?- in particular, taking
inputs.nixpkgs.url = "nixpkgs/nixos-20.09"
input and overridingallowUnfree
in its outputs wouldn’t work because some of inputs’ attributes are already evaluated withallowUnfree = false
- in particular, taking
I couldn’t find any options on marking flakes/flake outputs as unfree and atm couldn’t nix build
my project. It seems like allowUnfree
should really be a part of system
.
Aside: It’s also interesting that flakes don’t seem to have a notion of a license… Since flakes’ purpose is composition of different projects (I am still unsure I am not misunderstanding the goals and not taking the desired for reality) they probably relate to licensing and compatibility of licenses
Related:
- Another instance of
nix build
ignoring Nix flakes should not cache evaluation errors · Issue #3872 · NixOS/nix · GitHub - Why it is correct for
nix build
to ignore~/.config/nixpkgs/config.nix
: [flake]: provide builtins.currentSystem as a input to flakes · Issue #3843 · NixOS/nix · GitHub - The only other topic mentioning both “flakes” and "allowUnfree` I could find: https://discourse.nixos.org/t/only-one-nixpkgs-in-a-flake-input-can-allow-unfree/
Thanks