Skip to content

Support revisions and more #1775

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

Merged
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
16 changes: 9 additions & 7 deletions builder/comp-builder.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ let self =
, setup
, src
, flags
, revision
, cabalFile
, cabal-generator
, patches ? []
Expand Down Expand Up @@ -246,12 +245,12 @@ let
&& x.identifier.name or "" != "hsc2hs")
(map
(p: if builtins.isFunction p
then p { inherit (package.identifier) version; inherit revision; }
then p { inherit (package.identifier) version; }
else p) build-tools))) ++
lib.optional (pkgconfig != []) buildPackages.cabalPkgConfigWrapper;

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

SETUP_HS = setup + /bin/Setup;

inherit cabalFile;
passAsFile = [ "cabalFile" ];

prePatch =
# If the package is in a sub directory `cd` there first.
# In some cases the `cleanSrc.subDir` will be empty and the `.cabal`
Expand All @@ -292,7 +294,7 @@ let
''
) +
(if cabalFile != null
then ''cat ${cabalFile} > ${package.identifier.name}.cabal''
then ''cp -v $cabalFilePath ${package.identifier.name}.cabal''
else
# When building hpack package we use the internal nix-tools
# (compiled with a fixed GHC version)
Expand All @@ -301,11 +303,11 @@ let
''
);
}
# patches can (if they like) depend on the version and revision of the package.
# patches can (if they like) depend on the version of the package.
// lib.optionalAttrs (patches != []) {
patches = map (p:
if builtins.isFunction p
then p { inherit (package.identifier) version; inherit revision; }
then p { inherit (package.identifier) version; }
else p
) patches;
}
Expand All @@ -323,7 +325,7 @@ let

haddock = haddockBuilder {
inherit componentId component package flags commonConfigureFlags
commonAttrs revision doHaddock
commonAttrs doHaddock
doHoogle hyperlinkSource quickjump setupHaddockFlags
needsProfiling configFiles preHaddock postHaddock pkgconfig;

Expand Down
1 change: 0 additions & 1 deletion builder/haddock-builder.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
, component
, package
, flags
, revision
, commonAttrs
, preHaddock
, postHaddock
Expand Down
17 changes: 6 additions & 11 deletions builder/hspkg-builder.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ config:
, name
, sha256
, src
, revision
, revisionSha256
, package-description-override
, patches

, shellHook
Expand Down Expand Up @@ -48,12 +47,8 @@ let
# repository.
inputMap.${__head baseUrlMatch} + "/package/${__elemAt baseUrlMatch 1}"
else pkg.src;
cabalFile = if revision == null || revision == 0 || bundledSrc != null then null else
fetchurl {
name = "${name}-${toString revision}.cabal";
url = "https://hackage.haskell.org/package/${name}/revision/${toString revision}.cabal";
sha256 = revisionSha256;
};

cabalFile = if package-description-override == null || bundledSrc != null then null else package-description-override;

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

Expand Down Expand Up @@ -134,12 +129,12 @@ let
extraSrcFiles = components.setup.extraSrcFiles ++ [ "Setup.hs" "Setup.lhs" ];
pkgconfig = if components ? library then components.library.pkgconfig or [] else [];
};
inherit package name src flags revision patches defaultSetupSrc;
inherit package name src flags patches defaultSetupSrc;
inherit (pkg) preUnpack postUnpack;
};

buildComp = allComponent: componentId: component: comp-builder {
inherit allComponent componentId component package name src flags setup cabalFile cabal-generator patches revision
inherit allComponent componentId component package name src flags setup cabalFile cabal-generator patches
shellHook
;
};
Expand All @@ -150,7 +145,7 @@ in rec {
(_: d: haskellLib.check d)
(lib.filterAttrs (_: d: d.config.doCheck) components.tests));
inherit (package) identifier detailLevel isLocal isProject buildType;
inherit setup cabalFile;
inherit setup;
isHaskell = true;
inherit src;
}
2 changes: 1 addition & 1 deletion builder/setup-builder.nix
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ let
cd ${lib.removePrefix "/" cleanSrc'.subDir}
'';
})
// (lib.optionalAttrs (patches != []) { patches = map (p: if builtins.isFunction p then p { inherit (package.identifier) version; inherit revision; } else p) patches; })
// (lib.optionalAttrs (patches != []) { patches = map (p: if builtins.isFunction p then p { inherit (package.identifier) version; } else p) patches; })
// hooks
);
in drv; in self
2 changes: 0 additions & 2 deletions lib/cabal-project-parser.nix
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ let
${pkgs.lib.optionalString (attrs ? root-keys) "root-keys: ${attrs.root-keys}"}
${pkgs.lib.optionalString (attrs ? key-threshold) "key-threshold: ${attrs.key-threshold}"}
EOF

cabal v2-update ${name}
cp -r $HOME/.cabal/packages/${name} $out
''
Expand All @@ -180,7 +179,6 @@ let
${pkgs.lib.optionalString (attrs ? root-keys) "root-keys: ${attrs.root-keys}"}
${pkgs.lib.optionalString (attrs ? key-threshold) "key-threshold: ${attrs.key-threshold}"}
EOF

export SSL_CERT_FILE=${evalPackages.cacert}/etc/ssl/certs/ca-bundle.crt
cabal v2-update ${name}
cp -r $HOME/.cabal/packages/${name} $out
Expand Down
13 changes: 7 additions & 6 deletions lib/call-cabal-project-to-nix.nix
Original file line number Diff line number Diff line change
Expand Up @@ -527,12 +527,8 @@ let
export SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt
export GIT_SSL_CAINFO=${cacert}/etc/ssl/certs/ca-bundle.crt

# Using `cabal v2-freeze` will configure the project (since
# it is not configured yet), taking the existing `cabal.project.freeze`
# file into account. Then it "writes out a freeze file which
# records all of the versions and flags that are picked" (from cabal docs).
echo "Using index-state ${index-state-found}"
HOME=${
CABAL_DIR=${
# This creates `.cabal` directory that is as it would have
# been at the time `cached-index-state`. We may include
# some packages that will be excluded by `index-state-found`
Expand All @@ -543,7 +539,7 @@ let
index-state = cached-index-state;
sha256 = index-sha256-found;
}
} cabal v2-freeze ${
} make-install-plan ${
# Setting the desired `index-state` here in case it is not
# in the cabal.project file. This will further restrict the
# packages used by the solver (cached-index-state >= index-state-found).
Expand Down Expand Up @@ -596,6 +592,11 @@ let
# as they should not be in the output hash (they may change slightly
# without affecting the nix).
find $out \( -type f -or -type l \) ! -name '*.nix' -delete

# Make the revised cabal files available (after the delete step avove)
echo "Moving cabal files from $tmp${subDir'}/dist-newstyle/cabal-files to $out${subDir'}/cabal-files"
mv $tmp${subDir'}/dist-newstyle/cabal-files $out${subDir'}/cabal-files

# Remove empty dirs
find $out -type d -empty -delete

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

153 changes: 76 additions & 77 deletions materialized/dummy-ghc/ghc-8.8.3-aarch64-linux/ghc-pkg/dump-global

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading