https://pantsbuild.org/ logo
#general
Title
# general
g

gentle-engine-57253

10/30/2020, 7:34 PM
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

witty-crayon-22786

10/30/2020, 7:38 PM
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

flat-zoo-31952

10/30/2020, 7:56 PM
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

gentle-engine-57253

10/30/2020, 7:56 PM
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

witty-crayon-22786

10/30/2020, 7:57 PM
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

gentle-engine-57253

10/30/2020, 8:04 PM
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

witty-crayon-22786

10/30/2020, 8:05 PM
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

gentle-engine-57253

10/30/2020, 8:06 PM
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

witty-crayon-22786

10/30/2020, 8:07 PM
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!
5 Views