2020-04-24 23:36:52 +00:00
|
|
|
|
/*
|
|
|
|
|
If user need access to more haskell package for building his
|
|
|
|
|
diagrams, he simply has to pass these package through the
|
|
|
|
|
extra packages function as follow in `config.nix`:
|
2020-11-09 15:59:12 +00:00
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
|
~~~
|
|
|
|
|
diagrams-builder.override {
|
|
|
|
|
extraPackages = self : [myHaskellPackage];
|
|
|
|
|
}
|
|
|
|
|
~~~
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
{ stdenv, ghcWithPackages, makeWrapper, diagrams-builder, extraPackages ? (self: []) }:
|
|
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
|
|
# Used same technique as for the yiCustom package.
|
2020-11-09 15:59:12 +00:00
|
|
|
|
wrappedGhc = ghcWithPackages
|
2020-04-24 23:36:52 +00:00
|
|
|
|
(self: [ diagrams-builder ] ++ extraPackages self);
|
|
|
|
|
ghcVersion = wrappedGhc.version;
|
|
|
|
|
|
|
|
|
|
exeWrapper = backend : ''
|
|
|
|
|
makeWrapper \
|
|
|
|
|
"${diagrams-builder}/bin/diagrams-builder-${backend}" "$out/bin/diagrams-builder-${backend}" \
|
|
|
|
|
--set NIX_GHC ${wrappedGhc}/bin/ghc \
|
|
|
|
|
--set NIX_GHC_LIBDIR ${wrappedGhc}/lib/ghc-${ghcVersion}
|
|
|
|
|
'';
|
2020-11-09 15:59:12 +00:00
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
|
backends = ["svg" "cairo" "ps"];
|
|
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
|
name = "diagrams-builder";
|
|
|
|
|
|
|
|
|
|
buildInputs = [ makeWrapper ];
|
|
|
|
|
|
2020-11-09 15:59:12 +00:00
|
|
|
|
buildCommand = with stdenv.lib;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
concatStrings (intersperse "\n" (map exeWrapper backends));
|
|
|
|
|
|
|
|
|
|
# Will be faster to build the wrapper locally then to fetch it from a binary cache.
|
|
|
|
|
preferLocalBuild = true;
|
|
|
|
|
meta = diagrams-builder.meta;
|
2020-11-09 15:59:12 +00:00
|
|
|
|
}
|