Nix packages for pants build system.
Official pants launcher can read
[GLOBAL].pants_version from pants.toml, download the correct version of
pants and run it. On the contrary, this nix package only provides the specific
versions of pants, you need to use the correct version yourself.
Pants can download other tools via
backends.
This installation is reproducable by design, but binary packages like ruff
probably won't work on nixos. To make them work we need some mechanism to tell
pants to use preinstalled package from nix store.
Add channel:
nix-channel --add https://github.com/grihabor/pants-nix/archive/main.tar.gz pants-nix
nix-channel --updateThen build the package:
nix-build '<pants-nix>' -A '"release_2.20.0"'Or install via nix-env:
nix-env -iA 'pants-nix."release_2.20.0"'Spin up a container:
docker run -it -e NIX_PATH=nixpkgs=channel:nixos-23.11 nixpkgs/nix:nixos-23.11 bashThen inside the container:
nix-channel --add https://github.com/grihabor/pants-nix/archive/main.tar.gz pants-nix
nix-channel --update
nix-env -iA 'pants-nix."release_2.20.0"'
export PATH="$PATH:$(nix-env --query --out-path --no-name pants)/bin"
touch pants.toml
pants --versionAdhoc shell:
nix shell 'github:grihabor/pants-nix#"release_2.20.0"' --command pants --versionUsing in a flake:
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
pants-nix = {
url = "github:grihabor/pants-nix/main";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = {
self,
nixpkgs,
pants-nix,
}: let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
in {
devShells."x86_64-linux".default = pkgs.mkShell {
packages = [
pants-nix.packages."x86_64-linux"."release_2.21.0"
];
};
};
}List available packages:
nix search github:grihabor/pants-nix ^nix-build -A '"release_2.20.0"'
nix build '.#"release_2.20.0"'
nix shell '.#"release_2.20.0"' --command pants --version