Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,35 @@ brew update
brew upgrade baseten
```

### Nix (macOS and Linux)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.


This repository is a Nix flake. Run the CLI without installing anything:

```bash
nix run github:basetenlabs/baseten-cli -- --help
```

or install it into your profile:

```bash
nix profile install github:basetenlabs/baseten-cli
```

To install with [Home Manager](https://github.com/nix-community/home-manager),
add the flake as an input and put the package in `home.packages`:

```nix
{
inputs.baseten-cli.url = "github:basetenlabs/baseten-cli";

# In your home-manager configuration (with `inputs` passed through):
# home.packages = [ inputs.baseten-cli.packages.${pkgs.system}.default ];
}
```

The flake also exposes `overlays.default`, which adds the package as
`pkgs.baseten`.

### Prebuilt binaries

Download the [latest release](https://github.com/basetenlabs/baseten-cli/releases/latest) for Windows, macOS, or Linux, extract the archive, and place the `baseten` executable on your `PATH`.
Expand Down
61 changes: 61 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 50 additions & 0 deletions flake.nix

@cretz cretz Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
description = "CLI for Baseten";

inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-26.05";
flake-utils.url = "github:numtide/flake-utils";
};

outputs =
{
self,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs { inherit system; };
baseten = pkgs.callPackage ./nix/package.nix {
version = if self ? shortRev then "unstable-${self.shortRev}" else "dev";
};
in
{
packages = {
default = baseten;
inherit baseten;
};

checks = {
build = baseten;
# Smoke test: the built binary runs and reports the expected version.
version = pkgs.runCommand "baseten-version-check" { } ''
got="$(${pkgs.lib.getExe baseten} version)"
want=${pkgs.lib.escapeShellArg baseten.version}
if [ "$got" != "$want" ]; then
echo "baseten version reported '$got', expected '$want'" >&2
exit 1
fi
${pkgs.lib.getExe baseten} --help > /dev/null
touch $out
'';
};
}
)
// {
overlays.default = final: prev: {
baseten = final.callPackage ./nix/package.nix { };
};
Comment on lines +46 to +48
};
}
31 changes: 31 additions & 0 deletions nix/package.nix

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we did support nix, I think it should use the released binaries, not do a rebuild

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
lib,
buildGoModule,
version ? "dev",
}:
buildGoModule {
pname = "baseten";
inherit version;

src = lib.cleanSource ../.;

# Update by setting to lib.fakeHash and copying the hash from the build error.
vendorHash = "sha256-ghtyvdt80fy6JCw0J20a70fai9fUQyJW5vS8gQibZWE=";

subPackages = [ "cmd/baseten" ];

env.CGO_ENABLED = 0;

ldflags = [
"-s"
"-w"
"-X github.com/basetenlabs/baseten-cli/internal/cmd.Version=${version}"
];

meta = {
description = "CLI for Baseten";
homepage = "https://github.com/basetenlabs/baseten-cli";
license = lib.licenses.mit;
mainProgram = "baseten";
};
}
Loading