From 695737acd07d6435a369ca347394ec41e44add57 Mon Sep 17 00:00:00 2001 From: Luke Tchang Date: Thu, 19 Mar 2026 09:31:56 -0700 Subject: [PATCH 1/2] Add Databricks CLI v0.286.0 as a nix module Add a new module that packages the pre-built Databricks CLI binary from GitHub releases so Repls can have the databricks command available by default for Databricks apps. --- pkgs/modules/databricks-cli/default.nix | 45 +++++++++++++++++++++++++ pkgs/modules/default.nix | 1 + 2 files changed, 46 insertions(+) create mode 100644 pkgs/modules/databricks-cli/default.nix diff --git a/pkgs/modules/databricks-cli/default.nix b/pkgs/modules/databricks-cli/default.nix new file mode 100644 index 00000000..c38a4791 --- /dev/null +++ b/pkgs/modules/databricks-cli/default.nix @@ -0,0 +1,45 @@ +{ pkgs, lib, ... }: + +let + version = "0.286.0"; + databricks-cli = pkgs.stdenvNoCC.mkDerivation { + pname = "databricks-cli"; + inherit version; + + src = pkgs.fetchurl { + url = "https://github.com/databricks/cli/releases/download/v${version}/databricks_cli_${version}_linux_amd64.tar.gz"; + hash = "sha256-lf6q0c9iZVNvIzLVrptTe0YudpFDVDdZXMWR8lOObw8="; + }; + + sourceRoot = "."; + + dontConfigure = true; + dontBuild = true; + + unpackPhase = '' + tar -xzf $src + ''; + + installPhase = '' + runHook preInstall + mkdir -p $out/bin + install -m755 databricks $out/bin/databricks + runHook postInstall + ''; + }; +in +{ + id = "databricks-cli"; + name = "Databricks CLI"; + description = '' + The Databricks CLI is a command-line tool for interacting with + Databricks. It provides commands to manage Databricks resources + such as workspaces, jobs, clusters, libraries, and Databricks + apps from the command line. + ''; + displayVersion = version; + + replit.packages = [ + databricks-cli + ]; +} diff --git a/pkgs/modules/default.nix b/pkgs/modules/default.nix index d9a08f13..ad2edbec 100644 --- a/pkgs/modules/default.nix +++ b/pkgs/modules/default.nix @@ -158,6 +158,7 @@ let }) (import ./replit-rtld-loader) (import ./graphite-cli) + (import ./databricks-cli) ]; activeModules = listToAttrs ( From f02ea595c11472a44d30dacef041a000a80e03bb Mon Sep 17 00:00:00 2001 From: Luke Tchang Date: Fri, 20 Mar 2026 08:26:10 -0700 Subject: [PATCH 2/2] Build Databricks CLI from source following nixpkgs pattern Rework the derivation to use buildGoModule + fetchFromGitHub instead of downloading a pre-built binary tarball. This follows the upstream nixpkgs package.nix pattern with version bumped to 0.286.0. Changes: - Build from source with buildGoModule for reproducibility - Add meta.license = lib.licenses.databricks - Add databricks-cli to allowUnfreePredicate in flake.nix - Exclude tools/testmask (new in v0.286.0, not a distributable package) - Skip TestCacheDirEnvVar (fails in nix sandbox, no home directory) --- flake.nix | 3 +- pkgs/modules/databricks-cli/default.nix | 83 ++++++++++++++++++++----- 2 files changed, 71 insertions(+), 15 deletions(-) diff --git a/flake.nix b/flake.nix index e4b0a2b3..e9e46a2e 100644 --- a/flake.nix +++ b/flake.nix @@ -31,9 +31,10 @@ fenix.overlays.default replit-rtld-loader.overlays.default ]; - # replbox has an unfree license + # replbox and databricks-cli have unfree licenses config.allowUnfreePredicate = pkg: builtins.elem (nixpkgs.lib.getName pkg) [ "@replit/replbox" + "databricks-cli" ]; }; diff --git a/pkgs/modules/databricks-cli/default.nix b/pkgs/modules/databricks-cli/default.nix index c38a4791..2d1bc8a9 100644 --- a/pkgs/modules/databricks-cli/default.nix +++ b/pkgs/modules/databricks-cli/default.nix @@ -2,30 +2,85 @@ let version = "0.286.0"; - databricks-cli = pkgs.stdenvNoCC.mkDerivation { + databricks-cli = pkgs.buildGoModule { pname = "databricks-cli"; inherit version; - src = pkgs.fetchurl { - url = "https://github.com/databricks/cli/releases/download/v${version}/databricks_cli_${version}_linux_amd64.tar.gz"; - hash = "sha256-lf6q0c9iZVNvIzLVrptTe0YudpFDVDdZXMWR8lOObw8="; + src = pkgs.fetchFromGitHub { + owner = "databricks"; + repo = "cli"; + rev = "v${version}"; + hash = "sha256-iCmxHjIYznqed6BMQKtuYHJNFPy+3XrNzSXfhtyzPJk="; }; - sourceRoot = "."; + vendorHash = "sha256-TNUI2VQVKnxTiKQg9Bj3qDK2w3oOjO0rdrtTlFIhTzA="; - dontConfigure = true; - dontBuild = true; + excludedPackages = [ + "bundle/internal" + "acceptance" + "integration" + "tools/testrunner" + "tools/testmask" + ]; - unpackPhase = '' - tar -xzf $src + postPatch = '' + substituteInPlace bundle/deploy/terraform/init_test.go \ + --replace-fail "cli/0.0.0-dev" "cli/${version}" ''; - installPhase = '' - runHook preInstall - mkdir -p $out/bin - install -m755 databricks $out/bin/databricks - runHook postInstall + ldflags = [ + "-X github.com/databricks/cli/internal/build.buildVersion=${version}" + ]; + + postBuild = '' + mv "$GOPATH/bin/cli" "$GOPATH/bin/databricks" ''; + + checkFlags = + "-skip=" + + (lib.concatStringsSep "|" [ + # Need network + "TestConsistentDatabricksSdkVersion" + "TestTerraformArchiveChecksums" + "TestExpandPipelineGlobPaths" + "TestRelativePathTranslationDefault" + "TestRelativePathTranslationOverride" + "TestWorkspaceVerifyProfileForHost" + "TestWorkspaceVerifyProfileForHost/default_config_file_with_match" + "TestWorkspaceResolveProfileFromHost" + "TestWorkspaceResolveProfileFromHost/no_config_file" + "TestBundleConfigureDefault" + # Use uv venv which doesn't work with nix + # https://github.com/astral-sh/uv/issues/4450 + "TestVenvSuccess" + "TestPatchWheel" + # Fails in nix sandbox due to missing home/cache directory + "TestCacheDirEnvVar" + ]); + + nativeCheckInputs = [ + pkgs.gitMinimal + (pkgs.python3.withPackages ( + ps: with ps; [ + setuptools + wheel + ] + )) + ]; + + preCheck = '' + # Some tests depend on git and remote url + git init + git remote add origin https://github.com/databricks/cli.git + ''; + + meta = { + description = "Databricks CLI"; + mainProgram = "databricks"; + homepage = "https://github.com/databricks/cli"; + changelog = "https://github.com/databricks/cli/releases/tag/v${version}"; + license = lib.licenses.databricks; + }; }; in {