stackage2nix icon indicating copy to clipboard operation
stackage2nix copied to clipboard

Support Cabal flags in stack.yaml

Open 4e6 opened this issue 8 years ago • 2 comments

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

4e6 avatar Jun 24 '17 08:06 4e6

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?

MartinPotier avatar Dec 12 '17 16:12 MartinPotier

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 ];
      };
    };

4e6 avatar Dec 12 '17 17:12 4e6