on iko/ghcjs-patch-master help sign in
Add shellHook option to components (and packages and plans) (#117)
commit413d5c9dbdb6bf9090bcc8b88198a75e7c1181d0 authorEdward Amsden <edward@blackriversoft.com> dateThu 16 May 2019, 22:55 (7 years ago) parentae457c1
3 files changed+13−7
builder/comp-builder.nix+7−2 modules/component-driver.nix+1−1 modules/plan.nix+5−4
builder/comp-builder.nix+7−2
@@ -18,7 +18,7 @@
1818, preCheck ? null, postCheck ? null
1919, preInstall ? null, postInstall ? null
2020, preHaddock ? null, postHaddock ? null
21−, shellHook ? null
21+, shellHook ? ""
2222
2323, doCheck ? component.doCheck || haskellLib.isTest componentId
2424, doCrossCheck ? component.doCrossCheck || false
@@ -187,6 +187,11 @@ let
187187 inherit configFiles;
188188 };
189189
190+ # In order to let shell hooks make package-specific things like Hoogle databases
191+ shellHookApplied = if builtins.isString shellHook then shellHook else
192+ if builtins.isFunction shellHook then shellHook { inherit package shellWrappers; }
193+ else abort "shellHook should be a string or a function";
194+
190195 # the target dir for haddock documentation
191196 docdir = docoutput: docoutput + "/share/doc/" + componentId.cname;
192197
@@ -332,7 +337,7 @@ stdenv.mkDerivation ({
332337
333338 shellHook = ''
334339 export PATH="${shellWrappers}/bin:$PATH"
335− ${toString shellHook}
340+ ${shellHookApplied}
336341 '';
337342}
338343# patches can (if they like) depend on the version and revision of the package.
modules/component-driver.nix+1−1
@@ -5,7 +5,7 @@ let
55 inherit haskellLib;
66 ghc = config.ghc.package;
77 buildGHC = buildModules.config.ghc.package;
8− inherit (config) nonReinstallablePkgs hsPkgs;
8+ inherit (config) nonReinstallablePkgs hsPkgs shellHook;
99 inherit ghcForComponent;
1010 };
1111
modules/plan.nix+5−4
@@ -73,6 +73,11 @@ let
7373 type = bool;
7474 default = (def.doHaddock or true);
7575 };
76+ shellHook = mkOption {
77+ description = "Hook to run when entering a shell";
78+ type = unspecified; # Can be either a string or a function
79+ default = (def.shellHook or "");
80+ };
7681 };
7782 packageOptions = def: componentOptions def // {
7883 preUnpack = mkOption {
@@ -123,10 +128,6 @@ let
123128 type = nullOr string;
124129 default = (def.postHaddock or null);
125130 };
126− shellHook = mkOption {
127− type = nullOr string;
128− default = (def.shellHook or null);
129− };
130131 };
131132
132133