Files
hx/flake.nix
T
johannes 061649cb07
build / version (push) Successful in 11s
build / build (aarch64-apple-darwin) (push) Successful in 6m14s
build / build (x86_64-unknown-linux-musl) (push) Successful in 5m37s
build / release (push) Successful in 26s
chore: add depencencies to readme and flake
2026-11-15 16:13:16 +01:00

79 lines
3.0 KiB
Nix

{
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 ] ++ pkgs.lib.optionals pkgs.stdenv.hostPlatform.isLinux [ pkgs.makeWrapper ];
dontUseCmakeConfigure = true;
# bubblewrap sandbox runtime dependency (Linux only).
postInstall = pkgs.lib.optionalString pkgs.stdenv.hostPlatform.isLinux ''
wrapProgram $out/bin/hx --suffix PATH : ${pkgs.lib.makeBinPath [ pkgs.bubblewrap ]}
'';
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 ] ++ pkgs.lib.optional pkgs.stdenv.hostPlatform.isLinux pkgs.bubblewrap;
};
});
};
}