I reviewed multiple discussions and other sources about allowUnfree
, but they were mostly focused on Home Manager or NixOS, and the proper way to propagate the the option through your configs.
However, I found no solution for the case in which I’d like to use an external flake, that declares a package license as not free, but it doesn’t expose a facility similar to HM useGlobalPkgs.
To make it concrete, consider this two flakes:
# flake.nix
{
inputs = {
dep.url = "path:./dep";
};
outputs = {
self,
dep,
}: {
packages.x86_64-linux.default = dep.packages.x86_64-linux.default;
};
}
and
# dep/flake.nix
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
};
outputs = {
self,
nixpkgs,
}: let
# pkgs = import nixpkgs {
# system = "x86_64-linux";
# config.allowUnfree = true;
# };
pkgs = nixpkgs.legacyPackages.x86_64-linux;
in {
packages.x86_64-linux = {
default = pkgs.hello.overrideAttrs (final: prev: {meta.license.free = false;});
};
};
}
and then run nix build .
in the folder of flake.nix
.
Obviously, swapping the definition of pkgs
with the commented one in the dependency flake solves the issue. But the second flake should be the one written by someone else, so it’s not really possible to modify it (nor it would make sense, since the allowUnfree
should be a choice of the end user).