Skip to content

Commit 22aa350

Browse files
authored
Put v1 compatibility back and fix warning (#714)
* Revert "Remove backwards compatibility with V1 code (#710)" * Fix issue with warning not being displayed
1 parent 6c41c29 commit 22aa350

File tree

1 file changed

+54
-31
lines changed

1 file changed

+54
-31
lines changed

default.nix

+54-31
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,56 @@
1-
{ checkMaterialization ? false # Allows us to easily switch on materialization checking
2-
, defaultCompilerNixName ? null # Quick way to override the default compiler e.g. "ghc883"
3-
, system ? builtins.currentSystem
4-
, sourcesOverride ? {}
5-
, ... }@args: rec {
6-
sources = (import ./nix/sources.nix) // sourcesOverride;
1+
let haskellNix = {
2+
checkMaterialization ? false, # Allows us to easily switch on materialization checking
3+
defaultCompilerNixName ? null, # Quick way to override the default compiler e.g. "ghc883"
4+
system ? builtins.currentSystem,
5+
sourcesOverride ? {},
6+
... }@args: rec {
7+
sources = (import ./nix/sources.nix) // sourcesOverride;
78

8-
config = import ./config.nix;
9-
overlays = [ allOverlays.combined ] ++ (
10-
if checkMaterialization == true
11-
then [(
12-
final: prev: {
13-
haskell-nix = prev.haskell-nix // {
14-
checkMaterialization = true;
15-
};
16-
}
17-
)]
18-
else []
19-
) ++ (
20-
if defaultCompilerNixName != null
21-
then [(
22-
final: prev: {
23-
haskell-nix = prev.haskell-nix // {
24-
inherit defaultCompilerNixName;
25-
};
26-
}
27-
)]
28-
else []
29-
);
30-
allOverlays = import ./overlays args;
31-
nixpkgsArgs = { inherit config overlays system; };
32-
pkgs = import sources.nixpkgs-default nixpkgsArgs;
9+
config = import ./config.nix;
10+
overlays = [ allOverlays.combined ] ++ (
11+
if checkMaterialization == true
12+
then [(
13+
final: prev: {
14+
haskell-nix = prev.haskell-nix // {
15+
checkMaterialization = true;
16+
};
17+
}
18+
)]
19+
else []
20+
) ++ (
21+
if defaultCompilerNixName != null
22+
then [(
23+
final: prev: {
24+
haskell-nix = prev.haskell-nix // {
25+
inherit defaultCompilerNixName;
26+
};
27+
}
28+
)]
29+
else []
30+
);
31+
allOverlays = import ./overlays args;
32+
nixpkgsArgs = { inherit config overlays system; };
33+
pkgs = import sources.nixpkgs-default nixpkgsArgs;
34+
};
35+
36+
v1DeprecationMessage = "Version 1 is deprecated: use version 2 (nixpkgs arguments are available as the `nixpkgsArgs` attribute of version 2)";
37+
haskellNixV1 = (haskellNix {}).nixpkgsArgs // {
38+
overlays = builtins.trace v1DeprecationMessage (haskellNix {}).nixpkgsArgs.overlays;
39+
};
40+
haskellNixV2 = haskellNix;
41+
42+
# If no arguments, then you get V1
43+
in haskellNixV1 // {
44+
__functor = _: {
45+
version ? 2,
46+
checkMaterialization ? false, # Allows us to easily switch on materialization checking
47+
defaultCompilerNixName ? null, # Quick way to override the default compiler e.g. "ghc883"
48+
system ? builtins.currentSystem,
49+
sourcesOverride ? {},
50+
... }@args:
51+
if version == 1
52+
then haskellNixV1
53+
else if version == 2
54+
then haskellNixV2 args
55+
else builtins.throw ("haskell.nix: unknown version: " + (builtins.toString version));
3356
}

0 commit comments

Comments
 (0)