Is there a way to build Pants in a sandbox? I want...
# general
g
Is there a way to build Pants in a sandbox? I want to create a package for [Nix](https://nixos.org/), and it builds everything in a sandbox to ensure reproducibility.
w
building pants from source involves downloading a fair number of tools… it currently manages its own copy of rust in a cache directory
we’d be happy to help patch the bootstrap scripts to allow overriding that to use Nix’s copies instead?
the two things that would be likely to need adaptation are: 1. creating a virtualenv for pants to build itself in… there are probably Nix conventions for this 2. adapting https://github.com/pantsbuild/pants/blob/master/build-support/bin/native/cargo.sh to use Nix’s tools
f
let me know how this goes...i'm more interested in the inverse...using pants to build nix pacakges, but this sounds interesting anyways
g
Another option is pre-fetching everything before building inside a given directory. A fixed output derivation can run arbitrary commands, the only requirement is the output must be reproducible, because it's verified by hash.
w
yea, prefetching is likely also an option.
the rough idea is that checking out an arbitrary SHA of https://github.com/pantsbuild/pants/ and then running the
./pants
script will bootstrap all of the tools necessary to run from source. you can then use that copy of pants to build a PEX of pants
build-support/bin/release.sh -q
will build a PEX locally (needs network access for the venv and cargo tools, as mentioned above)
g
Building in a fixed-output derivation is not a very good idea, it's main purpose is to fetch sources to be used as an input for a normal derivation.
w
ok.
yea, i don’t have any experience with Nix, but the concepts of reproducible builds are quite clear, because we try to apply them in Pants as well
happy to help change our scripts however is necessary to help you!
g
Nix is indeed very similar to tools like bazel, please or pants.
Except it's a package manager and uses a lazy functional language instead of Python.
w
yep.
ftr,
@rules
are lazy and pure as well!
anywho. i would try out
build-support/bin/release.sh -q
and see what is missing from the Nix environment… from there we’ll be happy to help!