|
1 | 1 | { pkgs, runCommand, cacert, index-state-hashes, haskellLib }@defaults:
|
2 | 2 | let readIfExists = src: fileName:
|
| 3 | + # Using origSrcSubDir bypasses any cleanSourceWith. |
3 | 4 | let origSrcDir = src.origSrcSubDir or src;
|
4 | 5 | in
|
5 | 6 | if builtins.elem ((__readDir origSrcDir)."${fileName}" or "") ["regular" "symlink"]
|
@@ -122,24 +123,38 @@ let
|
122 | 123 | type == "directory" ||
|
123 | 124 | pkgs.lib.any (i: (pkgs.lib.hasSuffix i path)) [ ".cabal" "package.yaml" ]); };
|
124 | 125 |
|
125 |
| - # Using origSrcSubDir bypasses any cleanSourceWith so that it will work when |
126 |
| - # access to the store is restricted. If origSrc was already in the store |
127 |
| - # you can pass the project in as a string. |
128 |
| - rawCabalProject = |
129 |
| - # Even if `cabal.project` doesn't exist, `cabal.project.local` is still used by cabal. |
130 |
| - # We tested this: https://github.com/input-output-hk/haskell.nix/pull/1588 |
131 |
| - if cabalProject == null && cabalProjectLocal == null |
132 |
| - then null |
133 |
| - else ( |
134 |
| - # like fmap |
135 |
| - let f = g: x: if x == null then "" else g x; in |
136 |
| - f (x: x) cabalProject + f (x: "\n-- Added from cabalProjectLocal argument to cabalProject\n${x}") cabalProjectLocal |
137 |
| - ); |
138 |
| - |
139 |
| - cabalProjectIndexState = |
140 |
| - if rawCabalProject != null |
141 |
| - then pkgs.haskell-nix.haskellLib.parseIndexState rawCabalProject |
142 |
| - else null; |
| 126 | + # When there is no `cabal.project` file `cabal-install` behaves as if there was |
| 127 | + # one containing `packages: ./*.cabal`. Even if there is a `cabal.project.local` |
| 128 | + # containing some other `packages:`, it still includes `./*.cabal`. |
| 129 | + # |
| 130 | + # We could write to `cabal.project.local` instead of `cabal.project` when |
| 131 | + # `cabalProject == null`. However then `cabal-install` will look in parent |
| 132 | + # directories for a `cabal.project` file. That would complicate reasoning about |
| 133 | + # the relative directories of packages. |
| 134 | + # |
| 135 | + # Instead we treat `cabalProject == null` as if it was `packages: ./*.cabal`. |
| 136 | + # |
| 137 | + # See: https://github.com/input-output-hk/haskell.nix/pull/1588 |
| 138 | + # https://github.com/input-output-hk/haskell.nix/pull/1639 |
| 139 | + # |
| 140 | + rawCabalProject = '' |
| 141 | + ${ |
| 142 | + if cabalProject == null |
| 143 | + then '' |
| 144 | + -- Included to match the implicit project used by `cabal-install` |
| 145 | + packages: ./*.cabal |
| 146 | + '' |
| 147 | + else cabalProject |
| 148 | + } |
| 149 | + ${ |
| 150 | + pkgs.lib.optionalString (cabalProjectLocal != null) '' |
| 151 | + -- Added from `cabalProjectLocal` argument to the `cabalProject` function |
| 152 | + ${cabalProjectLocal} |
| 153 | + '' |
| 154 | + } |
| 155 | + ''; |
| 156 | + |
| 157 | + cabalProjectIndexState = pkgs.haskell-nix.haskellLib.parseIndexState rawCabalProject; |
143 | 158 |
|
144 | 159 | index-state-found =
|
145 | 160 | if index-state != null
|
|
292 | 307 | );
|
293 | 308 | };
|
294 | 309 |
|
295 |
| - fixedProject = |
296 |
| - if rawCabalProject == null |
297 |
| - then { sourceRepos = []; repos = {}; extra-hackages = []; makeFixedProjectFile = ""; replaceLocations = ""; } |
298 |
| - else replaceSourceRepos rawCabalProject; |
| 310 | + fixedProject = replaceSourceRepos rawCabalProject; |
299 | 311 |
|
300 | 312 | # The use of the actual GHC can cause significant problems:
|
301 | 313 | # * For hydra to assemble a list of jobs from `components.tests` it must
|
|
0 commit comments