-
Notifications
You must be signed in to change notification settings - Fork 2
Add Nix flake for installing the CLI on macOS and Linux #46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
| 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
|
||
| }; | ||
| } | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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"; | ||
| }; | ||
| } |
There was a problem hiding this comment.
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.