NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.6k stars 13.76k forks source link

Package request: PANTSBUILD #294330

Open EdDanileyko opened 6 months ago

EdDanileyko commented 6 months ago

Project description

This is a request for the pants monorepo build tool to be added to nixpkgs

Metadata

adminy commented 3 months ago

The build inputs are: setuptools pex virtualenv filelock six distlib appdirs and optionally debugpy. The starting point is turning this shell script into nix python package: https://static.pantsbuild.org/setup/pants

thamenato commented 3 months ago

I took a stab at this a couple months ago coming from 0 previous knowledge in how to package things with nix so I might have missed something - the TL;DR is that I was able to create a package that clone the pantsbuild repo and build it by running the pants script that comes with it BUT when I tried running pants it gave me an error saying that pants does not support running it "directly" anymore and that I should be using scie-pants.

I wonder what else needs to be added to it to allow you to run a compiled version of pants OR how to package scie-pants (https://github.com/pantsbuild/scie-pants) which will create an isolated python environment and on NixOS it doesn't allow me to run these "unknown binaries" :disappointed:

Sheemap commented 3 months ago

After a lot of trial and error, I was able to get a version with scie-pants working. I'm not confident enough to signup to maintain this in the official nixpkgs repo, but if any of you want to copy this package for local install, or maintain it yourself in nixpkgs, be my guest.

The trick is the binary needs to be run in a fhs compatible environment, which nix doesnt natively do. I created a package that just downloads the release from the scie-pants repo, and wraps it in a fhs env, and sets up some environment variables needed.

I was able to successfully execute fix, check, and run pants goals, it downloaded all dependencies as expected. Though you still may need to install your specific version of python, either in your env or dev shell. Pants wont download that for you.

Heres my source code https://github.com/Sheemap/nixpkgs/blob/b89976504d17a0197bef5c1b41eaade080904588/pkgs/by-name/pa/pants/package.nix

You can build it by copying the source, and running pkgs.callPackage ./path/to/package.nix {};

adminy commented 3 months ago

a few months back I got scie-pants rust derivation from source properly compiling the rust source code. the issue is in pants project itself. that's a little messy since its not a proper python package. pants builds itself ...

thamenato commented 3 months ago

I wanted to mention that I've discovered this project https://github.com/grihabor/pants-nix/ recently on Pants' Slack while searching for nix. I've tested it in one of my projects and it's working fine and you can even pick which pants version. It might still be worth having an "official" pants here as part of nixpkgs though but that unblocked me temporarily here at work.