on iko/ghcjs-patch-master help sign in
call-cabal-project-to-nix: Allow overriding source-repository-package entries. (#1354)
50fd86fShea Levy
lib/call-cabal-project-to-nix.nix+20−1
@@ -37,6 +37,24 @@ in
37 then { location, tag, ...}: sha256map."${location}"."${tag}"
37 then { location, tag, ...}: sha256map."${location}"."${tag}"
38 else _: null
38 else _: null
39, extra-hackage-tarballs ? []
39, extra-hackage-tarballs ? []
40+, source-repo-override ? {} # Cabal seems to behave incoherently when
41+ # two source-repository-package entries
42+ # provide the same packages, making it
43+ # impossible to override cabal.project
44+ # with e.g. a cabal.project.local. In CI,
45+ # we want to be able to test against the
46+ # latest versions of various dependencies.
47+ #
48+ # This argument is a map from url to
49+ # a function taking the existing repoData
50+ # and returning the new repoData in its
51+ # place. E.g.
52+ #
53+ # { "https://github.com/input-output-hk/plutus-apps" = orig: orig // { subdirs = (orig.subdirs or [ "." ]) ++ [ "foo" ]; }; }
54+ #
55+ # would result in the "foo" subdirectory of
56+ # any plutus-apps input being used for a
57+ # package.
40, ...
58, ...
41}@args:
59}@args:
42
60
@@ -206,7 +224,8 @@ let
206 blocks = pkgs.lib.splitString "\nsource-repository-package\n" ("\n" + projectFile);
224 blocks = pkgs.lib.splitString "\nsource-repository-package\n" ("\n" + projectFile);
207 initialText = pkgs.lib.lists.take 1 blocks;
225 initialText = pkgs.lib.lists.take 1 blocks;
208 repoBlocks = builtins.map (pkgs.haskell-nix.haskellLib.parseBlock cabalProjectFileName lookupSha256) (pkgs.lib.lists.drop 1 blocks);
226 repoBlocks = builtins.map (pkgs.haskell-nix.haskellLib.parseBlock cabalProjectFileName lookupSha256) (pkgs.lib.lists.drop 1 blocks);
227+ overrideSourceRepo = sourceRepo: (source-repo-override.${sourceRepo.url} or (pkgs.lib.id)) sourceRepo;
209− sourceRepoData = pkgs.lib.lists.map (x: x.sourceRepo) repoBlocks;
228+ sourceRepoData = pkgs.lib.lists.map (x: overrideSourceRepo x.sourceRepo) repoBlocks;
210 otherText = pkgs.evalPackages.writeText "cabal.project" (pkgs.lib.strings.concatStringsSep "\n" (
229 otherText = pkgs.evalPackages.writeText "cabal.project" (pkgs.lib.strings.concatStringsSep "\n" (
211 initialText
230 initialText
212 ++ (builtins.map (x: x.otherText) repoBlocks)));
231 ++ (builtins.map (x: x.otherText) repoBlocks)));
modules/cabal-project.nix+4
@@ -115,6 +115,10 @@ in {
115 type = nullOr (listOf unspecified);
115 type = nullOr (listOf unspecified);
116 default = [];
116 default = [];
117 };
117 };
118+ source-repo-override = mkOption {
119+ type = attrsOf (functionTo attrs);
120+ default = {};
121+ };
118
122
119 # Used by mkCabalProjectPkgSet
123 # Used by mkCabalProjectPkgSet
120 pkg-def-extras = mkOption {
124 pkg-def-extras = mkOption {