{ description = "hx: minimal Rust coding agent"; 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}; hx = pkgs.rustPlatform.buildRustPackage { pname = "hx"; version = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).workspace.package.version; src = pkgs.lib.cleanSource ./.; cargoLock.lockFile = ./Cargo.lock; cargoBuildFlags = [ "-p" "hx-cli" ]; # ponytail: tests skipped (need git/network); enable when hermetic. doCheck = false; # rustls may build aws-lc-sys (cmake) depending on feature set. nativeBuildInputs = [ pkgs.cmake pkgs.perl ]; dontUseCmakeConfigure = true; meta = { description = "Minimal Rust coding agent using existing subscriptions"; license = pkgs.lib.licenses.unlicense; mainProgram = "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 { hx = { type = "app"; program = "${self.packages.${pkgs.system}.default}/bin/hx"; }; default = hx; }); overlays.default = _: prev: { hx = self.packages.${prev.system}.default; }; devShells = forAll (pkgs: { default = pkgs.mkShell { packages = with pkgs; [ cargo rustc clippy rustfmt rust-analyzer git ]; }; }); }; }