1# This expression takes a file like `hackage-packages.nix` and constructs
2# a full package set out of that.
3
4{ # package-set used for build tools (all of nixpkgs)
5 buildPackages
6
7, # A haskell package set for Setup.hs, compiler plugins, and similar
8 # build-time uses.
9 buildHaskellPackages
10
11, # package-set used for non-haskell dependencies (all of nixpkgs)
12 pkgs
13
14, # stdenv provides our build and host platforms
15 stdenv
16
17, # this module provides the list of known licenses and maintainers
18 lib
19
20 # needed for overrideCabal & packageSourceOverrides
21, haskellLib
22
23, # hashes for downloading Hackage packages
24 # This is either a directory or a .tar.gz containing the cabal files and
25 # hashes of Hackage as exemplified by this repository:
26 # https://github.com/commercialhaskell/all-cabal-hashes/tree/hackage
27 all-cabal-hashes
28
29, # compiler to use
30 ghc
31
32, # A function that takes `{ pkgs, lib, callPackage }` as the first arg and
33 # `self` as second, and returns a set of haskell packages
34 package-set
35
36, # The final, fully overridden package set usable with the nixpkgs fixpoint
37 # overriding functionality
38 extensible-self
39}:
40
41# return value: a function from self to the package set
42self:
43
44let
45 inherit (stdenv) buildPlatform hostPlatform;
46
47 inherit (lib) fix' extends makeOverridable;
48 inherit (haskellLib) overrideCabal;
49
50 mkDerivationImpl = pkgs.callPackage ./generic-builder.nix {
51 inherit stdenv;
52 nodejs = buildPackages.nodejs-slim;
53 inherit (self) buildHaskellPackages ghc ghcWithHoogle ghcWithPackages;
54 inherit (self.buildHaskellPackages) jailbreak-cabal;
55 hscolour = overrideCabal (drv: {
56 isLibrary = false;
57 doHaddock = false;
58 hyperlinkSource = false; # Avoid depending on hscolour for this build.
59 postFixup = "rm -rf $out/lib $out/share $out/nix-support";
60 }) self.buildHaskellPackages.hscolour;
61 cpphs = overrideCabal (drv: {
62 isLibrary = false;
63 postFixup = "rm -rf $out/lib $out/share $out/nix-support";
64 }) (self.cpphs.overrideScope (self: super: {
65 mkDerivation = drv: super.mkDerivation (drv // {
66 enableSharedExecutables = false;
67 enableSharedLibraries = false;
68 doHaddock = false;
69 useCpphs = false;
70 });
71 }));
72 };
73
74 mkDerivation = makeOverridable mkDerivationImpl;
75
76 # manualArgs are the arguments that were explicitly passed to `callPackage`, like:
77 #
78 # callPackage foo { bar = null; };
79 #
80 # here `bar` is a manual argument.
81 callPackageWithScope = scope: fn: manualArgs:
82 let
83 # this code is copied from callPackage in lib/customisation.nix
84 #
85 # we cannot use `callPackage` here because we want to call `makeOverridable`
86 # on `drvScope` (we cannot add `overrideScope` after calling `callPackage` because then it is
87 # lost on `.override`) but determine the auto-args based on `drv` (the problem here
88 # is that nix has no way to "passthrough" args while preserving the reflection
89 # info that callPackage uses to determine the arguments).
90 drv = if lib.isFunction fn then fn else import fn;
91 auto = builtins.intersectAttrs (lib.functionArgs drv) scope;
92
93 # Converts a returned function to a functor attribute set if necessary
94 ensureAttrs = v: if builtins.isFunction v then { __functor = _: v; } else v;
95
96 # this wraps the `drv` function to add `scope` and `overrideScope` to the result.
97 drvScope = allArgs: ensureAttrs (drv allArgs) // {
98 inherit scope;
99 overrideScope = f:
100 let newScope = mkScope (fix' (extends f scope.__unfix__));
101 # note that we have to be careful here: `allArgs` includes the auto-arguments that
102 # weren't manually specified. If we would just pass `allArgs` to the recursive call here,
103 # then we wouldn't look up any packages in the scope in the next interation, because it
104 # appears as if all arguments were already manually passed, so the scope change would do
105 # nothing.
106 in callPackageWithScope newScope drv manualArgs;
107 };
108 in lib.makeOverridable drvScope (auto // manualArgs);
109
110 mkScope = scope: let
111 ps = pkgs.__splicedPackages;
112 scopeSpliced = pkgs.splicePackages {
113 pkgsBuildBuild = scope.buildHaskellPackages.buildHaskellPackages;
114 pkgsBuildHost = scope.buildHaskellPackages;
115 pkgsBuildTarget = {};
116 pkgsHostHost = {};
117 pkgsHostTarget = scope;
118 pkgsTargetTarget = {};
119 } // {
120 # Don't splice these
121 inherit (scope) ghc buildHaskellPackages;
122 };
123 in ps // ps.xorg // ps.gnome2 // { inherit stdenv; } // scopeSpliced;
124 defaultScope = mkScope self;
125 callPackage = drv: args: callPackageWithScope defaultScope drv args;
126
127 # Use cabal2nix to create a default.nix for the package sources found at 'src'.
128 haskellSrc2nix = { name, src, sha256 ? null, extraCabal2nixOptions ? "" }:
129 let
130 sha256Arg = if sha256 == null then "--sha256=" else ''--sha256="${sha256}"'';
131 in buildPackages.runCommand "cabal2nix-${name}" {
132 nativeBuildInputs = [ buildPackages.cabal2nix-unwrapped ];
133 preferLocalBuild = true;
134 allowSubstitutes = false;
135 LANG = "en_US.UTF-8";
136 LOCALE_ARCHIVE = pkgs.lib.optionalString (buildPlatform.libc == "glibc") "${buildPackages.glibcLocales}/lib/locale/locale-archive";
137 } ''
138 export HOME="$TMP"
139 mkdir -p "$out"
140 cabal2nix --compiler=${self.ghc.haskellCompilerName} --system=${hostPlatform.config} ${sha256Arg} "${src}" ${extraCabal2nixOptions} > "$out/default.nix"
141 '';
142
143 # Given a package name and version, e.g. name = "async", version = "2.2.4",
144 # gives its cabal file and hashes (JSON file) as discovered from the
145 # all-cabal-hashes value. If that's a directory, it will copy the relevant
146 # files to $out; if it's a tarball, it will extract and move them to $out.
147 all-cabal-hashes-component = name: version: buildPackages.runCommand "all-cabal-hashes-component-${name}-${version}" {} ''
148 mkdir -p $out
149 if [ -d ${all-cabal-hashes} ]
150 then
151 cp ${all-cabal-hashes}/${name}/${version}/${name}.json $out
152 cp ${all-cabal-hashes}/${name}/${version}/${name}.cabal $out
153 else
154 tar --wildcards -xzvf ${all-cabal-hashes} \*/${name}/${version}/${name}.{json,cabal}
155 mv */${name}/${version}/${name}.{json,cabal} $out
156 fi
157 '';
158
159 hackage2nix = name: version: let component = all-cabal-hashes-component name version; in self.haskellSrc2nix {
160 name = "${name}-${version}";
161 sha256 = ''$(sed -e 's/.*"SHA256":"//' -e 's/".*$//' "${component}/${name}.json")'';
162 src = "${component}/${name}.cabal";
163 };
164
165 # Adds a nix file derived from cabal2nix in the passthru of the derivation it
166 # produces. This is useful to debug callHackage / callCabal2nix by looking at
167 # the content of the nix file pointed by `cabal2nixDeriver`.
168 # However, it does not keep a reference to that file, which may be garbage
169 # collected, which may be an annoyance.
170 callPackageKeepDeriver = src: args:
171 overrideCabal (orig: {
172 passthru = orig.passthru or {} // {
173 # When using callCabal2nix or callHackage, it is often useful
174 # to debug a failure by inspecting the Nix expression
175 # generated by cabal2nix. This can be accessed via this
176 # cabal2nixDeriver field.
177 cabal2nixDeriver = src;
178 };
179 }) (self.callPackage src args);
180
181in package-set { inherit pkgs lib callPackage; } self // {
182
183 inherit mkDerivation callPackage haskellSrc2nix hackage2nix buildHaskellPackages;
184
185 inherit (haskellLib) packageSourceOverrides;
186
187 # callHackage :: Text -> Text -> AttrSet -> HaskellPackage
188 #
189 # e.g., while overriding a package set:
190 # '... foo = self.callHackage "foo" "1.5.3" {}; ...'
191 callHackage = name: version: callPackageKeepDeriver (self.hackage2nix name version);
192
193 # callHackageDirect
194 # :: { pkg :: Text, ver :: Text, sha256 :: Text }
195 # -> AttrSet
196 # -> HaskellPackage
197 #
198 # This function does not depend on all-cabal-hashes and therefore will work
199 # for any version that has been released on hackage as opposed to only
200 # versions released before whatever version of all-cabal-hashes you happen
201 # to be currently using.
202 callHackageDirect = {pkg, ver, sha256}:
203 let pkgver = "${pkg}-${ver}";
204 in self.callCabal2nix pkg (pkgs.fetchzip {
205 url = "mirror://hackage/${pkgver}/${pkgver}.tar.gz";
206 inherit sha256;
207 });
208
209 # Creates a Haskell package from a source package by calling cabal2nix on the source.
210 callCabal2nixWithOptions = name: src: extraCabal2nixOptions: args:
211 let
212 filter = path: type:
213 pkgs.lib.hasSuffix ".cabal" path ||
214 baseNameOf path == "package.yaml";
215 expr = self.haskellSrc2nix {
216 inherit name extraCabal2nixOptions;
217 src = if pkgs.lib.canCleanSource src
218 then pkgs.lib.cleanSourceWith { inherit src filter; }
219 else src;
220 };
221 in overrideCabal (orig: {
222 inherit src;
223 }) (callPackageKeepDeriver expr args);
224
225 callCabal2nix = name: src: args: self.callCabal2nixWithOptions name src "" args;
226
227 # : { root : Path
228 # , name : Defaulted String
229 # , source-overrides : Defaulted (Either Path VersionNumber)
230 # , overrides : Defaulted (HaskellPackageOverrideSet)
231 # , modifier : Defaulted
232 # , returnShellEnv : Defaulted
233 # , withHoogle : Defaulted
234 # , cabal2nixOptions : Defaulted
235 # } -> NixShellAwareDerivation
236 #
237 # Given a path to a haskell package directory, an optional package name
238 # which defaults to the base name of the path, an optional set of source
239 # overrides as appropriate for the 'packageSourceOverrides' function, an
240 # optional set of arbitrary overrides, and an optional haskell package
241 # modifier, return a derivation appropriate for nix-build or nix-shell to
242 # build that package.
243 #
244 # If 'returnShellEnv' is true this returns a derivation which will give you
245 # an environment suitable for developing the listed packages with an
246 # incremental tool like cabal-install.
247 #
248 # If 'withHoogle' is true (the default if a shell environment is requested)
249 # then 'ghcWithHoogle' is used to generate the derivation (instead of
250 # 'ghcWithPackages'), see the documentation there for more information.
251 #
252 # 'cabal2nixOptions' can contain extra command line arguments to pass to
253 # 'cabal2nix' when generating the package derivation, for example setting
254 # a cabal flag with '--flag=myflag'.
255 developPackage =
256 { root
257 , name ? lib.optionalString (builtins.typeOf root == "path") (builtins.baseNameOf root)
258 , source-overrides ? {}
259 , overrides ? self: super: {}
260 , modifier ? drv: drv
261 , returnShellEnv ? pkgs.lib.inNixShell
262 , withHoogle ? returnShellEnv
263 , cabal2nixOptions ? "" }:
264 let drv =
265 (extensible-self.extend
266 (pkgs.lib.composeExtensions
267 (self.packageSourceOverrides source-overrides)
268 overrides))
269 .callCabal2nixWithOptions name root cabal2nixOptions {};
270 in if returnShellEnv
271 then (modifier drv).envFunc {inherit withHoogle;}
272 else modifier drv;
273
274 # This can be used to easily create a derivation containing GHC and the specified set of Haskell packages.
275 #
276 # Example:
277 # $ nix-shell -p 'haskellPackages.ghcWithPackages (hpkgs: [ hpkgs.mtl hpkgs.lens ])'
278 # $ ghci # in the nix-shell
279 # Prelude > import Control.Lens
280 #
281 # GHC is setup with a package database with all the specified Haskell packages.
282 #
283 # ghcWithPackages :: (HaskellPkgSet -> [ HaskellPkg ]) -> Derivation
284 ghcWithPackages = buildHaskellPackages.callPackage ./with-packages-wrapper.nix {
285 haskellPackages = self;
286 inherit (self) hoogleWithPackages;
287 };
288
289
290 # Put 'hoogle' into the derivation's PATH with a database containing all
291 # the package's dependencies; run 'hoogle server --local' in a shell to
292 # host a search engine for the dependencies.
293 #
294 # Example usage:
295 # $ nix-shell -p 'haskellPackages.hoogleWithPackages (p: [ p.mtl p.lens ])'
296 # [nix-shell] $ hoogle server
297 #
298 # hoogleWithPackages :: (HaskellPkgSet -> [ HaskellPkg ]) -> Derivation
299 #
300 # To reload the Hoogle server automatically on .cabal file changes try
301 # this:
302 # echo *.cabal | entr -r -- nix-shell --run 'hoogle server --local'
303 hoogleWithPackages = self.callPackage ./hoogle.nix {
304 haskellPackages = self;
305 };
306 hoogleLocal =
307 { packages ? [] }:
308 lib.warn "hoogleLocal is deprecated, use hoogleWithPackages instead" (
309 self.hoogleWithPackages (_: packages)
310 );
311 # This is like a combination of ghcWithPackages and hoogleWithPackages.
312 # It provides a derivation containing both GHC and Hoogle with an index of
313 # the given Haskell package database.
314 #
315 # Example:
316 # $ nix-shell -p 'haskellPackages.ghcWithHoogle (hpkgs: [ hpkgs.conduit hpkgs.lens ])'
317 #
318 # ghcWithHoogle :: (HaskellPkgSet -> [ HaskellPkg ]) -> Derivation
319 ghcWithHoogle = self.ghcWithPackages.override {
320 withHoogle = true;
321 };
322
323 # Returns a derivation whose environment contains a GHC with only
324 # the dependencies of packages listed in `packages`, not the
325 # packages themselves. Using nix-shell on this derivation will
326 # give you an environment suitable for developing the listed
327 # packages with an incremental tool like cabal-install.
328 #
329 # In addition to the "packages" arg and "withHoogle" arg, anything that
330 # can be passed into stdenv.mkDerivation can be included in the input attrset
331 #
332 # # default.nix
333 # with import <nixpkgs> {};
334 # haskellPackages.extend (haskell.lib.compose.packageSourceOverrides {
335 # frontend = ./frontend;
336 # backend = ./backend;
337 # common = ./common;
338 # })
339 #
340 # # shell.nix
341 # let pkgs = import <nixpkgs> {} in
342 # (import ./.).shellFor {
343 # packages = p: [p.frontend p.backend p.common];
344 # withHoogle = true;
345 # buildInputs = [ pkgs.python pkgs.cabal-install ];
346 # }
347 #
348 # -- cabal.project
349 # packages:
350 # frontend/
351 # backend/
352 # common/
353 #
354 # bash$ nix-shell --run "cabal new-build all"
355 # bash$ nix-shell --run "python"
356 shellFor =
357 { # Packages to create this development shell for. These are usually
358 # your local packages.
359 packages
360 , # Whether or not to generate a Hoogle database for all the
361 # dependencies.
362 withHoogle ? false
363 , # Whether or not to include benchmark dependencies of your local
364 # packages. You should set this to true if you have benchmarks defined
365 # in your local packages that you want to be able to run with cabal benchmark
366 doBenchmark ? false
367 # An optional function that can modify the generic builder arguments
368 # for the fake package that shellFor uses to construct its environment.
369 #
370 # Example:
371 # let
372 # # elided...
373 # haskellPkgs = pkgs.haskell.packages.ghc884.override (hpArgs: {
374 # overrides = pkgs.lib.composeExtensions (hpArgs.overrides or (_: _: { })) (
375 # _hfinal: hprev: {
376 # mkDerivation = args: hprev.mkDerivation ({
377 # doCheck = false;
378 # doBenchmark = false;
379 # doHoogle = true;
380 # doHaddock = true;
381 # enableLibraryProfiling = false;
382 # enableExecutableProfiling = false;
383 # } // args);
384 # }
385 # );
386 # });
387 # in
388 # haskellPkgs.shellFor {
389 # packages = p: [ p.foo ];
390 # genericBuilderArgsModifier = args: args // { doCheck = true; doBenchmark = true };
391 # }
392 #
393 # This will disable tests and benchmarks for everything in "haskellPkgs"
394 # (which will invalidate the binary cache), and then re-enable them
395 # for the "shellFor" environment (ensuring that any test/benchmark
396 # dependencies for "foo" will be available within the nix-shell).
397 , genericBuilderArgsModifier ? (args: args)
398
399 # Extra dependencies, in the form of cabal2nix build attributes.
400 #
401 # An example use case is when you have Haskell scripts that use
402 # libraries that don't occur in your packages' dependencies.
403 #
404 # Example:
405 #
406 # extraDependencies = p: {
407 # libraryHaskellDepends = [ p.releaser ];
408 # };
409 , extraDependencies ? p: {}
410 , ...
411 } @ args:
412 let
413 # A list of the packages we want to build a development shell for.
414 # This is a list of Haskell package derivations.
415 selected = packages self;
416
417 # This is a list of attribute sets, where each attribute set
418 # corresponds to the build inputs of one of the packages input to shellFor.
419 #
420 # Each attribute has keys like buildDepends, executableHaskellDepends,
421 # testPkgconfigDepends, etc. The values for the keys of the attribute
422 # set are lists of dependencies.
423 #
424 # Example:
425 # cabalDepsForSelected
426 # => [
427 # # This may be the attribute set corresponding to the `backend`
428 # # package in the example above.
429 # { buildDepends = [ gcc ... ];
430 # libraryHaskellDepends = [ lens conduit ... ];
431 # ...
432 # }
433 # # This may be the attribute set corresponding to the `common`
434 # # package in the example above.
435 # { testHaskellDepends = [ tasty hspec ... ];
436 # libraryHaskellDepends = [ lens aeson ];
437 # benchmarkHaskellDepends = [ criterion ... ];
438 # ...
439 # }
440 # ...
441 # ]
442 cabalDepsForSelected = map (p: p.getCabalDeps) selected;
443
444 # A predicate that takes a derivation as input, and tests whether it is
445 # the same as any of the `selected` packages.
446 #
447 # Returns true if the input derivation is not in the list of `selected`
448 # packages.
449 #
450 # isNotSelected :: Derivation -> Bool
451 #
452 # Example:
453 #
454 # isNotSelected common [ frontend backend common ]
455 # => false
456 #
457 # isNotSelected lens [ frontend backend common ]
458 # => true
459 isNotSelected = input: pkgs.lib.all (p: input.outPath or null != p.outPath) selected;
460
461 # A function that takes a list of list of derivations, filters out all
462 # the `selected` packages from each list, and concats the results.
463 #
464 # zipperCombinedPkgs :: [[Derivation]] -> [Derivation]
465 #
466 # Example:
467 # zipperCombinedPkgs [ [ lens conduit ] [ aeson frontend ] ]
468 # => [ lens conduit aeson ]
469 #
470 # Note: The reason this isn't just the function `pkgs.lib.concat` is
471 # that we need to be careful to remove dependencies that are in the
472 # `selected` packages.
473 #
474 # For instance, in the above example, if `common` is a dependency of
475 # `backend`, then zipperCombinedPkgs needs to be careful to filter out
476 # `common`, because cabal will end up ignoring that built version,
477 # assuming new-style commands.
478 zipperCombinedPkgs = vals:
479 pkgs.lib.concatMap
480 (drvList: pkgs.lib.filter isNotSelected drvList)
481 vals;
482
483 # Zip `cabalDepsForSelected` into a single attribute list, combining
484 # the derivations in all the individual attributes.
485 #
486 # Example:
487 # packageInputs
488 # => # Assuming the value of cabalDepsForSelected is the same as
489 # # the example in cabalDepsForSelected:
490 # { buildDepends = [ gcc ... ];
491 # libraryHaskellDepends = [ lens conduit aeson ... ];
492 # testHaskellDepends = [ tasty hspec ... ];
493 # benchmarkHaskellDepends = [ criterion ... ];
494 # ...
495 # }
496 #
497 # See the Note in `zipperCombinedPkgs` for what gets filtered out from
498 # each of these dependency lists.
499 packageInputs =
500 pkgs.lib.zipAttrsWith (_name: zipperCombinedPkgs) (cabalDepsForSelected ++ [ (extraDependencies self) ]);
501
502 # A attribute set to pass to `haskellPackages.mkDerivation`.
503 #
504 # The important thing to note here is that all the fields from
505 # packageInputs are set correctly.
506 genericBuilderArgs = {
507 pname =
508 if pkgs.lib.length selected == 1
509 then (pkgs.lib.head selected).name
510 else "packages";
511 version = "0";
512 license = null;
513 }
514 // packageInputs
515 // pkgs.lib.optionalAttrs doBenchmark {
516 # `doBenchmark` needs to explicitly be set here because haskellPackages.mkDerivation defaults it to `false`. If the user wants benchmark dependencies included in their development shell, it has to be explicitly enabled here.
517 doBenchmark = true;
518 };
519
520 # This is a pseudo Haskell package derivation that contains all the
521 # dependencies for the packages in `selected`.
522 #
523 # This is a derivation created with `haskellPackages.mkDerivation`.
524 #
525 # pkgWithCombinedDeps :: HaskellDerivation
526 pkgWithCombinedDeps = self.mkDerivation (genericBuilderArgsModifier genericBuilderArgs);
527
528 # The derivation returned from `envFunc` for `pkgWithCombinedDeps`.
529 #
530 # This is a derivation that can be run with `nix-shell`. It provides a
531 # GHC with a package database with all the dependencies of our
532 # `selected` packages.
533 #
534 # This is a derivation created with `stdenv.mkDerivation` (not
535 # `haskellPackages.mkDerivation`).
536 #
537 # pkgWithCombinedDepsDevDrv :: Derivation
538 pkgWithCombinedDepsDevDrv = pkgWithCombinedDeps.envFunc { inherit withHoogle; };
539
540 mkDerivationArgs = builtins.removeAttrs args [ "genericBuilderArgsModifier" "packages" "withHoogle" "doBenchmark" "extraDependencies" ];
541
542 in pkgWithCombinedDepsDevDrv.overrideAttrs (old: mkDerivationArgs // {
543 nativeBuildInputs = old.nativeBuildInputs ++ mkDerivationArgs.nativeBuildInputs or [];
544 buildInputs = old.buildInputs ++ mkDerivationArgs.buildInputs or [];
545 });
546
547 ghc = ghc // {
548 withPackages = self.ghcWithPackages;
549 withHoogle = self.ghcWithHoogle;
550 };
551
552 /*
553 Run `cabal sdist` on a source.
554
555 Unlike `haskell.lib.sdistTarball`, this does not require any dependencies
556 to be present, as it uses `cabal-install` instead of building `Setup.hs`.
557 This makes `cabalSdist` faster than `sdistTarball`.
558 */
559 cabalSdist = {
560 src,
561 name ? if src?name then "${src.name}-sdist.tar.gz" else "source.tar.gz"
562 }:
563 pkgs.runCommandLocal name
564 {
565 inherit src;
566 nativeBuildInputs = [
567 buildHaskellPackages.cabal-install
568
569 # TODO after https://github.com/haskell/cabal/issues/8352
570 # remove ghc
571 self.ghc
572 ];
573 dontUnpack = false;
574 } ''
575 unpackPhase
576 cd "''${sourceRoot:-.}"
577 patchPhase
578 mkdir out
579 HOME=$PWD cabal sdist --output-directory out
580 mv out/*.tar.gz $out
581 '';
582
583 /*
584 Like `haskell.lib.buildFromSdist`, but using `cabal sdist` instead of
585 building `./Setup`.
586
587 Unlike `haskell.lib.buildFromSdist`, this does not require any dependencies
588 to be present. This makes `buildFromCabalSdist` faster than `haskell.lib.buildFromSdist`.
589 */
590 buildFromCabalSdist = pkg:
591 haskellLib.overrideSrc
592 {
593 src = self.cabalSdist { inherit (pkg) src; };
594 version = pkg.version;
595 }
596 pkg;
597
598 /*
599 Modify a Haskell package to add shell completion scripts for the
600 given executables produced by it. These completion scripts will be
601 picked up automatically if the resulting derivation is installed,
602 e.g. by `nix-env -i`.
603
604 This depends on the `--*-completion` flag `optparse-applicative` provides
605 automatically. Since we need to invoke installed executables, completions
606 are not generated if we are cross-compiling.
607
608 commands: names of the executables built by the derivation
609 pkg: Haskell package that builds the executables
610
611 Example:
612 generateOptparseApplicativeCompletions [ "exec1" "exec2" ] pkg
613
614 Type: [str] -> drv -> drv
615 */
616 generateOptparseApplicativeCompletions =
617 self.callPackage (
618 { stdenv }:
619
620 commands:
621 pkg:
622
623 if stdenv.buildPlatform.canExecute stdenv.hostPlatform
624 then lib.foldr haskellLib.__generateOptparseApplicativeCompletion pkg commands
625 else pkg
626 ) { };
627
628 /*
629 Modify given Haskell package to force GHC to employ the LLVM
630 codegen backend when compiling. Useful when working around bugs
631 in a native codegen backend GHC defaults to.
632
633 Example:
634 forceLlvmCodegenBackend tls
635
636 Type: drv -> drv
637 */
638 forceLlvmCodegenBackend = haskellLib.overrideCabal (drv: {
639 configureFlags = drv.configureFlags or [ ] ++ [ "--ghc-option=-fllvm" ];
640 buildTools = drv.buildTools or [ ] ++ [ self.llvmPackages.llvm ];
641 });
642 }