Add Nix flake for installing the CLI on macOS and Linux - #46
Conversation
There was a problem hiding this comment.
Pull request overview
Adds first-class Nix support so baseten-cli can be built/run/installed via flakes across macOS and Linux, aligning the Nix build’s version injection with the existing GoReleaser ldflags approach.
Changes:
- Introduces a
buildGoModuleNix derivation for the CLI (nix/package.nix) with CGO disabled and version injected via-ldflags. - Adds a
flake.nixexposingpackages, an overlay, andchecksincluding a version smoke test. - Documents Nix usage in the README (run, profile install, Home Manager, overlay).
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| README.md | Adds a “Nix (macOS and Linux)” installation section with example commands/config. |
| nix/package.nix | Defines the Nix buildGoModule package for the baseten CLI with version ldflags. |
| flake.nix | Provides flake outputs (packages/overlay/checks) to support nix run, installs, and CI smoke checks. |
| flake.lock | Locks nixpkgs and flake-utils inputs for reproducible builds. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| overlays.default = final: prev: { | ||
| baseten = final.callPackage ./nix/package.nix { }; | ||
| }; |
There was a problem hiding this comment.
I am a bit concerned about adding and maintaining distro-specific installation files at the top level like this. Note this doesn't exist for any other install/distro/OS in this repository. Is there any other way for nix to work with standard released binaries without adding these files?
I wonder if putting in https://github.com/nixos/nixpkgs would be better? Or if we need a baseten-nix repo for all flakes at Baseten and not unique to this one thing. Or just (collapsed by default) instructions on how to use in nix directly via fetchurl without adding these files.
There was a problem hiding this comment.
If we did support nix, I think it should use the released binaries, not do a rebuild
| brew upgrade baseten | ||
| ``` | ||
|
|
||
| ### Nix (macOS and Linux) |
There was a problem hiding this comment.
If we did want to support Nix explicitly in README, would request most of this is collapsed so the majority of unaffected users don't have to see it. Maybe somehow under "Prebuilt binaries" even if we have to change that heading.
Adds a Nix flake so the CLI can be installed on macOS and Linux (x86_64 and aarch64) via
nix profile install github:basetenlabs/baseten-cli, run ad hoc withnix run, or pulled into a Home Manager / NixOS configuration.nix/package.nix: callPackage-ablebuildGoModulederivation (CGO disabled, version injected via the same ldflag goreleaser uses,mainProgram = "baseten").flake.nix: pinned to nixpkgs 26.05 (Go 1.26.5; unstable has dropped x86_64-darwin support, which 26.05 retains). Outputspackages.{default,baseten},overlays.default(addspkgs.baseten), andcheckswith a smoke test assertingbaseten versionreports the build version.nix run,nix profile install, Home Manager usage, and the overlay.Tested with
nix build+nix flake checkon aarch64-darwin (build and version smoke test pass) and evaluation of the package for all four Linux/macOS systems. Whengo.mod/go.sumchange,vendorHashinnix/package.nixneeds updating (set tolib.fakeHash, rebuild, copy the hash from the error).🤖 Generated with Claude Code