There’s no great solution to this currently. Meta checks (brokenness, licensing, …) are implemented as part of the stdenv
builder.
I.e., when nix evaluates your package, as part of the stdenv.mkDerivation
call, some code in nixpkgs will check if the package metadata says that the package is broken, and if so, it throws an error, which aborts evaluation.
All of the “please don’t do this” configuration parsing is therefore defined and implemented in nixpkgs directly - nix does not have a concept of licenses or broken packages. This in turn means that you somehow need to set this configuration in the nixpkgs config, rather than the nix config.
In theory, you could write config to ~/.config/nixpkgs/config.nix
, and checks will also try to read environment variables, but nix permits neither in flakes’ pure eval mode.
So we’re stuck. There’s no good first party support for this when using flakes.
The best you can do is import
the nixpkgs in question and set the config directly when you do so:
let
system = "x86_64-linux";
pkgs = import inputs.nixpkgs {
inherit system;
config = {
allowBroken = true;
};
};
This is an antipattern, but it’s the only way to do this for now.
If you use NixOS, home-manager or nix-darwin you can also use their nixpkgs config, which I’d recommend doing instead of the above when possible. This only applies to the nixpkgs whose lib.x
you called to make your config, though.
For unfree packages there is nixpkgs-unfree, but that’s just a crutch for the most common use case until there is first party support.
A proper solution is probably years off, nothing has been proposed yet and the current state of flakes will not even be stabilized anytime soon. Maybe the various forks will shake up the situation a bit.