on iko/ghcjs-patch-master help sign in
Allow patches to optionally depend on version and revision

This allows us to patch hackage packages to match those as shipped with ghc; which we sadly have to.

commit4050450b86bca7a958d794d58763313db8999c61 authorMoritz Angermann <moritz.angermann@gmail.com> dateFri 18 Jan 2019, 15:45 (8 years ago) parent84bcfd7
10 files changed+59−53
builder/comp-builder.nix+3−1 builder/default.nix+1−1 modules/package.nix+1−1 patches/default.nix−7 patches/ghc843/default.nix+9−9 patches/ghc844/default.nix+9−9 patches/ghc861/default.nix+9−9 patches/ghc862/default.nix+8−8 patches/ghc863/default.nix+8−8 patches/update-patches.sh+11
builder/comp-builder.nix+3−1
@@ -7,6 +7,7 @@
77, setup
88, src
99, flags
10+, revision
1011, cabalFile
1112, patches ? []
1213
@@ -229,7 +230,8 @@ in stdenv.mkDerivation ({
229230 runHook postInstall
230231 '';
231232}
232−// lib.optionalAttrs (patches != []) { inherit patches; }
233+# patches can (if they like) depend on the version and revision of the package.
234+// lib.optionalAttrs (patches != []) { patches = map (p: if builtins.isFunction p then p { inherit (package.identifier) version; inherit revision; } else p) patches; }
233235// lib.optionalAttrs (preUnpack != "") { inherit preUnpack; }
234236// lib.optionalAttrs (postUnpack != "") { inherit postUnpack; }
235237// lib.optionalAttrs (preConfigure != "") { inherit preConfigure; }
builder/default.nix+1−1
@@ -70,7 +70,7 @@ let
7070 comp-builder = haskellLib.weakCallPackage pkgs ./comp-builder.nix { inherit ghc haskellLib nonReinstallablePkgs; };
7171
7272 buildComp = componentId: component: comp-builder {
73− inherit componentId component package name src flags setup cabalFile patches
73+ inherit componentId component package name src flags setup cabalFile patches revision
7474 preUnpack postUnpack preConfigure postConfigure preBuild postBuild preCheck postCheck preInstall postInstall
7575 ;
7676 };
modules/package.nix+1−1
@@ -202,7 +202,7 @@ in {
202202 default = null;
203203 };
204204 patches = mkOption {
205− type = listOf (either package path);
205+ type = listOf (either unspecified path);
206206 default = [];
207207 };
208208 configureFlags = mkOption {
patches/default.nix−7
@@ -1,9 +1,2 @@
11{
2− ghc841 = import ./ghc841;
3− ghc842 = import ./ghc842;
4− ghc843 = import ./ghc843;
5− ghc844 = import ./ghc844;
6− ghc861 = import ./ghc861;
7− ghc862 = import ./ghc862;
8− ghc863 = import ./ghc863;
92}
patches/ghc843/default.nix+9−9
@@ -1,11 +1,11 @@
11{
2− packages.array.patches = [ ./array-0.5.2.0.patch ];
3− packages.deepseq.patches = [ ./deepseq-1.4.3.0.patch ];
4− packages.hpc.patches = [ ./hpc-0.6.0.3.patch ];
5− packages.parallel.patches = [ ./parallel-3.2.1.1.patch ];
6− packages.parsec.patches = [ ./parsec-3.1.13.0.patch ];
7− packages.random.patches = [ ./random-1.1.patch ];
8− packages.time.patches = [ ./time-1.8.0.2.patch ];
9− packages.unix.patches = [ ./unix-2.7.2.2.patch ];
10− packages.vector.patches = [ ./vector-0.11.0.0.patch ];
2+ packages.hpc.patches = [ ({ version, revision }: if version == "0.6.0.3.patch" && revision == 0 then ./hpc-0.6.0.3.patch else null) ];
3+ packages.array.patches = [ ({ version, revision }: if version == "0.5.2.0.patch" && revision == 0 then ./array-0.5.2.0.patch else null) ];
4+ packages.parsec.patches = [ ({ version, revision }: if version == "3.1.13.0.patch" && revision == 0 then ./parsec-3.1.13.0.patch else null) ];
5+ packages.random.patches = [ ({ version, revision }: if version == "1.1.patch" && revision == 0 then ./random-1.1.patch else null) ];
6+ packages.time.patches = [ ({ version, revision }: if version == "1.8.0.2.patch" && revision == 0 then ./time-1.8.0.2.patch else null) ];
7+ packages.deepseq.patches = [ ({ version, revision }: if version == "1.4.3.0.patch" && revision == 0 then ./deepseq-1.4.3.0.patch else null) ];
8+ packages.unix.patches = [ ({ version, revision }: if version == "2.7.2.2.patch" && revision == 0 then ./unix-2.7.2.2.patch else null) ];
9+ packages.parallel.patches = [ ({ version, revision }: if version == "3.2.1.1.patch" && revision == 0 then ./parallel-3.2.1.1.patch else null) ];
10+ packages.vector.patches = [ ({ version, revision }: if version == "0.11.0.0.patch" && revision == 0 then ./vector-0.11.0.0.patch else null) ];
1111}
patches/ghc844/default.nix+9−9
@@ -1,11 +1,11 @@
11{
2− packages.array.patches = [ ./array-0.5.2.0.patch ];
3− packages.deepseq.patches = [ ./deepseq-1.4.3.0.patch ];
4− packages.hpc.patches = [ ./hpc-0.6.0.3.patch ];
5− packages.parallel.patches = [ ./parallel-3.2.1.1.patch ];
6− packages.parsec.patches = [ ./parsec-3.1.13.0.patch ];
7− packages.random.patches = [ ./random-1.1.patch ];
8− packages.time.patches = [ ./time-1.8.0.2.patch ];
9− packages.unix.patches = [ ./unix-2.7.2.2.patch ];
10− packages.vector.patches = [ ./vector-0.11.0.0.patch ];
2+ packages.hpc.patches = [ ({ version, revision }: if version == "0.6.0.3.patch" && revision == 0 then ./hpc-0.6.0.3.patch else null) ];
3+ packages.array.patches = [ ({ version, revision }: if version == "0.5.2.0.patch" && revision == 0 then ./array-0.5.2.0.patch else null) ];
4+ packages.parsec.patches = [ ({ version, revision }: if version == "3.1.13.0.patch" && revision == 0 then ./parsec-3.1.13.0.patch else null) ];
5+ packages.random.patches = [ ({ version, revision }: if version == "1.1.patch" && revision == 0 then ./random-1.1.patch else null) ];
6+ packages.time.patches = [ ({ version, revision }: if version == "1.8.0.2.patch" && revision == 0 then ./time-1.8.0.2.patch else null) ];
7+ packages.deepseq.patches = [ ({ version, revision }: if version == "1.4.3.0.patch" && revision == 0 then ./deepseq-1.4.3.0.patch else null) ];
8+ packages.unix.patches = [ ({ version, revision }: if version == "2.7.2.2.patch" && revision == 0 then ./unix-2.7.2.2.patch else null) ];
9+ packages.parallel.patches = [ ({ version, revision }: if version == "3.2.1.1.patch" && revision == 0 then ./parallel-3.2.1.1.patch else null) ];
10+ packages.vector.patches = [ ({ version, revision }: if version == "0.11.0.0.patch" && revision == 0 then ./vector-0.11.0.0.patch else null) ];
1111}
patches/ghc861/default.nix+9−9
@@ -1,11 +1,11 @@
11{
2− packages.array.patches = [ ./array-0.5.2.0.patch ];
3− packages.binary.patches = [ ./binary-0.8.6.0.patch ];
4− packages.containers.patches = [ ./containers-0.6.0.1.patch ];
5− packages.hpc.patches = [ ./hpc-0.6.0.3.patch ];
6− packages.parsec.patches = [ ./parsec-3.1.13.0.patch ];
7− packages.process.patches = [ ./process-1.6.3.0.patch ];
8− packages.time.patches = [ ./time-1.8.0.2.patch ];
9− packages.transformers.patches = [ ./transformers-0.5.5.0.patch ];
10− packages.unix.patches = [ ./unix-2.7.2.2.patch ];
2+ packages.hpc.patches = [ ({ version, revision }: if version == "0.6.0.3.patch" && revision == 0 then ./hpc-0.6.0.3.patch else null) ];
3+ packages.containers.patches = [ ({ version, revision }: if version == "0.6.0.1.patch" && revision == 0 then ./containers-0.6.0.1.patch else null) ];
4+ packages.binary.patches = [ ({ version, revision }: if version == "0.8.6.0.patch" && revision == 0 then ./binary-0.8.6.0.patch else null) ];
5+ packages.array.patches = [ ({ version, revision }: if version == "0.5.2.0.patch" && revision == 0 then ./array-0.5.2.0.patch else null) ];
6+ packages.parsec.patches = [ ({ version, revision }: if version == "3.1.13.0.patch" && revision == 0 then ./parsec-3.1.13.0.patch else null) ];
7+ packages.time.patches = [ ({ version, revision }: if version == "1.8.0.2.patch" && revision == 0 then ./time-1.8.0.2.patch else null) ];
8+ packages.unix.patches = [ ({ version, revision }: if version == "2.7.2.2.patch" && revision == 0 then ./unix-2.7.2.2.patch else null) ];
9+ packages.process.patches = [ ({ version, revision }: if version == "1.6.3.0.patch" && revision == 0 then ./process-1.6.3.0.patch else null) ];
10+ packages.transformers.patches = [ ({ version, revision }: if version == "0.5.5.0.patch" && revision == 0 then ./transformers-0.5.5.0.patch else null) ];
1111}
patches/ghc862/default.nix+8−8
@@ -1,10 +1,10 @@
11{
2− packages.binary.patches = [ ./binary-0.8.6.0.patch ];
3− packages.containers.patches = [ ./containers-0.6.0.1.patch ];
4− packages.hpc.patches = [ ./hpc-0.6.0.3.patch ];
5− packages.parsec.patches = [ ./parsec-3.1.13.0.patch ];
6− packages.process.patches = [ ./process-1.6.3.0.patch ];
7− packages.time.patches = [ ./time-1.8.0.2.patch ];
8− packages.transformers.patches = [ ./transformers-0.5.5.0.patch ];
9− packages.unix.patches = [ ./unix-2.7.2.2.patch ];
2+ packages.hpc.patches = [ ({ version, revision }: if version == "0.6.0.3.patch" && revision == 0 then ./hpc-0.6.0.3.patch else null) ];
3+ packages.containers.patches = [ ({ version, revision }: if version == "0.6.0.1.patch" && revision == 0 then ./containers-0.6.0.1.patch else null) ];
4+ packages.binary.patches = [ ({ version, revision }: if version == "0.8.6.0.patch" && revision == 0 then ./binary-0.8.6.0.patch else null) ];
5+ packages.parsec.patches = [ ({ version, revision }: if version == "3.1.13.0.patch" && revision == 0 then ./parsec-3.1.13.0.patch else null) ];
6+ packages.time.patches = [ ({ version, revision }: if version == "1.8.0.2.patch" && revision == 0 then ./time-1.8.0.2.patch else null) ];
7+ packages.unix.patches = [ ({ version, revision }: if version == "2.7.2.2.patch" && revision == 0 then ./unix-2.7.2.2.patch else null) ];
8+ packages.process.patches = [ ({ version, revision }: if version == "1.6.3.0.patch" && revision == 0 then ./process-1.6.3.0.patch else null) ];
9+ packages.transformers.patches = [ ({ version, revision }: if version == "0.5.5.0.patch" && revision == 0 then ./transformers-0.5.5.0.patch else null) ];
1010}
patches/ghc863/default.nix+8−8
@@ -1,10 +1,10 @@
11{
2− packages.binary.patches = [ ./binary-0.8.6.0.patch ];
3− packages.containers.patches = [ ./containers-0.6.0.1.patch ];
4− packages.hpc.patches = [ ./hpc-0.6.0.3.patch ];
5− packages.parsec.patches = [ ./parsec-3.1.13.0.patch ];
6− packages.process.patches = [ ./process-1.6.3.0.patch ];
7− packages.time.patches = [ ./time-1.8.0.2.patch ];
8− packages.transformers.patches = [ ./transformers-0.5.5.0.patch ];
9− packages.unix.patches = [ ./unix-2.7.2.2.patch ];
2+ packages.hpc.patches = [ ({ version, revision }: if version == "0.6.0.3.patch" && revision == 0 then ./hpc-0.6.0.3.patch else null) ];
3+ packages.containers.patches = [ ({ version, revision }: if version == "0.6.0.1.patch" && revision == 0 then ./containers-0.6.0.1.patch else null) ];
4+ packages.binary.patches = [ ({ version, revision }: if version == "0.8.6.0.patch" && revision == 0 then ./binary-0.8.6.0.patch else null) ];
5+ packages.parsec.patches = [ ({ version, revision }: if version == "3.1.13.0.patch" && revision == 0 then ./parsec-3.1.13.0.patch else null) ];
6+ packages.time.patches = [ ({ version, revision }: if version == "1.8.0.2.patch" && revision == 0 then ./time-1.8.0.2.patch else null) ];
7+ packages.unix.patches = [ ({ version, revision }: if version == "2.7.2.2.patch" && revision == 0 then ./unix-2.7.2.2.patch else null) ];
8+ packages.process.patches = [ ({ version, revision }: if version == "1.6.3.0.patch" && revision == 0 then ./process-1.6.3.0.patch else null) ];
9+ packages.transformers.patches = [ ({ version, revision }: if version == "0.5.5.0.patch" && revision == 0 then ./transformers-0.5.5.0.patch else null) ];
1010}
patches/update-patches.shnew file+11
@@ -0,0 +1,11 @@
1+#!/bin/bash
2+for ghc in $(find . -name "ghc*" -type d); do
3+ (cd $ghc
4+ echo "{" > default.nix
5+ (for a in $(find . -name "*.patch" -type f); do
6+ b=${a%%.patch};
7+ b=${a##./};
8+ echo " packages.${b%%-*}.patches = [ ({ version, revision }: if version == \"${b##*-}\" && revision == 0 then $a else null) ];" >> default.nix
9+ done) || true
10+ echo "}" >> default.nix)
11+done