[Nix-dev] Modifying expressions generated by cabal2nix

Marc Weber marco-oweber at gmx.de
Sat Sep 17 23:56:37 CEST 2011


Excerpts from Alexander Tsamutali's message of Sat Sep 17 23:02:15 +0200 2011:
> I wanted to enable (again) freetype support in xmobar but decided to be
> overcautious. How to modify expressions generated by cabal2nix and be
> sure that changes will be ported during following (automatic?) updates?
Using nixpkgs-haskell-overlay you define flags in the global func.
Cause a fix point is used you can "override" it and adjust all flags the
way you want:

https://github.com/MarcWeber/nixpkgs-haskell-overlay/blob/master/default.nix#L334
line 334 shows how flags are set for the package "darcs"

I don't know about cabal2nix.

I don't know how to grep the official nixpkgs haskell stuff for "flags"
- because all packages are in different directories...

But nixpkgs-haskell-overlay is using the same derivation for creating
haskell packages. And this code works for me:

                  configureFlags = ( lib.concatStringsSep " " (
                           (lib.mapAttrsFlatten (a: v: "-f${if v then "" else "-"}${a}") flags)
                        ++ (lib.attrByPath [name "configureFlags"] [] ammendmentsFixed)
                        ++ ["--enable-library-profiling"] # <- think about this again
                        )
                      );

Thus it'll work for haskell-packages.nix. You want to pass configureFlags and
set -fFLAG_NAME orc -F-FLAG_NAME (see cabal documentation)

Because haskell-packages.nix in nixpkgs is using callPackage this implies that
you can use .override in some way.

Which is the best way to override packages?
Depends on what you're trying to do.

Using nixpkgs-haskell-overlay you can have different configuration easily and
the dependencies will always comply to the cabal files.

If you need more assistance write again.

Marc Weber


More information about the nix-dev mailing list