|
138 | 138 | if sha256map != null
|
139 | 139 | then sha256map.${attrs.url} or null
|
140 | 140 | else null);
|
| 141 | + # Find store directory strings and include them in the string context |
| 142 | + addContext = s: |
| 143 | + let storeDirMatch = builtins.match ".*(${builtins.storeDir}/[^/]+).*" s; |
| 144 | + in if storeDirMatch == null |
| 145 | + then s |
| 146 | + else builtins.appendContext s { ${builtins.head storeDirMatch} = { path = true; }; }; |
141 | 147 | in rec {
|
142 | 148 | # This is `some-name` from the `repository some-name` line in the `cabal.project` file.
|
143 |
| - name = __head lines; |
| 149 | + name = builtins.unsafeDiscardStringContext (__head lines); |
144 | 150 | # The $HOME/.cabal/packages/${name} after running `cabal v2-update` to download the repository
|
145 | 151 | repoContents = if inputMap ? ${attrs.url}
|
146 | 152 | # If there is an input use it to make `file:` url and create a suitable `.cabal/packages/${name}` directory
|
|
174 | 180 | mkdir -p $HOME/.cabal/packages/${name}
|
175 | 181 | cat <<EOF > $HOME/.cabal/config
|
176 | 182 | repository ${name}
|
177 |
| - url: ${attrs.url} |
| 183 | + url: ${addContext attrs.url} |
178 | 184 | ${pkgs.lib.optionalString (attrs ? secure) "secure: ${attrs.secure}"}
|
179 | 185 | ${pkgs.lib.optionalString (attrs ? root-keys) "root-keys: ${attrs.root-keys}"}
|
180 | 186 | ${pkgs.lib.optionalString (attrs ? key-threshold) "key-threshold: ${attrs.key-threshold}"}
|
|
195 | 201 | hackage-to-nix $out ${repoContents}/01-index.tar ${attrs.url}
|
196 | 202 | '');
|
197 | 203 | # Directory to `lndir` when constructing a suitable $HOME/.cabal dir
|
198 |
| - repo = { |
199 |
| - # Strings used as attrset keys can't have contet. This can cause problems if the cabal.project file has antiquoted strings |
200 |
| - # in it. Discarding the context here works, and because 'name' is used elsewhere, we don't actually lose the string content, |
201 |
| - # which can matter! |
202 |
| - ${builtins.unsafeDiscardStringContext name} = repoContents; |
203 |
| - }; |
| 204 | + repo.${name} = repoContents; |
204 | 205 | };
|
205 | 206 |
|
206 | 207 | parseRepositories = evalPackages: cabalProjectFileName: sha256map: inputMap: cabal-install: nix-tools: projectFile:
|
|
0 commit comments