Skip to content

Commit 7075077

Browse files
Support revisions and more (#1775)
* Support revisions Cabal files are now obtained from the index tarball (as cabal does) directly. This allows us to always pick the cabal file revision that cabal would pick, without having to understand or reference hackage. * Update nix-tools materialised plan for new tooling * Update materialized files * Eval on x86_64-linux * Turn off full materialization check * Replace pkgs.writeText with passAsFile Nix derivations are already able to pass a attribute to the builder as a file. This means we don't need to use pkgs.writeText to turn the cabalFile attribute into a file, saving one derivation. * Bump closure size limit to 540 --------- Co-authored-by: Hamish Mackenzie <[email protected]>
1 parent 0d3dea7 commit 7075077

File tree

3,670 files changed

+252181
-11722
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3,670 files changed

+252181
-11722
lines changed

builder/comp-builder.nix

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ let self =
88
, setup
99
, src
1010
, flags
11-
, revision
1211
, cabalFile
1312
, cabal-generator
1413
, patches ? []
@@ -246,12 +245,12 @@ let
246245
&& x.identifier.name or "" != "hsc2hs")
247246
(map
248247
(p: if builtins.isFunction p
249-
then p { inherit (package.identifier) version; inherit revision; }
248+
then p { inherit (package.identifier) version; }
250249
else p) build-tools))) ++
251250
lib.optional (pkgconfig != []) buildPackages.cabalPkgConfigWrapper;
252251

253252
# Unfortunately, we need to wrap ghc commands for cabal builds to
254-
# work in the nix-shell. See ../doc/removing-with-package-wrapper.md.
253+
# work in the nix-shell. See ../docs/dev/removing-with-package-wrapper.md.
255254
shellWrappers = ghcForComponent {
256255
componentName = fullName;
257256
inherit configFiles enableDWARF;
@@ -279,6 +278,9 @@ let
279278

280279
SETUP_HS = setup + /bin/Setup;
281280

281+
inherit cabalFile;
282+
passAsFile = [ "cabalFile" ];
283+
282284
prePatch =
283285
# If the package is in a sub directory `cd` there first.
284286
# In some cases the `cleanSrc.subDir` will be empty and the `.cabal`
@@ -292,7 +294,7 @@ let
292294
''
293295
) +
294296
(if cabalFile != null
295-
then ''cat ${cabalFile} > ${package.identifier.name}.cabal''
297+
then ''cp -v $cabalFilePath ${package.identifier.name}.cabal''
296298
else
297299
# When building hpack package we use the internal nix-tools
298300
# (compiled with a fixed GHC version)
@@ -301,11 +303,11 @@ let
301303
''
302304
);
303305
}
304-
# patches can (if they like) depend on the version and revision of the package.
306+
# patches can (if they like) depend on the version of the package.
305307
// lib.optionalAttrs (patches != []) {
306308
patches = map (p:
307309
if builtins.isFunction p
308-
then p { inherit (package.identifier) version; inherit revision; }
310+
then p { inherit (package.identifier) version; }
309311
else p
310312
) patches;
311313
}
@@ -323,7 +325,7 @@ let
323325

324326
haddock = haddockBuilder {
325327
inherit componentId component package flags commonConfigureFlags
326-
commonAttrs revision doHaddock
328+
commonAttrs doHaddock
327329
doHoogle hyperlinkSource quickjump setupHaddockFlags
328330
needsProfiling configFiles preHaddock postHaddock pkgconfig;
329331

builder/haddock-builder.nix

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
, component
55
, package
66
, flags
7-
, revision
87
, commonAttrs
98
, preHaddock
109
, postHaddock

builder/hspkg-builder.nix

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ config:
99
, name
1010
, sha256
1111
, src
12-
, revision
13-
, revisionSha256
12+
, package-description-override
1413
, patches
1514

1615
, shellHook
@@ -48,12 +47,8 @@ let
4847
# repository.
4948
inputMap.${__head baseUrlMatch} + "/package/${__elemAt baseUrlMatch 1}"
5049
else pkg.src;
51-
cabalFile = if revision == null || revision == 0 || bundledSrc != null then null else
52-
fetchurl {
53-
name = "${name}-${toString revision}.cabal";
54-
url = "https://hackage.haskell.org/package/${name}/revision/${toString revision}.cabal";
55-
sha256 = revisionSha256;
56-
};
50+
51+
cabalFile = if package-description-override == null || bundledSrc != null then null else package-description-override;
5752

5853
defaultSetupSrc = if stdenv.hostPlatform.isGhcjs then ./Setup.ghcjs.hs else ./Setup.hs;
5954

@@ -134,12 +129,12 @@ let
134129
extraSrcFiles = components.setup.extraSrcFiles ++ [ "Setup.hs" "Setup.lhs" ];
135130
pkgconfig = if components ? library then components.library.pkgconfig or [] else [];
136131
};
137-
inherit package name src flags revision patches defaultSetupSrc;
132+
inherit package name src flags patches defaultSetupSrc;
138133
inherit (pkg) preUnpack postUnpack;
139134
};
140135

