mirror of
https://github.com/srid/haskell-flake.git
synced 2024-09-11 05:55:25 +03:00
Merge pull request #111 from srid/shell-extra-libraries
Add `devShell.extraLibraries` option
This commit is contained in:
commit
da1d8bbda4
@ -8,6 +8,7 @@
|
||||
- #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`
|
||||
- #111: Add `devShell.extraLibraries` to add custom Haskell libraries to the devshell.
|
||||
- #100: `source-overrides` option now supports specifying Hackage versions.
|
||||
- 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).
|
||||
|
@ -63,6 +63,20 @@ in
|
||||
Build tools useful for Haskell development are included by default.
|
||||
'';
|
||||
};
|
||||
extraLibraries = mkOption {
|
||||
type = functionTo (types.attrsOf (types.nullOr types.package));
|
||||
description = ''
|
||||
Extra Haskell libraries available in the shell's environment.
|
||||
These can be used in the shell's `runghc` and `ghci` for instance.
|
||||
|
||||
The argument is the Haskell package set.
|
||||
|
||||
The return type is an attribute set for overridability and syntax, as only the values are used.
|
||||
'';
|
||||
default = hp: { };
|
||||
defaultText = lib.literalExpression "hp: { }";
|
||||
example = lib.literalExpression "hp: { inherit (hp) releaser; }";
|
||||
};
|
||||
hlsCheck = mkOption {
|
||||
default = { };
|
||||
type = hlsCheckSubmodule;
|
||||
|
@ -83,6 +83,12 @@ in
|
||||
(name: p."${name}")
|
||||
(lib.attrNames config.packages);
|
||||
withHoogle = true;
|
||||
extraDependencies = p:
|
||||
let o = mkShellArgs.extraDependencies or (_: { }) p;
|
||||
in o // {
|
||||
libraryHaskellDepends = o.libraryHaskellDepends or []
|
||||
++ builtins.attrValues (config.devShell.extraLibraries p);
|
||||
};
|
||||
});
|
||||
in
|
||||
{
|
||||
|
@ -51,6 +51,9 @@
|
||||
# Adding a tool should make it available in devshell.
|
||||
fzf = pkgs.fzf;
|
||||
};
|
||||
extraLibraries = hp: {
|
||||
inherit (hp) tomland;
|
||||
};
|
||||
mkShellArgs.shellHook = ''
|
||||
echo "Hello from devshell!"
|
||||
export FOO=bar
|
||||
|
5
test/script
Normal file
5
test/script
Normal file
@ -0,0 +1,5 @@
|
||||
import Toml.Type.Value (Value(Bool))
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
putStrLn ("I depend on the `tomland` package. Here's a TOML-flavored boolean: " <> show (Bool True))
|
@ -23,4 +23,7 @@ if [[ "$FOO" == "bar" ]]; then
|
||||
else
|
||||
echo "FOO is not bar"
|
||||
exit 2
|
||||
fi
|
||||
fi
|
||||
|
||||
# extraLibraries works
|
||||
runghc ./script | grep -F 'TOML-flavored boolean: Bool True'
|
||||
|
Loading…
Reference in New Issue
Block a user