Support Cabal flags in stack.yaml
Parse Cabal flags section from stack.yaml file, and produce appropriate Nix overrides.
flags:
package-name:
flag-name: true
https://docs.haskellstack.org/en/stable/yaml_configuration/#flags https://docs.haskellstack.org/en/stable/GUIDE/#cabal-flag-management
I'm so needing that. But that's OK, writing overrides by hand is not a big problem.
However, I have .cabal files with conditional flags in them (like static, or production). Using stackage2nix for now ignores those and pick the dependencies from the default value of those flags.
For instance, production adds a postgresql dependency. The generated default.nix doesn't have it. So if I override my package and I add a -fproduction, then nix-build complains of a missing dep, namely postgresql.
Can I go around this?
You definitely can. Check out Nixpkgs example 9.5.3.2. How to build projects that depend on each other
Suppose, project foo is missing from generated Haskell packages, so you add derivation manually:
cd ~/src/foo && cabal2nix . > default.nix
Project bar lacks dependency on foo, so you override it with:
bar = addBuildDepends super.bar [ foo ];
Eventually, it should look something like this:
haskellPackages = super.haskellPackages.override {
overrides = self: super: rec {
foo = self.callPackage ./src/foo {};
bar = addBuildDepends super.bar [ foo ];
};
};