nh2 / static-haskell-nix

easily build most Haskell programs into fully static Linux executables
388 stars 36 forks source link

passing a cabal flag when creating the initial derivation (realated to cabal2nix) #102

Closed ruslantalpa closed 3 years ago

ruslantalpa commented 3 years ago

Usually when you want to build a normal haskell project with nix, one would have as a starting point

der = pkgs.haskell.packages."${compiler}".callCabal2nix name src { };

Now if that project can be compiled with different cabal flags, which in turn require different dependencies, like in a cabal file one has

if flag(SomeFlag)
     build-depends:   pacakgename                   >= 0.5.1 && <0.6

then the starting point can be created with

der = pkgs.haskell.packages."${compiler}".callCabal2nixWithOptions name src "-f SomeFlag" { }

which creates the correct derivation (i.e includes the correct build dependencies)

Is there any way to specify that special flag, not on the build stage but on the derivation creation stage? Is cabal2nix used internally and is it possible to pass down to it -f flag?

Without this, while the correct flag is passed at the build stage, the error i get is Setup: Encountered missing or private dependencies:

Thank you

ruslantalpa commented 3 years ago

figured it out, sorry, cabl2nix was being called in my code