Add shellHook option to components (and packages and plans) (#117)

This commit is contained in:
Edward Amsden
2019-05-17 10:55:04 +08:00
committed by Moritz Angermann
parent ae457c17d3
commit 413d5c9dbd
3 changed files with 13 additions and 7 deletions
+7 -2
View File
@@ -18,7 +18,7 @@
, preCheck ? null, postCheck ? null
, preInstall ? null, postInstall ? null
, preHaddock ? null, postHaddock ? null
, shellHook ? null
, shellHook ? ""
, doCheck ? component.doCheck || haskellLib.isTest componentId
, doCrossCheck ? component.doCrossCheck || false
@@ -187,6 +187,11 @@ let
inherit configFiles;
};
# In order to let shell hooks make package-specific things like Hoogle databases
shellHookApplied = if builtins.isString shellHook then shellHook else
if builtins.isFunction shellHook then shellHook { inherit package shellWrappers; }
else abort "shellHook should be a string or a function";
# the target dir for haddock documentation
docdir = docoutput: docoutput + "/share/doc/" + componentId.cname;
@@ -332,7 +337,7 @@ stdenv.mkDerivation ({
shellHook = ''
export PATH="${shellWrappers}/bin:$PATH"
${toString shellHook}
${shellHookApplied}
'';
}
# patches can (if they like) depend on the version and revision of the package.
+1 -1
View File
@@ -5,7 +5,7 @@ let
inherit haskellLib;
ghc = config.ghc.package;
buildGHC = buildModules.config.ghc.package;
inherit (config) nonReinstallablePkgs hsPkgs;
inherit (config) nonReinstallablePkgs hsPkgs shellHook;
inherit ghcForComponent;
};
+5 -4
View File
@@ -73,6 +73,11 @@ let
type = bool;
default = (def.doHaddock or true);
};
shellHook = mkOption {
description = "Hook to run when entering a shell";
type = unspecified; # Can be either a string or a function
default = (def.shellHook or "");
};
};
packageOptions = def: componentOptions def // {
preUnpack = mkOption {
@@ -123,10 +128,6 @@ let
type = nullOr string;
default = (def.postHaddock or null);
};
shellHook = mkOption {
type = nullOr string;
default = (def.shellHook or null);
};
};