141136
buildComp = allComponent: componentId: component: comp-builder {
142-
inherit allComponent componentId component package name src flags setup cabalFile cabal-generator patches revision
137+
inherit allComponent componentId component package name src flags setup cabalFile cabal-generator patches
143138
shellHook
144139
;
145140
};
@@ -150,7 +145,7 @@ in rec {
150145
(_: d: haskellLib.check d)
151146
(lib.filterAttrs (_: d: d.config.doCheck) components.tests));
152147
inherit (package) identifier detailLevel isLocal isProject buildType;
153-
inherit setup cabalFile;
148+
inherit setup;
154149
isHaskell = true;
155150
inherit src;
156151
}

builder/setup-builder.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ let
105105
cd ${lib.removePrefix "/" cleanSrc'.subDir}
106106
'';
107107
})
108-
// (lib.optionalAttrs (patches != []) { patches = map (p: if builtins.isFunction p then p { inherit (package.identifier) version; inherit revision; } else p) patches; })
108+
// (lib.optionalAttrs (patches != []) { patches = map (p: if builtins.isFunction p then p { inherit (package.identifier) version; } else p) patches; })
109109
// hooks
110110
);
111111
in drv; in self

lib/cabal-project-parser.nix

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ let
157157
${pkgs.lib.optionalString (attrs ? root-keys) "root-keys: ${attrs.root-keys}"}
158158
${pkgs.lib.optionalString (attrs ? key-threshold) "key-threshold: ${attrs.key-threshold}"}
159159
EOF
160-
161160
cabal v2-update ${name}
162161
cp -r $HOME/.cabal/packages/${name} $out
163162
''
@@ -180,7 +179,6 @@ let
180179
${pkgs.lib.optionalString (attrs ? root-keys) "root-keys: ${attrs.root-keys}"}
181180
${pkgs.lib.optionalString (attrs ? key-threshold) "key-threshold: ${attrs.key-threshold}"}
182181
EOF
183-
184182
export SSL_CERT_FILE=${evalPackages.cacert}/etc/ssl/certs/ca-bundle.crt
185183
cabal v2-update ${name}
186184
cp -r $HOME/.cabal/packages/${name} $out

lib/call-cabal-project-to-nix.nix

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -527,12 +527,8 @@ let
527527
export SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt
528528
export GIT_SSL_CAINFO=${cacert}/etc/ssl/certs/ca-bundle.crt
529529
530-
# Using `cabal v2-freeze` will configure the project (since
531-
# it is not configured yet), taking the existing `cabal.project.freeze`
532-
# file into account. Then it "writes out a freeze file which
533-
# records all of the versions and flags that are picked" (from cabal docs).
534530
echo "Using index-state ${index-state-found}"
535-
HOME=${
531+
CABAL_DIR=${
536532
# This creates `.cabal` directory that is as it would have
537533
# been at the time `cached-index-state`. We may include
538534
# some packages that will be excluded by `index-state-found`
@@ -543,7 +539,7 @@ let
543539
index-state = cached-index-state;
544540
sha256 = index-sha256-found;
545541
}
546-
} cabal v2-freeze ${
542+
} make-install-plan ${
547543
# Setting the desired `index-state` here in case it is not
548544
# in the cabal.project file. This will further restrict the
549545
# packages used by the solver (cached-index-state >= index-state-found).
@@ -596,6 +592,11 @@ let
596592
# as they should not be in the output hash (they may change slightly
597593
# without affecting the nix).
598594
find $out \( -type f -or -type l \) ! -name '*.nix' -delete
595+
596+
# Make the revised cabal files available (after the delete step avove)
597+
echo "Moving cabal files from $tmp${subDir'}/dist-newstyle/cabal-files to $out${subDir'}/cabal-files"
598+
mv $tmp${subDir'}/dist-newstyle/cabal-files $out${subDir'}/cabal-files
599+
599600
# Remove empty dirs
600601
find $out -type d -empty -delete
601602

materialized/dummy-ghc/ghc-8.10.4.20210212-x86_64-linux/ghc-pkg/dump-global

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

materialized/dummy-ghc/ghc-8.10.4.20210212-x86_64-linux/ghc/info

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

materialized/dummy-ghc/ghc-8.8.3-aarch64-linux/ghc-pkg/dump-global

Lines changed: 76 additions & 77 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)