haskell.nix/default.nix
Hamish Mackenzie 6a0dd874be
Add pkgs to use nixpkgs-default easily (#602)
Currently if we want to use nixpkgs-default and nixpkgsAgs it is
a bit painful.  With this change:

```
nix-build -E 'let h = import ./. {}; in (import h.sources.nixpkgs-default h.nixpkgsArgs).haskell-nix.tool "hlint" "3.1"'
```

becomes

```
nix-build -E 'pkgs.haskell-nix.tool "hlint" "3.1"'
```
2020-05-13 12:29:29 +08:00

27 lines
986 B
Nix

let haskellNix = rec {
sources = {
inherit (import ./nixpkgs/default.nix) nixpkgs-1909 nixpkgs-2003 nixpkgs-default;
};
config = import ./config.nix;
overlays = [ allOverlays.combined ];
allOverlays = import ./overlays;
nixpkgsArgs = { inherit config overlays; };
pkgs = import sources.nixpkgs-default nixpkgsArgs;
};
haskellNixV1 = haskellNix.nixpkgsArgs;
haskellNixV2 = haskellNix;
v1DeprecationMessage = "Version 1 is deprecated: use version 2 (nixpkgs arguments are available as the `nixpkgsArgs` attribute of version 2)";
# If no arguments, then you get V1
# I'd like to make importing directly issue a warning, but I couldn't figure out a way to make it happen
in haskellNixV1 // {
__functor = _: { version ? 2 }:
if version == 1
then builtins.trace v1DeprecationMessage haskellNixV1
else if version == 2
then haskellNixV2
else builtins.throw ("haskell.nix: unknown version: " + (builtins.toString version));
}