Skip to content

Commit 295d87d

Browse files
committed
Remove backwards compatibility with V1 code
This was a nice idea, but in practice it did not work unless you were explicitly extracting just `config`, `overlays` and `system` (see #542). ``` ~/iohk/haskell.nix$ nix-build -E 'import <nixpkgs> (import ./.)' error: anonymous function at /nix/store/f7mwvx7gl8lwjiqmpv60xapc3crvc474-nixpkgs-20.03pre194824.1f56d679f40/nixpkgs/pkgs/top-level/default.nix:20:1 called with unexpected argument '__functor', at /nix/store/f7mwvx7gl8lwjiqmpv60xapc3crvc474-nixpkgs-20.03pre194824.1f56d679f40/nixpkgs/pkgs/top-level/impure.nix:84:1 ``` This change will replace #542 errors with #709 errors.
1 parent e1589cc commit 295d87d

File tree

1 file changed

+31
-47
lines changed

1 file changed

+31
-47
lines changed

default.nix

+31-47
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,33 @@
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;
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;
87

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-
haskellNixV1 = (haskellNix {}).nixpkgsArgs;
37-
haskellNixV2 = haskellNix;
38-
39-
v1DeprecationMessage = "Version 1 is deprecated: use version 2 (nixpkgs arguments are available as the `nixpkgsArgs` attribute of version 2)";
40-
# If no arguments, then you get V1
41-
# I'd like to make importing directly issue a warning, but I couldn't figure out a way to make it happen
42-
in haskellNixV1 // {
43-
__functor = _: { version ? 2, ... }@args:
44-
if version == 1
45-
then builtins.trace v1DeprecationMessage haskellNixV1
46-
else if version == 2
47-
then haskellNixV2 args
48-
else builtins.throw ("haskell.nix: unknown version: " + (builtins.toString version));
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;
4933
}

0 commit comments

Comments
 (0)