New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add pkgs.haskell.lib.packagesFromDirectory
utility
#42923
Conversation
This adds a `readDirectory` utility that can be used to "slurp" a directory full of `cabal2nix`-generated files and transform them into a Haskell package override set. The main use of this is so that users don't have to write: ``` { overrides = self: super: { foo = self.callPackage ./path/to/foo.nix { }; bar = self.callPackage ./path/to/bar.nix { }; ... }; } ``` Instead, they can write: ``` { overrides = pkgs.haskell.lib.readDirectory ./path/to; } ``` This is a an alternative to `packageSourceOverrides` which primarily addresses the following use cases: * The desired package is not yet available in `all-cabal-hashes` (perhaps the user is pinned to an older revision of `nixpkgs`) * The default `cabal2nix` invocation used by `packageSourceOverrides` does not use the desired `cabal2nix` flags * The user wants to avoid the use of import-from-derivation
It'd be nice to ignore missing If you make the first parameter an attrset pattern, such functionality can be added in the future. Future example:
|
@roberth: It's lazy, so it will only attempt to read files if you try to access the corresponding attribute and ignore any other files However, I agree that it should probably take an attribute set as an argument for ease of extension later |
@Gabriel439 good point. I'm using a little hack to collect self-defined attributes in my overlay for |
... as suggested by @roberth
Not sure if |
... as suggested by @roberth
pkgs.haskell.lib.readDirectory
utilitypkgs.haskell.lib.packagesFromDirectory
utility
Add `...` for less painful downgrades in the future
I've added LGTM. Will merge in a couple of days unless anyone objects. |
Motivation for this change
This adds a
readDirectory
utility that can be used to "slurp" a directoryfull of
cabal2nix
-generated files and transform them into a Haskell packageoverride set. The main use of this is so that users don't have to write:
Instead, they can write:
This is a an alternative to
packageSourceOverrides
which primarily addressesthe following use cases:
all-cabal-hashes
(perhaps theuser is pinned to an older revision of
nixpkgs
)cabal2nix
invocation used bypackageSourceOverrides
does not use the desired
cabal2nix
flagsThings done
sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)nix path-info -S
before and after)