Skip to content

Commit fc6fe0b

Browse files
angermanandreabedinihamishmack
authored
Fix stackage (#1882)
* Fetch the revised cabal files as part of elaborating hackage.nix Fixes #1857. --------- Co-authored-by: Andrea Bedini <[email protected]> Co-authored-by: Hamish Mackenzie <[email protected]>
1 parent fb3a7b1 commit fc6fe0b

22 files changed

+51
-346
lines changed

modules/hackage.nix

Lines changed: 51 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,39 +27,70 @@ let
2727
# { r0 = { nix = import ../hackage/...;
2828
# sha256 = $packageVersionSha256;
2929
# revision = $revNum;
30-
# revisionSha256 = $revisionSha256; };
30+
# revisionSha256 = $revisionSha256;
31+
# package-description-override = ... optional revised cabal file from hackage ...; };
3132
# default = revisions.r0;
3233
# $revisionSha256 = revisions.r0; };
3334
# };
3435
# };
3536
# };
3637
# }
3738

39+
rev2Config =
40+
{ pname, vnum, sha256 }:
41+
rev:
42+
{ system, compiler, flags, pkgs, hsPkgs, pkgconfPkgs, ... }@modArgs:
43+
let
44+
package-description-override =
45+
# we don't need to fetch cabal file revision zero because that's the one included in the source distribution
46+
if rev.revNum == 0 then null
47+
else
48+
builtins.readFile (pkgs.fetchurl (
49+
{
50+
name = "${pname}-${vnum}-r${toString rev.revNum}.cabal";
51+
url = "https://hackage.haskell.org/package/${pname}-${vnum}/revision/${toString rev.revNum}.cabal";
52+
sha256 = rev.sha256;
53+
}));
54+
in
55+
{
56+
inherit sha256;
57+
inherit package-description-override;
58+
revision = rev.revNum;
59+
revisionSha256 = rev.sha256;
60+
} // (x: (rev.nix or (import rev)) x) modArgs;
61+
62+
makeContentAddressed = revisions:
63+
let
64+
f = revName: acc:
65+
let rev = revisions.${revName};
66+
in
67+
acc // {
68+
# The original revsion attribute
69+
${revName} = rev;
70+
# The revision keyed by its sha256
71+
# Note: if there's a collision (e.g. a revision was reverted), pick
72+
# the one with the smaller revNum. They're identical, but if the
73+
# smaller one is r0 then we don't have to download a cabal file.
74+
${rev.sha256} =
75+
if lib.hasAttr rev.sha256 acc && acc.${rev.sha256}.revNum < rev.revNum
76+
then acc.${rev.sha256}
77+
else rev;
78+
};
79+
in
80+
lib.foldr f { } (builtins.attrNames revisions);
81+
3882
hackageConfigs =
3983
lib.flip lib.mapAttrs config.hackage.db
4084
(pname: lib.mapAttrs
4185
(vnum: version: version // {
4286
revisions =
43-
let
44-
rev2Config = rev: { system, compiler, flags, pkgs, hsPkgs, pkgconfPkgs, ... }@modArgs: {
45-
inherit (version) sha256;
46-
revision = rev.revNum;
47-
revisionSha256 = rev.sha256;
48-
} // (x: (rev.nix or (import rev)) x) modArgs;
49-
f = rev: acc: acc // {
50-
# If there's a collision (e.g. a revision was
51-
# reverted), pick the one with the smaller
52-
# revNum. They're identical, but if the smaller one is
53-
# r0 then we don't have to download a cabal file.
54-
${rev.sha256} = if lib.hasAttr rev.sha256 acc && acc.${rev.sha256}.revNum < rev.revNum
55-
then acc.${rev.sha256}
56-
else rev;
57-
};
58-
contentAddressedRevs = lib.foldr f {} (builtins.attrValues version.revisions);
59-
in lib.mapAttrs (_: rev2Config) (version.revisions // contentAddressedRevs);
87+
lib.mapAttrs
88+
(_: rev2Config { inherit pname vnum; inherit (version) sha256; })
89+
(makeContentAddressed version.revisions);
6090
}));
6191

62-
in {
92+
in
93+
{
6394
options.ghc.package = lib.mkOption {
6495
type = lib.types.package;
6596
# obtain the compiler from the haskell packages.
@@ -85,5 +116,5 @@ in {
85116
# be built by GHC's build system. However it may show up in stackage
86117
# snapshots. As such we just null it out.
87118
config.hackage.configs = hackageConfigs
88-
// { rts."1.0".revisions.default = null; };
119+
// { rts."1.0".revisions.default = null; };
89120
}

patches/ghc843/default.nix

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
packages.deepseq.patches = [ ({ version }: if version == "1.4.3.0" then ./deepseq-1.4.3.0.patch else null) ];
44
packages.hpc.patches = [ ({ version }: if version == "0.6.0.3" then ./hpc-0.6.0.3.patch else null) ];
55
packages.parallel.patches = [ ({ version }: if version == "3.2.1.1" then ./parallel-3.2.1.1.patch else null) ];
6-
packages.parsec.patches = [ ({ version }: if version == "3.1.13.0" then ./parsec-3.1.13.0.patch else null) ];
76
packages.random.patches = [ ({ version }: if version == "1.1" then ./random-1.1.patch else null) ];
87
packages.time.patches = [ ({ version }: if version == "1.8.0.2" then ./time-1.8.0.2.patch else null) ];
98
packages.unix.patches = [ ({ version }: if version == "2.7.2.2" then ./unix-2.7.2.2.patch else null) ];

patches/ghc843/parsec-3.1.13.0.patch

Lines changed: 0 additions & 24 deletions
This file was deleted.

patches/ghc843/unix-2.7.2.2.patch

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,3 @@ index ea0475d..a3897ae 100644
9696
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
9797
&& LARGE_OFF_T % 2147483647 == 1)
9898
? 1 : -1];
99-
diff --git a/unix.cabal b/unix.cabal
100-
index cf44068..6714fb2 100644
101-
--- a/unix.cabal
102-
+++ b/unix.cabal
103-
@@ -62,7 +62,7 @@ library
104-
buildable: False
105-
106-
build-depends:
107-
- base >= 4.5 && < 4.11,
108-
+ base >= 4.5 && < 4.12,
109-
bytestring >= 0.9.2 && < 0.11,
110-
time >= 1.2 && < 1.9
111-

patches/ghc844/default.nix

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
packages.deepseq.patches = [ ({ version }: if version == "1.4.3.0" then ./deepseq-1.4.3.0.patch else null) ];
44
packages.hpc.patches = [ ({ version }: if version == "0.6.0.3" then ./hpc-0.6.0.3.patch else null) ];
55
packages.parallel.patches = [ ({ version }: if version == "3.2.1.1" then ./parallel-3.2.1.1.patch else null) ];
6-
packages.parsec.patches = [ ({ version }: if version == "3.1.13.0" then ./parsec-3.1.13.0.patch else null) ];
76
packages.random.patches = [ ({ version }: if version == "1.1" then ./random-1.1.patch else null) ];
87
packages.time.patches = [ ({ version }: if version == "1.8.0.2" then ./time-1.8.0.2.patch else null) ];
98
packages.unix.patches = [ ({ version }: if version == "2.7.2.2" then ./unix-2.7.2.2.patch else null) ];

patches/ghc844/parsec-3.1.13.0.patch

Lines changed: 0 additions & 24 deletions
This file was deleted.

patches/ghc844/unix-2.7.2.2.patch

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,3 @@ index ea0475d..a3897ae 100644
9696
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
9797
&& LARGE_OFF_T % 2147483647 == 1)
9898
? 1 : -1];
99-
diff --git a/unix.cabal b/unix.cabal
100-
index cf44068..6714fb2 100644
101-
--- a/unix.cabal
102-
+++ b/unix.cabal
103-
@@ -62,7 +62,7 @@ library
104-
buildable: False
105-
106-
build-depends:
107-
- base >= 4.5 && < 4.11,
108-
+ base >= 4.5 && < 4.12,
109-
bytestring >= 0.9.2 && < 0.11,
110-
time >= 1.2 && < 1.9
111-

patches/ghc861/default.nix

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
packages.binary.patches = [ ({ version }: if version == "0.8.6.0" then ./binary-0.8.6.0.patch else null) ];
44
packages.containers.patches = [ ({ version }: if version == "0.6.0.1" then ./containers-0.6.0.1.patch else null) ];
55
packages.hpc.patches = [ ({ version }: if version == "0.6.0.3" then ./hpc-0.6.0.3.patch else null) ];
6-
packages.parsec.patches = [ ({ version }: if version == "3.1.13.0" then ./parsec-3.1.13.0.patch else null) ];
76
packages.process.patches = [ ({ version }: if version == "1.6.3.0" then ./process-1.6.3.0.patch else null) ];
87
packages.time.patches = [ ({ version }: if version == "1.8.0.2" then ./time-1.8.0.2.patch else null) ];
98
packages.transformers.patches = [ ({ version }: if version == "0.5.5.0" then ./transformers-0.5.5.0.patch else null) ];

patches/ghc861/parsec-3.1.13.0.patch

Lines changed: 0 additions & 36 deletions
This file was deleted.

patches/ghc861/unix-2.7.2.2.patch

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,3 @@ index ea0475d..a3897ae 100644
9696
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
9797
&& LARGE_OFF_T % 2147483647 == 1)
9898
? 1 : -1];
99-
diff --git a/unix.cabal b/unix.cabal
100-
index cf44068..bb3155f 100644
101-
--- a/unix.cabal
102-
+++ b/unix.cabal
103-
@@ -62,7 +62,7 @@ library
104-
buildable: False
105-
106-
build-depends:
107-
- base >= 4.5 && < 4.11,
108-
+ base >= 4.5 && < 4.13,
109-
bytestring >= 0.9.2 && < 0.11,
110-
time >= 1.2 && < 1.9
111-

patches/ghc862/default.nix

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
packages.binary.patches = [ ({ version }: if version == "0.8.6.0" then ./binary-0.8.6.0.patch else null) ];
33
packages.containers.patches = [ ({ version }: if version == "0.6.0.1" then ./containers-0.6.0.1.patch else null) ];
44
packages.hpc.patches = [ ({ version }: if version == "0.6.0.3" then ./hpc-0.6.0.3.patch else null) ];
5-
packages.parsec.patches = [ ({ version }: if version == "3.1.13.0" then ./parsec-3.1.13.0.patch else null) ];
65
packages.process.patches = [ ({ version }: if version == "1.6.3.0" then ./process-1.6.3.0.patch else null) ];
76
packages.singletons.patches = [ ({ version }: if version == "2.5.1" then ./singletons-2.5.1.patch else null) ];
87
packages.time.patches = [ ({ version }: if version == "1.8.0.2" then ./time-1.8.0.2.patch else null) ];

patches/ghc862/parsec-3.1.13.0.patch

Lines changed: 0 additions & 36 deletions
This file was deleted.

patches/ghc862/unix-2.7.2.2.patch

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,3 @@ index ea0475d..a3897ae 100644
9696
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
9797
&& LARGE_OFF_T % 2147483647 == 1)
9898
? 1 : -1];
99-
diff --git a/unix.cabal b/unix.cabal
100-
index cf44068..bb3155f 100644
101-
--- a/unix.cabal
102-
+++ b/unix.cabal
103-
@@ -62,7 +62,7 @@ library
104-
buildable: False
105-
106-
build-depends:
107-
- base >= 4.5 && < 4.11,
108-
+ base >= 4.5 && < 4.13,
109-
bytestring >= 0.9.2 && < 0.11,
110-
time >= 1.2 && < 1.9
111-

patches/ghc863/default.nix

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
packages.binary.patches = [ ({ version }: if version == "0.8.6.0" then ./binary-0.8.6.0.patch else null) ];
33
packages.containers.patches = [ ({ version }: if version == "0.6.0.1" then ./containers-0.6.0.1.patch else null) ];
44
packages.hpc.patches = [ ({ version }: if version == "0.6.0.3" then ./hpc-0.6.0.3.patch else null) ];
5-
packages.parsec.patches = [ ({ version }: if version == "3.1.13.0" then ./parsec-3.1.13.0.patch else null) ];
65
packages.process.patches = [ ({ version }: if version == "1.6.3.0" then ./process-1.6.3.0.patch else null) ];
76
packages.singletons.patches = [ ({ version }: if version == "2.5.1" then ./singletons-2.5.1.patch else null) ];
87
packages.time.patches = [ ({ version }: if version == "1.8.0.2" then ./time-1.8.0.2.patch else null) ];

patches/ghc863/parsec-3.1.13.0.patch

Lines changed: 0 additions & 36 deletions
This file was deleted.

patches/ghc863/unix-2.7.2.2.patch

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,3 @@ index ea0475d..a3897ae 100644
9696
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
9797
&& LARGE_OFF_T % 2147483647 == 1)
9898
? 1 : -1];
99-
diff --git a/unix.cabal b/unix.cabal
100-
index cf44068..bb3155f 100644
101-
--- a/unix.cabal
102-
+++ b/unix.cabal
103-
@@ -62,7 +62,7 @@ library
104-
buildable: False
105-
106-
build-depends:
107-
- base >= 4.5 && < 4.11,
108-
+ base >= 4.5 && < 4.13,
109-
bytestring >= 0.9.2 && < 0.11,
110-
time >= 1.2 && < 1.9
111-

patches/ghc864/default.nix

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
packages.binary.patches = [ ({ version }: if version == "0.8.6.0" then ./binary-0.8.6.0.patch else null) ];
33
packages.containers.patches = [ ({ version }: if version == "0.6.0.1" then ./containers-0.6.0.1.patch else null) ];
44
packages.hpc.patches = [ ({ version }: if version == "0.6.0.3" then ./hpc-0.6.0.3.patch else null) ];
5-
packages.parsec.patches = [ ({ version }: if version == "3.1.13.0" then ./parsec-3.1.13.0.patch else null) ];
65
packages.singletons.patches = [ ({ version }: if version == "2.5.1" then ./singletons-2.5.1.patch else null) ];
76
packages.unix.patches = [ ({ version }: if version == "2.7.2.2" then ./unix-2.7.2.2.patch else null) ];
87
}

0 commit comments

Comments
 (0)