default.nix: Add configOverride argument
This should make it easier to provide a custom config argument. Previously to allow unfree hackage packages you had to do the following:
nixpkgs = import haskell-nix.sources.nixpkgs
( haskell-nix.nixpkgsArgs
// { config = haskell-nix.nixpkgsArgs.config
// { allowUnfree = true; };
}
);
Now you can simply provide { allowUnfree = true; } as the
configOverride argument when importing haskell.nix.
Motivation
Recently a user came to #haskell.nix asking how to allow unfree packages. While most packages on hackage have a free license, some have no license specified or were migrated from cabal's old license identifiers to "LicenseRef-..." SPDX identifiers. A package that used to have license identifier "LGPL" and has been migrated to the SPDX identifiers automatically without being revised since is deemed unfree by haskell.nix. This is the proper behavior because the meaning of a "LicenseRef-..." identifier is entirely arbitrary and up to the user.
As you can see above the incantation to pass config to the haskell.nix "nixpkgs" isn't very intuitive. This PR is only a suggestion of how to provide a more convenient UX in this. I'm not sure adding an argument that'll get merged in the right places later is very robust but I don't know of a better way so I wanted to start a discussion on how this can be improved.
I'm not sure how I feel about this. The current approach is dumb, yes, but it's also very straightforward. nixpkgsArgs is just an attribute set, containing just the normal nixpkgs arguments. Changing bits of it is just fiddling with attribute sets.
So I'm not wild about adding a second way of doing this. It's already hard enough to figure out how to do things: adding more helpers doesn't necessarily help (we have, if anything, too many functions of unclear purpose lying around already!). I think we'd be better served by explaining what nixpkgsArgs is more carefully.
I think straightforward's not the right word. You really have to look at the code to figure this out, which is a difficult step for many beginners. The argument list is as far as some get.
I don't really like adding an argument for each thing that someone might possibly want to alter in the future but I'm not sure of better solutions. Nix modules may be too heavy a tool but they do make it possible to only change a single option deep in an attrset. My first idea was passing in an overlay but having to manually access and merge the existing arguments in is precisely where the UX is lacking and an overlay doesn't fix this.
Imo, better documentation is surely something to work towards but it's not a solution. Friction in the UX can be alleviated with documentation but not fixed. For example, if the docs had an example of this exact problem, allowing unfree packages (and maybe they should since it might pop up again), the user could then simply copy and paste it into place but it's still 5 lines to understand every time you look at the Nix expression, rather than just "import haskell.nix { config = { allowUnfree = true;}; }"
A package that used to have license identifier "LGPL" and has been migrated to the SPDX identifiers automatically without being revised since is deemed unfree by haskell.nix.
Check the license file in the package itself to determine the correct LGPL version (you might need to diff the file as I don't think the version number is in the file). Then submit a PR to add it here:
https://github.com/input-output-hk/haskell.nix/blob/4b8dd307d75f7565f29876d3cb52c3bda4601e08/modules/configuration-nix.nix#L23-L28
@hamishmack, I actually contacted upstream and they were very responsive and willing to update the SPDX identifier. But unfree licensing is hardly the only time someone might want to pass config arguments.