From 5466a88456e3e25d35676af5f74f5e8d4d565f56 Mon Sep 17 00:00:00 2001 From: Nic Cope Date: Wed, 17 Jun 2026 22:17:25 -0700 Subject: [PATCH] Expose host-native CLI binary as the default flake package The default package was the full release bundle: the CLI cross-compiled for all seven platforms, laid out under bin/_/crossplane. This made nix build and nix run unhelpful for anyone consuming the CLI from another flake. nix run couldn't find a binary to run, and producing one binary meant a from-source build of all seven, six of which you'd throw away. This change makes default the host-native binary, built for the system Nix is running on, so nix build and nix run give you a single binary for your own machine. The multi-platform bundle moves to a new package named release. The per-platform builder already existed to assemble the bundle, so default just wraps it for the host, deriving GOOS and GOARCH from stdenv.hostPlatform. The CI build-artifacts job now builds .#release explicitly so it still produces and uploads the full bundle. The push-artifacts app already referenced the release derivation directly, so the S3 push and promote flows are unaffected. Fixes #125. Signed-off-by: Nic Cope --- .github/workflows/ci.yml | 2 +- flake.nix | 3 ++- nix/build.nix | 20 ++++++++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b51c3139..df707f4e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -158,7 +158,7 @@ jobs: sed -i "s|buildVersion = null;|buildVersion = \"$VERSION\";|" flake.nix - name: Build Artifacts - run: nix build --option warn-dirty false --print-build-logs + run: nix build .#release --option warn-dirty false --print-build-logs - name: Upload Artifacts uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6 diff --git a/flake.nix b/flake.nix index 702d94c7..fa802c28 100644 --- a/flake.nix +++ b/flake.nix @@ -108,7 +108,8 @@ build = import ./nix/build.nix { inherit pkgs self; }; in { - default = build.release { + default = build.binary { inherit version; }; + release = build.release { inherit version goPlatforms diff --git a/nix/build.nix b/nix/build.nix index 6f68eeb4..5dd18740 100644 --- a/nix/build.nix +++ b/nix/build.nix @@ -87,6 +87,26 @@ let in { + # Host-native CLI binary. This is the default package, so nix build and nix + # run give you a binary for your own machine rather than the full release. + binary = + { version }: + goBinary { + inherit version; + pname = "crossplane"; + subPackage = "cmd/crossplane"; + platform = { + os = pkgs.stdenv.hostPlatform.parsed.kernel.name; + # Go and Nix disagree on architecture names. + arch = + { + "x86_64" = "amd64"; + "aarch64" = "arm64"; + } + .${pkgs.stdenv.hostPlatform.parsed.cpu.name}; + }; + }; + # Full release package with all artifacts. release = {