nix: use release binaries as default package
The release job records the tarball hashes in bin.json and commits it ([skip ci]); flake.nix fetches the binary from the release on x86_64-linux and aarch64-darwin and builds from source elsewhere. Drop x86_64-darwin, nixpkgs no longer evaluates it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d0f23421cd
commit
10b2ccf60a
4 files changed
+74
-43
No files matched your search
@@ -2,6 +2,7 @@ name: build
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main]
|
branches: [main]
|
||||||
|
paths-ignore: [bin.json]
|
||||||
env:
|
env:
|
||||||
MACOS_SDK: "14.5"
|
MACOS_SDK: "14.5"
|
||||||
jobs:
|
jobs:
|
||||||
@@ -64,6 +65,10 @@ jobs:
|
|||||||
needs: [build, version]
|
needs: [build, version]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
# main, not the build sha: bin.json is committed on top of it
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
ref: main
|
||||||
- uses: actions/download-artifact@v3
|
- uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
path: dist
|
path: dist
|
||||||
@@ -88,3 +93,16 @@ jobs:
|
|||||||
curl -fsS -X POST -H "Authorization: token $TOKEN" \
|
curl -fsS -X POST -H "Authorization: token $TOKEN" \
|
||||||
-F "attachment=@$f" "$API/releases/$id/assets?name=$(basename "$f")"
|
-F "attachment=@$f" "$API/releases/$id/assets?name=$(basename "$f")"
|
||||||
done
|
done
|
||||||
|
# flake.nix reads bin.json to fetch these tarballs instead of building from source
|
||||||
|
- env:
|
||||||
|
VERSION: ${{ needs.version.outputs.version }}
|
||||||
|
run: |
|
||||||
|
jq -Rn --arg v "$VERSION" \
|
||||||
|
'{version: $v, sha256: ([inputs | split(" ") | {(.[1] | ltrimstr("hx-") | rtrimstr(".tar.gz")): .[0]}] | add)}' \
|
||||||
|
< dist/SHA256SUMS > bin.json
|
||||||
|
git config user.name gitea-actions
|
||||||
|
git config user.email gitea-actions@git.jokresner.de
|
||||||
|
git add bin.json
|
||||||
|
git commit -m "ci: bin.json v$VERSION"
|
||||||
|
git pull --rebase origin main
|
||||||
|
git push origin HEAD:main
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
name: ci
|
|
||||||
on: [push, pull_request]
|
|
||||||
jobs:
|
|
||||||
check:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- uses: dtolnay/rust-toolchain@stable
|
|
||||||
with:
|
|
||||||
components: rustfmt, clippy, rust-analyzer
|
|
||||||
- run: cargo fmt --all --check
|
|
||||||
- run: cargo clippy --workspace --all-targets -- -D warnings
|
|
||||||
- run: cargo test --workspace
|
|
||||||
- run: cargo build && sh tests/e2e.sh
|
|
||||||
- run: python3 tests/tui_smoke.py
|
|
||||||
- run: sh tests/lens_e2e.sh
|
|
||||||
- run: pip install ruff && sh tests/m4_e2e.sh
|
|
||||||
- run: sh tests/m5_e2e.sh
|
|
||||||
- run: sh tests/m6_e2e.sh
|
|
||||||
- run: python3 tests/tui_lspinstall.py
|
|
||||||
- run: sh tests/m7_e2e.sh
|
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"version": "0.1.0",
|
||||||
|
"sha256": {
|
||||||
|
"aarch64-apple-darwin": "b6c5b91a839ceb80be69d24a94fb8114f4150a039b7f8873381aa1efcb35a26c",
|
||||||
|
"x86_64-unknown-linux-musl": "a5079b8655af0046b4cca0af76e118b3d91c3048f6c3eab4f763a1bd4f85ba62"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,37 +6,64 @@
|
|||||||
outputs =
|
outputs =
|
||||||
{ self, nixpkgs }:
|
{ self, nixpkgs }:
|
||||||
let
|
let
|
||||||
systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
|
systems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" ];
|
||||||
forAll = f: nixpkgs.lib.genAttrs systems (s: f nixpkgs.legacyPackages.${s});
|
forAll = f: nixpkgs.lib.genAttrs systems (s: f nixpkgs.legacyPackages.${s});
|
||||||
|
# release binaries, bin.json is rewritten by the release job in .gitea/workflows/build.yml
|
||||||
|
bin = builtins.fromJSON (builtins.readFile ./bin.json);
|
||||||
|
targets = {
|
||||||
|
x86_64-linux = "x86_64-unknown-linux-musl";
|
||||||
|
aarch64-darwin = "aarch64-apple-darwin";
|
||||||
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
packages = forAll (pkgs: rec {
|
packages = forAll (
|
||||||
hx = pkgs.rustPlatform.buildRustPackage {
|
pkgs:
|
||||||
pname = "hx";
|
let
|
||||||
version = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).workspace.package.version;
|
target = targets.${pkgs.stdenv.hostPlatform.system} or "";
|
||||||
src = pkgs.lib.cleanSource ./.;
|
hasBin = bin.sha256 ? ${target};
|
||||||
cargoLock.lockFile = ./Cargo.lock;
|
|
||||||
cargoBuildFlags = [ "-p" "hx-cli" ];
|
hx = pkgs.rustPlatform.buildRustPackage {
|
||||||
# ponytail: tests skipped (need git/network); enable when hermetic.
|
pname = "hx";
|
||||||
doCheck = false;
|
version = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).workspace.package.version;
|
||||||
# rustls may build aws-lc-sys (cmake) depending on feature set.
|
src = pkgs.lib.cleanSource ./.;
|
||||||
nativeBuildInputs = [ pkgs.cmake pkgs.perl ];
|
cargoLock.lockFile = ./Cargo.lock;
|
||||||
dontUseCmakeConfigure = true;
|
cargoBuildFlags = [ "-p" "hx-cli" ];
|
||||||
meta = {
|
# ponytail: tests skipped (need git/network); enable when hermetic.
|
||||||
description = "Minimal Rust coding agent using existing subscriptions";
|
doCheck = false;
|
||||||
license = pkgs.lib.licenses.unlicense;
|
# rustls may build aws-lc-sys (cmake) depending on feature set.
|
||||||
mainProgram = "hx";
|
nativeBuildInputs = [ pkgs.cmake pkgs.perl ];
|
||||||
|
dontUseCmakeConfigure = true;
|
||||||
|
meta = {
|
||||||
|
description = "Minimal Rust coding agent using existing subscriptions";
|
||||||
|
license = pkgs.lib.licenses.unlicense;
|
||||||
|
mainProgram = "hx";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
default = hx;
|
hx-bin = pkgs.runCommand "hx-${bin.version}" { meta.mainProgram = "hx"; } ''
|
||||||
});
|
mkdir -p $out/bin
|
||||||
|
tar -xzf ${
|
||||||
|
pkgs.fetchurl {
|
||||||
|
url = "https://git.jokresner.de/johannes/hx/releases/download/v${bin.version}/hx-${target}.tar.gz";
|
||||||
|
sha256 = bin.sha256.${target};
|
||||||
|
}
|
||||||
|
} -C $out/bin hx
|
||||||
|
'';
|
||||||
|
in
|
||||||
|
{
|
||||||
|
inherit hx;
|
||||||
|
# prebuilt binary where the release has one, source build elsewhere
|
||||||
|
default = if hasBin then hx-bin else hx;
|
||||||
|
}
|
||||||
|
// pkgs.lib.optionalAttrs hasBin { inherit hx-bin; }
|
||||||
|
);
|
||||||
|
|
||||||
apps = forAll (pkgs: rec {
|
apps = forAll (pkgs: rec {
|
||||||
hx = { type = "app"; program = "${self.packages.${pkgs.system}.hx}/bin/hx"; };
|
hx = { type = "app"; program = "${self.packages.${pkgs.system}.default}/bin/hx"; };
|
||||||
default = hx;
|
default = hx;
|
||||||
});
|
});
|
||||||
|
|
||||||
overlays.default = _: prev: { hx = self.packages.${prev.system}.hx; };
|
overlays.default = _: prev: { hx = self.packages.${prev.system}.default; };
|
||||||
|
|
||||||
devShells = forAll (pkgs: {
|
devShells = forAll (pkgs: {
|
||||||
default = pkgs.mkShell {
|
default = pkgs.mkShell {
|
||||||
|
|||||||
Reference in new issue
Block a user