1 { stdenv, ghc, pkg-config, glibcLocales
2 , cacert, stack, makeSetupHook, lib }@depArgs:
5 , nativeBuildInputs ? []
9 , stack ? depArgs.stack
15 stackCmd = "stack --internal-re-exec-version=${stack.version}";
17 # Add all dependencies in buildInputs including propagated ones to
18 # STACK_IN_NIX_EXTRA_ARGS.
19 stackHook = makeSetupHook {
23 in stdenv.mkDerivation (args // {
25 # Doesn't work in the sandbox. Pass `--option sandbox relaxed` or
26 # `--option sandbox false` to be able to build this
29 buildInputs = buildInputs
30 ++ lib.optional (stdenv.hostPlatform.libc == "glibc") glibcLocales;
32 nativeBuildInputs = nativeBuildInputs
33 ++ [ ghc pkg-config stack stackHook ];
35 STACK_PLATFORM_VARIANT = "nix";
36 STACK_IN_NIX_SHELL = 1;
37 STACK_IN_NIX_EXTRA_ARGS = extraArgs;
39 # XXX: workaround for https://ghc.haskell.org/trac/ghc/ticket/11042.
40 LD_LIBRARY_PATH = lib.makeLibraryPath (LD_LIBRARY_PATH ++ buildInputs);
41 # ^^^ Internally uses `getOutput "lib"` (equiv. to getLib)
43 # Non-NixOS git needs cert
44 GIT_SSL_CAINFO = "${cacert}/etc/ssl/certs/ca-bundle.crt";
46 # Fixes https://github.com/commercialhaskell/stack/issues/2358
49 preferLocalBuild = true;
52 export STACK_ROOT=$NIX_BUILD_TOP/.stack
55 buildPhase = args.buildPhase or ''
63 checkPhase = args.checkPhase or ''
71 doCheck = args.doCheck or true;
73 installPhase = args.installPhase or ''
76 ${stackCmd} --local-bin-path=$out/bin build --copy-bins