@@ -285,18 +285,34 @@ self: super: {
286 sha256String = if isNull sha256 then self.buildPackages.lib.fakeSha256 else sha256;
286 sha256String = if isNull sha256 then self.buildPackages.lib.fakeSha256 else sha256;
288− in "${url} ${rev} ${subdir} ${sha256String} ${name} ${nix-expr}";
289+ line = "${url} ${rev} ${subdir} ${sha256String} ${name}";
290 # Given a list of repos:
293 # Given a list of repos:
291 # [ { name = ...; url = ...; rev = ...; ref = ...; sha256 = ...; cabal-file = ...; type = ...; is-private = ...; } ]
294 # [ { name = ...; url = ...; rev = ...; ref = ...; sha256 = ...; cabal-file = ...; type = ...; is-private = ...; } ]
292 # produce a cache file that can be used for
295 # produce a cache file that can be used for
293 # stack-to-nix or plan-to-nix to prevent them
296 # stack-to-nix or plan-to-nix to prevent them
294 # from needing network access.
297 # from needing network access.
298+ # The cache contains only local paths to nix files so that it can
299+ # the results of `stack-to-nix` can be imported in restrected eval
295 mkCacheFile = repos:
301 mkCacheFile = repos:
296− self.buildPackages.pkgs.writeTextFile {
302+ self.buildPackages.pkgs.runCommand "cache-file" {} ''
297− name = "cache-file";
303+ mkdir -p $out
298− text = self.buildPackages.lib.concatMapStringsSep "\n" mkCacheLine repos;
304+ touch $out/.stack-to-nix.cache
305+ ${self.lib.concatStrings (
306+ self.lib.lists.zipListsWith (n: repo:
307+ let l = mkCacheLine repo;
309+ cp ${l.nix-expr} $out/.stack-to-nix.cache.${toString n}
310+ echo ${l.line} .stack-to-nix.cache.${toString n} >> $out/.stack-to-nix.cache
312+ (self.lib.lists.range 0 ((builtins.length repos) - 1))
301 mkCacheModule = cache:
317 mkCacheModule = cache:
302 # for each item in the `cache`, set
318 # for each item in the `cache`, set