15 Sep 2025 |
bglgwyng | Can we override argument passed to cabal2nix result with haskellPackages.override ? For example, if I want to replace native zlib used by haskell package zlib, I can use overrideCabal to modify librarySystemDepends . However, is it possible to just override the value passed to cabal2nix, which is a lambda with arguments { mkDervation, base, ..., zlib} ? | 03:38:50 |
Alex | In reply to @bglgwyng:matrix.org Can we override argument passed to cabal2nix result with haskellPackages.override ? For example, if I want to replace native zlib used by haskell package zlib, I can use overrideCabal to modify librarySystemDepends . However, is it possible to just override the value passed to cabal2nix, which is a lambda with arguments { mkDervation, base, ..., zlib} ? cabal2nix produces a Nix script. If you mean overriding what gets passed to that script when you use callCabal2nix or callPackage then the answer is yes: put it in the attrset argument. | 03:44:27 |
Alex | overrideCabal also works as with any other Haskell package because cabal2nix uses the same builder. | 03:46:00 |
bglgwyng | Yes. but haskellPackages.override { overrides = self: super: zlib = super.zlib.override { zlib = my-zlib}} doesn't work, since super.zlib is not the lambda argument, but the result of callPackages . So it's late. | 03:54:48 |
bglgwyng | From my understanding, when we use nixpkgs haskellPackages | 03:55:27 |
bglgwyng | * From my understanding, when we use nixpkgs's haskellPackages , we usually deal with the result of callPackage cabal2nix-lambda rather than cabal2nix-lambda itself? | 03:56:00 |
bglgwyng | {
"zlib" = callPackage
({ mkDerivation, base, bytestring, QuickCheck, tasty
, tasty-quickcheck, zlib
}:
mkDerivation {
pname = "zlib";
version = "0.6.3.0";
sha256 = "1nh4xsm3kgsg76jmkcphvy7hhslg9hx1s75mpsskhi2ksjd9ialy";
revision = "5";
editedCabalFile = "0mj3f7ql54p0pfa5a6q4xv4ci8xf00616ls0nyadpmlqbb4qilwn";
libraryHaskellDepends = [ base bytestring ];
librarySystemDepends = [ zlib ];
testHaskellDepends = [
base bytestring QuickCheck tasty tasty-quickcheck
];
description = "Compression and decompression in the gzip and zlib formats";
license = lib.licenses.bsd3;
}) {inherit (pkgs) zlib;};
}
this is from hackage-pacakges.nix, and I'm not sure if I have any chance to override zlib when callPackage is already called.
| 03:57:11 |
Alex | So you want to be able to e.g. add extra arguments to the cabal2nix command?
IIRC that's possible with callCabal2nix and obviously if you implement the command yourself.
Overriding is trickier but should still be possible through overriding callCabal2nix (this isn't pretty).
I'm having trouble understanding why overriding the result is insufficient in your case. | 04:02:48 |
bglgwyng | Hmm, I tried such a thing splitmix = super.splitmix.override { testu01 = null; }; but it didn't work. | 04:06:32 |
bglgwyng | splitmix's definition is like
"splitmix" = callPackage
({ mkDerivation, async, base, ..., testu-01 }:
mkDerivation {
| 04:07:13 |
bglgwyng | To provide the context, I'm not using the vanilla haskellPackages , but the generated one for my purpose. | 04:08:38 |
bglgwyng | I was trying to handle "error: function 'anonymous lambda' called without required argument 'testu01'" this error message, by passing testu01 = null just like hackage-packages.nix does. | 04:09:24 |
bglgwyng | Of course I can do it with the cabal2nix expression, but I was wondering if I can do the same thing when callPackage is already applied. | 04:10:09 |
bglgwyng | If any approach simliar to splitmix = super.splitmix.override { testu01 = null; } is possible, it would be really helpful. | 04:10:53 |
bglgwyng | ah maybe I made a stupid mistake | 04:16:01 |
bglgwyng | it seems that the result of callCabal2Nix is not overridable, and I should wrap it manullay to make it overridable. | 04:16:42 |
bglgwyng | Yes, the vanilla pkgs.haskellPackages.* things are overridable and my callCabal2Nix results are not overridable. And I just found that make-package-set applies makeOverridable manullay. | 04:19:02 |
Alex | In reply to @bglgwyng:matrix.org it seems that the result of callCabal2Nix is not overridable, and I should wrap it manullay to make it overridable. At the very least, most of the functions from haskell.lib and haskell.lib.compose should be able to override it (try looking at how they do it?)
That is, unless you use things like buildFromSdist which IIRC prevent further overrides because of how they work. | 10:56:42 |
sterni | Seems like MicroHs is getting more serious about being usable for general purpose stuff, could maybe be interesting to try and add a microhs package set for variety. https://discourse.haskell.org/t/microhs-and-hackage/12916. However, the approach Lennart is taking is a bit questionable. For packages that don't accept MicroHs patches, MicroCabal automatically replaces them with an entirely different package (e.g. random-mhs instead of random). The package descriptions seem to rely on this as well, e.g. you can't build the random-mhs test suite with GHC/Cabal since it declares a dependency on random instead of random-mhs (though maybe that's just a mistake). | 12:23:43 |
emily | we talked about this recently and I suggested a package set would be interesting for exploring future GHC bootstrap | 12:26:04 |
emily | especially since we can have MicroHs bootstrap from hugs | 12:26:15 |
emily | @alex:tunstall.xyz has that Nixified apparently | 12:26:28 |
sterni | should be testu-01, not testu01 from your example? | 12:26:50 |
sterni | bglgwyng: override allows you to use the result of callPackage and call the underlying lambda again with different argument, completely recomputing the value: https://github.com/NixOS/nixpkgs/blob/f501ecd2f4b1b8c4f43fee3f1d5cf3e758c2e166/lib/customisation.nix#L116-L208 | 12:28:43 |
sterni | You can of course not change the underlying function. I'm not entirely sure what you are trying to do. | 12:29:10 |
Alex | Sure, I can contribute a package set later this week.
There might be a fair bit of flux from frequent upstream changes, but I doubt that'll be much of an issue. | 12:53:41 |
emily | why does it need its own Cabal btw? | 12:56:19 |
emily | is real Cabal not flexible enough? can't build with MicroHs? | 12:56:28 |
chreekat | Yeah it relies on many language extensions that Lennart doesn't plan to support | 12:58:13 |
emily | this is my fear with the GHC bootstrapping plan... | 13:00:07 |