Skip to content

Looking up package revisions in inputMap #1650

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

Closed
wants to merge 4 commits into from
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
4 changes: 2 additions & 2 deletions builder/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ pkgs, buildPackages, evalPackages, stdenv, lib, haskellLib, ghc, compiler-nix-name, fetchurl, pkgconfig, nonReinstallablePkgs, hsPkgs, compiler }:
{ pkgs, buildPackages, evalPackages, stdenv, lib, haskellLib, ghc, compiler-nix-name, fetchurl, pkgconfig, nonReinstallablePkgs, hsPkgs, compiler, inputMap }:

let
# Builds a single component of a package.
Expand Down Expand Up @@ -83,7 +83,7 @@ in {
# Build a Haskell package from its config.
# TODO: this pkgs is the adjusted pkgs, but pkgs.pkgs is unadjusted
build-package = haskellLib.weakCallPackage pkgs ./hspkg-builder.nix {
inherit haskellLib ghc compiler-nix-name comp-builder setup-builder;
inherit haskellLib ghc compiler-nix-name comp-builder setup-builder inputMap;
};

inherit shellFor makeConfigFiles;
Expand Down
23 changes: 17 additions & 6 deletions builder/hspkg-builder.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ pkgs, buildPackages, stdenv, lib, haskellLib, ghc, compiler-nix-name, fetchurl, runCommand, comp-builder, setup-builder }:
{ pkgs, buildPackages, stdenv, lib, haskellLib, ghc, compiler-nix-name, fetchurl, runCommand, comp-builder, setup-builder, inputMap }:

config:
{ flags
Expand Down Expand Up @@ -30,12 +30,23 @@ let
"ghc902/filepath-1.4.2.1" = "/libraries/filepath";
}."${compiler-nix-name}/${name}" or null;
src = if bundledSrc == null then pkg.src else ghc.configured-src + bundledSrc;
baseUrlMatch = __match "(.*)/package/[^/]*" pkg.src.url;
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;
};
if pkgs.lib.hasPrefix "mirror://hackage/" pkg.src.url
then fetchurl {
name = "${name}-${toString revision}.cabal";
url = "https://hackage.haskell.org/package/${name}/revision/${toString revision}.cabal";
sha256 = revisionSha256;
}
else if baseUrlMatch != null
then builtins.path {
path = inputMap.${__head baseUrlMatch}
or (throw "Unable to find inputMap entry for repository '${__head baseUrlMatch}' while looking for '${package.identifier.name}' revision.")
+ "/index/${package.identifier.name}/${package.identifier.version}/${package.identifier.name}.cabal";
sha256 = revisionSha256;
recursive = false;
}
else throw "Unexpected url '${pkg.src.url}' format while looking for '${package.identifier.name}' revision";

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

Expand Down
7 changes: 6 additions & 1 deletion modules/component-driver.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ let
inherit haskellLib;
ghc = config.ghc.package;
compiler-nix-name = config.compiler.nix-name;
inherit (config) nonReinstallablePkgs hsPkgs compiler evalPackages;
inherit (config) nonReinstallablePkgs hsPkgs compiler evalPackages inputMap;
};

in
Expand Down Expand Up @@ -89,6 +89,11 @@ in
__elem config.compiler.nix-name ["ghc901" "ghc902" "ghc921" "ghc922" "ghc923" "ghc924"]) [
"ghc-bignum" ];

options.inputMap = lib.mkOption {
type = lib.types.attrsOf lib.types.unspecified;
default = {};
};

options.hsPkgs = lib.mkOption {
type = lib.types.unspecified;
};
Expand Down
3 changes: 2 additions & 1 deletion overlays/haskell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ final: prev: {
# plan-nix without building the project.
cabalProject' =
projectModule: haskellLib.evalProjectModule ../modules/cabal-project.nix projectModule (
{ src, compiler-nix-name, evalPackages, ... }@args:
{ src, compiler-nix-name, evalPackages, inputMap, ... }@args:
let
callProjectResults = callCabalProjectToNix args;
plan-pkgs = importAndFilterProject {
Expand Down Expand Up @@ -538,6 +538,7 @@ final: prev: {
++ [ {
compiler.nix-name = final.lib.mkForce args.compiler-nix-name;
evalPackages = final.lib.mkDefault evalPackages;
inputMap = final.lib.mkDefault inputMap;
} ];
extra-hackages = args.extra-hackages or [] ++ callProjectResults.extra-hackages;
};
Expand Down