Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions builder/comp-builder.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion modules/component-driver.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down
9 changes: 5 additions & 4 deletions modules/plan.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we could craft a custom type. But for now this is porbably good enough.

default = (def.shellHook or "");
};
};
packageOptions = def: componentOptions def // {
preUnpack = mkOption {
Expand Down Expand Up @@ -123,10 +128,6 @@ let
type = nullOr string;
default = (def.postHaddock or null);
};
shellHook = mkOption {
type = nullOr string;
default = (def.shellHook or null);
};
};


Expand Down