Add nix flake, CI build and release workflow with bin.json
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
588d4d07e3
commit
ea1856e473
6 files changed
+220
-1
No files matched your search
@@ -0,0 +1,77 @@
|
||||
{
|
||||
description = "orch: orchestrator that runs many hx coding agents";
|
||||
|
||||
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
|
||||
outputs =
|
||||
{ self, nixpkgs }:
|
||||
let
|
||||
systems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" ];
|
||||
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
|
||||
{
|
||||
packages = forAll (pkgs: let
|
||||
target = targets.${pkgs.stdenv.hostPlatform.system} or "";
|
||||
hasBin = bin.sha256 ? ${target};
|
||||
runtimePath = pkgs.lib.makeBinPath [ pkgs.git ];
|
||||
|
||||
# only forced when hasBin, bin.sha256.${target} would throw otherwise
|
||||
orch-bin = pkgs.runCommand "orch-${bin.version}"
|
||||
{ nativeBuildInputs = [ pkgs.makeWrapper ]; meta.mainProgram = "orch"; }
|
||||
''
|
||||
mkdir -p $out/bin
|
||||
tar -xzf ${
|
||||
pkgs.fetchurl {
|
||||
url = "https://git.jokresner.de/johannes/orch/releases/download/v${bin.version}/orch-${target}.tar.gz";
|
||||
sha256 = bin.sha256.${target};
|
||||
}
|
||||
} -C $out/bin orch
|
||||
wrapProgram $out/bin/orch --prefix PATH : ${runtimePath}
|
||||
'';
|
||||
in rec {
|
||||
orch = pkgs.rustPlatform.buildRustPackage {
|
||||
pname = "orch";
|
||||
version = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).package.version;
|
||||
src = pkgs.lib.cleanSource ./.;
|
||||
cargoLock.lockFile = ./Cargo.lock;
|
||||
# ponytail: tests skipped (python e2e needs git/hx); enable when hermetic.
|
||||
doCheck = false;
|
||||
nativeBuildInputs = [ pkgs.makeWrapper pkgs.pkg-config ];
|
||||
# nixpkgs links libsqlite3-sys against the system sqlite
|
||||
buildInputs = [ pkgs.sqlite ];
|
||||
# orch shells out to git; hx is supplied by the user.
|
||||
postInstall = ''
|
||||
wrapProgram $out/bin/orch --prefix PATH : ${runtimePath}
|
||||
'';
|
||||
meta = {
|
||||
description = "Orchestrator that runs many hx coding agents";
|
||||
mainProgram = "orch";
|
||||
};
|
||||
};
|
||||
|
||||
# prebuilt binary where the release has one, source build elsewhere
|
||||
default = if hasBin then orch-bin else orch;
|
||||
} // pkgs.lib.optionalAttrs hasBin { inherit orch-bin; });
|
||||
|
||||
apps = forAll (pkgs: rec {
|
||||
orch = { type = "app"; program = "${self.packages.${pkgs.system}.default}/bin/orch"; };
|
||||
default = orch;
|
||||
});
|
||||
|
||||
overlays.default = _: prev: { orch = self.packages.${prev.system}.default; };
|
||||
|
||||
devShells = forAll (pkgs: {
|
||||
default = pkgs.mkShell {
|
||||
packages = with pkgs; [
|
||||
cargo rustc clippy rustfmt rust-analyzer git sqlite markdownlint-cli lychee
|
||||
];
|
||||
};
|
||||
});
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user