@@ -285,18 +285,34 @@ self: super: {
285285
286286 sha256String = if isNull sha256 then self.buildPackages.lib.fakeSha256 else sha256;
287287
288− in "${url} ${rev} ${subdir} ${sha256String} ${name} ${nix-expr}";
288+ in {
289+ line = "${url} ${rev} ${subdir} ${sha256String} ${name}";
290+ inherit nix-expr;
291+ };
289292
290293 # Given a list of repos:
291294 # [ { name = ...; url = ...; rev = ...; ref = ...; sha256 = ...; cabal-file = ...; type = ...; is-private = ...; } ]
292295 # produce a cache file that can be used for
293296 # stack-to-nix or plan-to-nix to prevent them
294297 # 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
300+ # mode.
295301 mkCacheFile = repos:
296− self.buildPackages.pkgs.writeTextFile {
297− name = "cache-file";
298− text = self.buildPackages.lib.concatMapStringsSep "\n" mkCacheLine repos;
299− };
302+ self.buildPackages.pkgs.runCommand "cache-file" {} ''
303+ mkdir -p $out
304+ touch $out/.stack-to-nix.cache
305+ ${self.lib.concatStrings (
306+ self.lib.lists.zipListsWith (n: repo:
307+ let l = mkCacheLine repo;
308+ in ''
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
311+ '')
312+ (self.lib.lists.range 0 ((builtins.length repos) - 1))
313+ repos)
314+ }
315+ '';
300316
301317 mkCacheModule = cache:
302318 # for each item in the `cache`, set