By default, I create my project without nix
, and the executable is statically linked. But when building with nix
I want to associate it dynamically. So I added a switch to myproj.cabal
:
flag dynamic
description: Build only dynamic binaries
default: False
executable RunMe
ghc-options: -O2 -Wall
if !flag(dynamic)
ghc-options: -optl-static -static
Now I can create a project using
stack --nix --nix-packages=zlib install --flag myproj:dynamic
To avoid passing command line parameters every time, I created shell.nix
:
{ghc}:
with (import <nixpkgs> {});
haskell.lib.buildStackProject {
inherit ghc;
name = "myproj";
buildInputs = [ zlib ];
}
Now I do not know how to pass the flag to cabal from the nix file. Based on buildStackProject
, I tried to install buildPhase
, for example.
haskell.lib.buildStackProject {
...
buildPhase = "stack build --flag=myproj:dynamic";
}
but it does not change anything. How to pass a flag to bondage from a file nix
?
source
share