mirror of
https://github.com/srid/haskell-flake.git
synced 2024-09-11 05:55:25 +03:00
Add devShell.mkShellArgs
(#92)
This commit is contained in:
parent
b46d3ce129
commit
67d2e0c753
@ -6,6 +6,7 @@
|
||||
- #63: Add `config.haskellProjects.${name}.outputs` containing all flake outputs for that project.
|
||||
- #49 & #91: The `packages` option now autodiscovers the top-level `.cabal` file (in addition to looking inside sub-directories) as its default value.
|
||||
- #69: The default flake template creates `flake.nix` only, while the `#example` one creates the full Haskell project template.
|
||||
- #92: Add `devShell.mkShellArgs` to pass custom arguments to `mkShell`
|
||||
- API changes
|
||||
- #37: Group `buildTools` (renamed to `tools`), `hlsCheck` and `hlintCheck` under the `devShell` submodule option; and allow disabling them all using `devShell.enable = false;` (useful if you want haskell-flake to produce just the package outputs).
|
||||
- #64: Remove hlintCheck (use [treefmt-nix](https://github.com/numtide/treefmt-nix#flake-parts) instead)
|
||||
|
@ -69,6 +69,21 @@ in
|
||||
A [check](flake-parts.html#opt-perSystem.checks) to make sure that your IDE will work.
|
||||
'';
|
||||
};
|
||||
mkShellArgs = mkOption {
|
||||
type = types.attrsOf types.raw;
|
||||
description = ''
|
||||
Extra arguments to pass to `pkgs.mkShell`.
|
||||
'';
|
||||
default = { };
|
||||
example = ''
|
||||
{
|
||||
shellHook = \'\'
|
||||
# Re-generate .cabal files so HLS will work (per hie.yaml)
|
||||
''${pkgs.findutils}/bin/find -name package.yaml -exec hpack {} \;
|
||||
\'\';
|
||||
};
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
projectSubmodule = types.submoduleWith {
|
||||
|
@ -74,14 +74,16 @@ in
|
||||
hlint;
|
||||
};
|
||||
nativeBuildInputs = lib.attrValues (defaultBuildTools finalPackages // config.devShell.tools finalPackages);
|
||||
devShell = finalPackages.shellFor {
|
||||
inherit nativeBuildInputs;
|
||||
mkShellArgs = config.devShell.mkShellArgs // {
|
||||
nativeBuildInputs = (config.devShell.mkShellArgs.nativeBuildInputs or [ ]) ++ nativeBuildInputs;
|
||||
};
|
||||
devShell = finalPackages.shellFor (mkShellArgs // {
|
||||
packages = p:
|
||||
map
|
||||
(name: p."${name}")
|
||||
(lib.attrNames config.packages);
|
||||
withHoogle = true;
|
||||
};
|
||||
});
|
||||
in
|
||||
{
|
||||
finalPackages = config.basePackages.extend config.finalOverlay;
|
||||
|
@ -46,9 +46,15 @@
|
||||
# docs.
|
||||
foo = self.callCabal2nix "foo" (inputs.haskell-multi-nix + /foo) { };
|
||||
};
|
||||
devShell.tools = hp: {
|
||||
# Adding a tool should make it available in devshell.
|
||||
fzf = pkgs.fzf;
|
||||
devShell = {
|
||||
tools = hp: {
|
||||
# Adding a tool should make it available in devshell.
|
||||
fzf = pkgs.fzf;
|
||||
};
|
||||
mkShellArgs.shellHook = ''
|
||||
echo "Hello from devshell!"
|
||||
export FOO=bar
|
||||
'';
|
||||
};
|
||||
};
|
||||
# haskell-flake doesn't set the default package, but you can do it here.
|
||||
|
@ -16,3 +16,11 @@ which ghcid && exit 2 || echo
|
||||
|
||||
# Adding a buildTool (fzf, here) should put it in devshell.
|
||||
which fzf
|
||||
|
||||
# mkShellArgs works
|
||||
if [[ "$FOO" == "bar" ]]; then
|
||||
echo "$FOO"
|
||||
else
|
||||
echo "FOO is not bar"
|
||||
exit 2
|
||||
fi
|
Loading…
Reference in New Issue
Block a user