1 # Nix with sandboxing requires every path used at build time be
2 # explicitly declared. If we simply passed in the paths, they
3 # would be copied in as sources. Using builtins.storePath we're
4 # able to tell Nix that, no, in fact, treat these not as sources
5 # to copy, but instead of a regular store path.
7 # Include the explicit closure, too, otherwise we'll get mysterious
8 # "file not found" errors due to the glibc interpreter being
11 # Magic inspired by Nix's config.nix:
12 # https://github.com/NixOS/nix/blob/f9a2ea44867cd1dbb408bca4df0ced806137b7f7/corepkgs/config.nix.in#L23
14 # If the dependency is in the Nix store we're using, refer to
15 # it as a literal store path. If it isn't, refer to it "normally".
17 # This makes sandboxing happy when in a nix-build, and the
18 # evaluation happy when in a «cargo build».
19 tools_build_host = @tools_build_host@;
21 # Compare the stringified version of the tools_build_host Nix store
22 # path to the evaluator's stringified Nix store path. Otherwise,
23 # Nix will read the sources in to the /nix/store, and, well,
24 # you can only copy the /nix/store in to the /nix/store so many
25 # times before you run out of disk space.
26 dep = if ("${toString (dirOf tools_build_host)}" == "${toString builtins.storeDir}")
27 then (builtins.trace "using storePath" builtins.storePath)
28 else (builtins.trace "using toString" toString) # assume we have no sandboxing
31 tools = dep tools_build_host;
34 path = "${tools}/bin";
35 builder = "${tools}/bin/bash";
36 closure = import @runtime_closure_list@ { inherit dep; };