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.
|
- #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.
|
- #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.
|
- #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
|
- 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).
|
- #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)
|
- #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.
|
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 {
|
projectSubmodule = types.submoduleWith {
|
||||||
|
@ -74,14 +74,16 @@ in
|
|||||||
hlint;
|
hlint;
|
||||||
};
|
};
|
||||||
nativeBuildInputs = lib.attrValues (defaultBuildTools finalPackages // config.devShell.tools finalPackages);
|
nativeBuildInputs = lib.attrValues (defaultBuildTools finalPackages // config.devShell.tools finalPackages);
|
||||||
devShell = finalPackages.shellFor {
|
mkShellArgs = config.devShell.mkShellArgs // {
|
||||||
inherit nativeBuildInputs;
|
nativeBuildInputs = (config.devShell.mkShellArgs.nativeBuildInputs or [ ]) ++ nativeBuildInputs;
|
||||||
|
};
|
||||||
|
devShell = finalPackages.shellFor (mkShellArgs // {
|
||||||
packages = p:
|
packages = p:
|
||||||
map
|
map
|
||||||
(name: p."${name}")
|
(name: p."${name}")
|
||||||
(lib.attrNames config.packages);
|
(lib.attrNames config.packages);
|
||||||
withHoogle = true;
|
withHoogle = true;
|
||||||
};
|
});
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
finalPackages = config.basePackages.extend config.finalOverlay;
|
finalPackages = config.basePackages.extend config.finalOverlay;
|
||||||
|
@ -46,9 +46,15 @@
|
|||||||
# docs.
|
# docs.
|
||||||
foo = self.callCabal2nix "foo" (inputs.haskell-multi-nix + /foo) { };
|
foo = self.callCabal2nix "foo" (inputs.haskell-multi-nix + /foo) { };
|
||||||
};
|
};
|
||||||
devShell.tools = hp: {
|
devShell = {
|
||||||
# Adding a tool should make it available in devshell.
|
tools = hp: {
|
||||||
fzf = pkgs.fzf;
|
# 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.
|
# 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.
|
# Adding a buildTool (fzf, here) should put it in devshell.
|
||||||
which fzf
|
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