-
-
Save expipiplus1/e401daca9e08ef3715e44d06cb6b03a1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let | |
# haskellPackageGen takes some options and a source location and generates a | |
# derivation which builds the haskell package at that source location. | |
# | |
# Internally it calls the `cabal2nix` executable to generate a function to | |
# make the derivation, calls this function with the haskell package set and | |
# tweaks it accoring to the options passed. | |
# | |
# See the 'Options to HaskellPackageGen' section in the project readme. | |
haskellPackageGen = { doFilter ? true | |
, doHaddock ? true | |
, extraPackages ? [] # Any extra packages to be made available at build time and in the shell | |
, extraEnvPackages ? [] # Any extra packages to be made available in the developer shell only | |
, extraArgs ? {} # Any extra arguments to callPackage | |
, extraAttrs ? {} # Any extra attrs to mkDerivation | |
, extraHaskellAttrs ? {} | |
# Any extra attrs to haskellPackages.mkDerivation such | |
# as { enableExecutableProfiling = true; }; | |
}: src: | |
let filteredSrc = maybeFilterSource src; | |
haskellPackages = myrtlepkgs.haskellPackages; | |
package = nixpkgs.runCommand "default.nix" {} '' | |
${haskellPackages.cabal2nix}/bin/cabal2nix \ | |
${if doFilter then filteredSrc else src} \ | |
${if doHaddock then "" else "--no-haddock"} \ | |
> $out | |
''; | |
# Call the generated package with the user specified 'extraArgsArgs', | |
# and a new 'mkDerication' which inserts the 'extraHaskellAttrs' into | |
# the derivation. | |
drv = haskellPackages.callPackage (import package) | |
(extraArgs // { mkDerivation = | |
let # It's possible (but weird) for the user to replace | |
# mkDerivation in extraArgs. If they did, make sure to use | |
# that one. | |
oldMkDerivation = | |
extraArgs.mkDerivation or haskellPackages.mkDerivation; | |
in args: oldMkDerivation (args // extraHaskellAttrs); | |
}); | |
# TODO: use .overrideAttrs when it lands in nixpkgs | |
drvWithExtras = nixpkgs.lib.overrideDerivation drv (attrs: { | |
buildInputs = attrs.buildInputs ++ extraPackages; | |
} // extraAttrs); | |
envWithExtras = nixpkgs.lib.overrideDerivation drv.env (attrs: { | |
buildInputs = attrs.buildInputs | |
++ extraPackages | |
++ extraEnvPackages | |
++ myrtlepkgs.config.userEnvPackages; | |
} // extraAttrs); | |
in drvWithExtras // { env = envWithExtras; }; | |
in {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment