Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetch the revised cabal files as part of elaborating hackage.nix #1860

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 51 additions & 20 deletions modules/hackage.nix
Original file line number Diff line number Diff line change
Expand Up @@ -27,39 +27,70 @@ let
# { r0 = { nix = import ../hackage/...;
# sha256 = $packageVersionSha256;
# revision = $revNum;
# revisionSha256 = $revisionSha256; };
# revisionSha256 = $revisionSha256;
# package-description-override = ... optional revised cabal file from hackage ...; };
# default = revisions.r0;
# $revisionSha256 = revisions.r0; };
# };
# };
# };
# }

rev2Config =
{ pname, vnum, sha256 }:
rev:
{ system, compiler, flags, pkgs, hsPkgs, pkgconfPkgs, ... }@modArgs:
let
package-description-override =
# we don't need to fetch cabal file revision zero because that's the one included in the source distribution
if rev.revNum == 0 then null
else
builtins.readFile (pkgs.fetchurl (
{
name = "${pname}-${vnum}-r${toString rev.revNum}.cabal";
url = "https://hackage.haskell.org/package/${pname}-${vnum}/revision/${toString rev.revNum}.cabal";
sha256 = rev.sha256;
}));
in
{
inherit sha256;
inherit package-description-override;
revision = rev.revNum;
revisionSha256 = rev.sha256;
} // (x: (rev.nix or (import rev)) x) modArgs;

makeContentAddressed = revisions:
let
f = revName: acc:
let rev = revisions.${revName};
in
acc // {
# The original revsion attribute
${revName} = rev;
# The revision keyed by its sha256
# Note: if there's a collision (e.g. a revision was reverted), pick
# the one with the smaller revNum. They're identical, but if the
# smaller one is r0 then we don't have to download a cabal file.
${rev.sha256} =
if lib.hasAttr rev.sha256 acc && acc.${rev.sha256}.revNum < rev.revNum
then acc.${rev.sha256}
else rev;
};
in
lib.foldr f { } (builtins.attrNames revisions);

hackageConfigs =
lib.flip lib.mapAttrs config.hackage.db
(pname: lib.mapAttrs
(vnum: version: version // {
revisions =
let
rev2Config = rev: { system, compiler, flags, pkgs, hsPkgs, pkgconfPkgs, ... }@modArgs: {
inherit (version) sha256;
revision = rev.revNum;
revisionSha256 = rev.sha256;
} // (x: (rev.nix or (import rev)) x) modArgs;
f = rev: acc: acc // {
# If there's a collision (e.g. a revision was
# reverted), pick the one with the smaller
# revNum. They're identical, but if the smaller one is
# r0 then we don't have to download a cabal file.
${rev.sha256} = if lib.hasAttr rev.sha256 acc && acc.${rev.sha256}.revNum < rev.revNum
then acc.${rev.sha256}
else rev;
};
contentAddressedRevs = lib.foldr f {} (builtins.attrValues version.revisions);
in lib.mapAttrs (_: rev2Config) (version.revisions // contentAddressedRevs);
lib.mapAttrs
(_: rev2Config { inherit pname vnum; inherit (version) sha256; })
(makeContentAddressed version.revisions);
}));

in {
in
{
options.ghc.package = lib.mkOption {
type = lib.types.package;
# obtain the compiler from the haskell packages.
Expand All @@ -85,5 +116,5 @@ in {
# be built by GHC's build system. However it may show up in stackage
# snapshots. As such we just null it out.
config.hackage.configs = hackageConfigs
// { rts."1.0".revisions.default = null; };
// { rts."1.0".revisions.default = null; };
}
1 change: 0 additions & 1 deletion patches/ghc843/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
packages.deepseq.patches = [ ({ version }: if version == "1.4.3.0" then ./deepseq-1.4.3.0.patch else null) ];
packages.hpc.patches = [ ({ version }: if version == "0.6.0.3" then ./hpc-0.6.0.3.patch else null) ];
packages.parallel.patches = [ ({ version }: if version == "3.2.1.1" then ./parallel-3.2.1.1.patch else null) ];
packages.parsec.patches = [ ({ version }: if version == "3.1.13.0" then ./parsec-3.1.13.0.patch else null) ];
packages.random.patches = [ ({ version }: if version == "1.1" then ./random-1.1.patch else null) ];
packages.time.patches = [ ({ version }: if version == "1.8.0.2" then ./time-1.8.0.2.patch else null) ];
packages.unix.patches = [ ({ version }: if version == "2.7.2.2" then ./unix-2.7.2.2.patch else null) ];
Expand Down
24 changes: 0 additions & 24 deletions patches/ghc843/parsec-3.1.13.0.patch

This file was deleted.

13 changes: 0 additions & 13 deletions patches/ghc843/unix-2.7.2.2.patch
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,3 @@ index ea0475d..a3897ae 100644
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
diff --git a/unix.cabal b/unix.cabal
index cf44068..6714fb2 100644
--- a/unix.cabal
+++ b/unix.cabal
@@ -62,7 +62,7 @@ library
buildable: False

build-depends:
- base >= 4.5 && < 4.11,
+ base >= 4.5 && < 4.12,
bytestring >= 0.9.2 && < 0.11,
time >= 1.2 && < 1.9

1 change: 0 additions & 1 deletion patches/ghc844/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
packages.deepseq.patches = [ ({ version }: if version == "1.4.3.0" then ./deepseq-1.4.3.0.patch else null) ];
packages.hpc.patches = [ ({ version }: if version == "0.6.0.3" then ./hpc-0.6.0.3.patch else null) ];
packages.parallel.patches = [ ({ version }: if version == "3.2.1.1" then ./parallel-3.2.1.1.patch else null) ];
packages.parsec.patches = [ ({ version }: if version == "3.1.13.0" then ./parsec-3.1.13.0.patch else null) ];
packages.random.patches = [ ({ version }: if version == "1.1" then ./random-1.1.patch else null) ];
packages.time.patches = [ ({ version }: if version == "1.8.0.2" then ./time-1.8.0.2.patch else null) ];
packages.unix.patches = [ ({ version }: if version == "2.7.2.2" then ./unix-2.7.2.2.patch else null) ];
Expand Down
24 changes: 0 additions & 24 deletions patches/ghc844/parsec-3.1.13.0.patch

This file was deleted.

13 changes: 0 additions & 13 deletions patches/ghc844/unix-2.7.2.2.patch
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,3 @@ index ea0475d..a3897ae 100644
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
diff --git a/unix.cabal b/unix.cabal
index cf44068..6714fb2 100644
--- a/unix.cabal
+++ b/unix.cabal
@@ -62,7 +62,7 @@ library
buildable: False

build-depends:
- base >= 4.5 && < 4.11,
+ base >= 4.5 && < 4.12,
bytestring >= 0.9.2 && < 0.11,
time >= 1.2 && < 1.9

1 change: 0 additions & 1 deletion patches/ghc861/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
packages.binary.patches = [ ({ version }: if version == "0.8.6.0" then ./binary-0.8.6.0.patch else null) ];
packages.containers.patches = [ ({ version }: if version == "0.6.0.1" then ./containers-0.6.0.1.patch else null) ];
packages.hpc.patches = [ ({ version }: if version == "0.6.0.3" then ./hpc-0.6.0.3.patch else null) ];
packages.parsec.patches = [ ({ version }: if version == "3.1.13.0" then ./parsec-3.1.13.0.patch else null) ];
packages.process.patches = [ ({ version }: if version == "1.6.3.0" then ./process-1.6.3.0.patch else null) ];
packages.time.patches = [ ({ version }: if version == "1.8.0.2" then ./time-1.8.0.2.patch else null) ];
packages.transformers.patches = [ ({ version }: if version == "0.5.5.0" then ./transformers-0.5.5.0.patch else null) ];
Expand Down
36 changes: 0 additions & 36 deletions patches/ghc861/parsec-3.1.13.0.patch

This file was deleted.

13 changes: 0 additions & 13 deletions patches/ghc861/unix-2.7.2.2.patch
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,3 @@ index ea0475d..a3897ae 100644
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
diff --git a/unix.cabal b/unix.cabal
index cf44068..bb3155f 100644
--- a/unix.cabal
+++ b/unix.cabal
@@ -62,7 +62,7 @@ library
buildable: False

build-depends:
- base >= 4.5 && < 4.11,
+ base >= 4.5 && < 4.13,
bytestring >= 0.9.2 && < 0.11,
time >= 1.2 && < 1.9

1 change: 0 additions & 1 deletion patches/ghc862/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
packages.binary.patches = [ ({ version }: if version == "0.8.6.0" then ./binary-0.8.6.0.patch else null) ];
packages.containers.patches = [ ({ version }: if version == "0.6.0.1" then ./containers-0.6.0.1.patch else null) ];
packages.hpc.patches = [ ({ version }: if version == "0.6.0.3" then ./hpc-0.6.0.3.patch else null) ];
packages.parsec.patches = [ ({ version }: if version == "3.1.13.0" then ./parsec-3.1.13.0.patch else null) ];
packages.process.patches = [ ({ version }: if version == "1.6.3.0" then ./process-1.6.3.0.patch else null) ];
packages.singletons.patches = [ ({ version }: if version == "2.5.1" then ./singletons-2.5.1.patch else null) ];
packages.time.patches = [ ({ version }: if version == "1.8.0.2" then ./time-1.8.0.2.patch else null) ];
Expand Down
36 changes: 0 additions & 36 deletions patches/ghc862/parsec-3.1.13.0.patch

This file was deleted.

13 changes: 0 additions & 13 deletions patches/ghc862/unix-2.7.2.2.patch
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,3 @@ index ea0475d..a3897ae 100644
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
diff --git a/unix.cabal b/unix.cabal
index cf44068..bb3155f 100644
--- a/unix.cabal
+++ b/unix.cabal
@@ -62,7 +62,7 @@ library
buildable: False

build-depends:
- base >= 4.5 && < 4.11,
+ base >= 4.5 && < 4.13,
bytestring >= 0.9.2 && < 0.11,
time >= 1.2 && < 1.9

1 change: 0 additions & 1 deletion patches/ghc863/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
packages.binary.patches = [ ({ version }: if version == "0.8.6.0" then ./binary-0.8.6.0.patch else null) ];
packages.containers.patches = [ ({ version }: if version == "0.6.0.1" then ./containers-0.6.0.1.patch else null) ];
packages.hpc.patches = [ ({ version }: if version == "0.6.0.3" then ./hpc-0.6.0.3.patch else null) ];
packages.parsec.patches = [ ({ version }: if version == "3.1.13.0" then ./parsec-3.1.13.0.patch else null) ];
packages.process.patches = [ ({ version }: if version == "1.6.3.0" then ./process-1.6.3.0.patch else null) ];
packages.singletons.patches = [ ({ version }: if version == "2.5.1" then ./singletons-2.5.1.patch else null) ];
packages.time.patches = [ ({ version }: if version == "1.8.0.2" then ./time-1.8.0.2.patch else null) ];
Expand Down
36 changes: 0 additions & 36 deletions patches/ghc863/parsec-3.1.13.0.patch

This file was deleted.

13 changes: 0 additions & 13 deletions patches/ghc863/unix-2.7.2.2.patch
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,3 @@ index ea0475d..a3897ae 100644
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
diff --git a/unix.cabal b/unix.cabal
index cf44068..bb3155f 100644
--- a/unix.cabal
+++ b/unix.cabal
@@ -62,7 +62,7 @@ library
buildable: False

build-depends:
- base >= 4.5 && < 4.11,
+ base >= 4.5 && < 4.13,
bytestring >= 0.9.2 && < 0.11,
time >= 1.2 && < 1.9

1 change: 0 additions & 1 deletion patches/ghc864/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
packages.binary.patches = [ ({ version }: if version == "0.8.6.0" then ./binary-0.8.6.0.patch else null) ];
packages.containers.patches = [ ({ version }: if version == "0.6.0.1" then ./containers-0.6.0.1.patch else null) ];
packages.hpc.patches = [ ({ version }: if version == "0.6.0.3" then ./hpc-0.6.0.3.patch else null) ];
packages.parsec.patches = [ ({ version }: if version == "3.1.13.0" then ./parsec-3.1.13.0.patch else null) ];
packages.singletons.patches = [ ({ version }: if version == "2.5.1" then ./singletons-2.5.1.patch else null) ];
packages.unix.patches = [ ({ version }: if version == "2.7.2.2" then ./unix-2.7.2.2.patch else null) ];
}
Loading