Compare commits
7
Commits
d1bfa22580
...
v0.1.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fe6811540a | ||
|
|
10b2ccf60a | ||
|
|
d0f23421cd | ||
|
|
ee5d8371d0 | ||
|
|
926bcbf978 | ||
|
|
4161095d4d | ||
|
|
a0cd7946c3 |
No files matched your search
@@ -0,0 +1,109 @@
|
|||||||
|
name: build
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
paths-ignore: [bin.json]
|
||||||
|
workflow_dispatch:
|
||||||
|
env:
|
||||||
|
MACOS_SDK: "14.5"
|
||||||
|
jobs:
|
||||||
|
# next version = highest vX.Y.Z tag with the patch bumped; push a tag by hand for minor/major
|
||||||
|
version:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
version: ${{ steps.next.outputs.version }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
- id: next
|
||||||
|
run: |
|
||||||
|
last=$(git tag -l 'v[0-9]*.[0-9]*.[0-9]*' --sort=-v:refname | head -n1)
|
||||||
|
if [ -z "$last" ]; then
|
||||||
|
next=0.1.0
|
||||||
|
else
|
||||||
|
last=${last#v}
|
||||||
|
next="${last%.*}.$(( ${last##*.} + 1 ))"
|
||||||
|
fi
|
||||||
|
echo "version=$next" >> "$GITHUB_OUTPUT"
|
||||||
|
build:
|
||||||
|
needs: version
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
target: [x86_64-unknown-linux-musl, aarch64-apple-darwin]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: dtolnay/rust-toolchain@stable
|
||||||
|
with:
|
||||||
|
targets: ${{ matrix.target }}
|
||||||
|
# caches ~/.cargo registry/git and target/, keyed on Cargo.lock + toolchain
|
||||||
|
- uses: Swatinem/rust-cache@v2
|
||||||
|
with:
|
||||||
|
key: ${{ matrix.target }}
|
||||||
|
# zig as cross C compiler/linker for both musl and macOS
|
||||||
|
- run: pip install ziglang cargo-zigbuild
|
||||||
|
# macOS: Apple SDK for Security.framework etc.
|
||||||
|
- if: matrix.target == 'aarch64-apple-darwin'
|
||||||
|
id: sdk-cache
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: ~/MacOSX${{ env.MACOS_SDK }}.sdk
|
||||||
|
key: macos-sdk-${{ env.MACOS_SDK }}
|
||||||
|
- if: matrix.target == 'aarch64-apple-darwin' && steps.sdk-cache.outputs.cache-hit != 'true'
|
||||||
|
run: curl -fsSL "https://github.com/joseluisq/macosx-sdks/releases/download/${MACOS_SDK}/MacOSX${MACOS_SDK}.sdk.tar.xz" | tar -xJ -C "$HOME"
|
||||||
|
- if: matrix.target == 'aarch64-apple-darwin'
|
||||||
|
run: echo "SDKROOT=$HOME/MacOSX${MACOS_SDK}.sdk" >> "$GITHUB_ENV"
|
||||||
|
- run: cargo zigbuild --release --locked --target ${{ matrix.target }} -p hx-cli
|
||||||
|
env:
|
||||||
|
HX_VERSION: ${{ needs.version.outputs.version }}
|
||||||
|
- uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: hx-${{ matrix.target }}
|
||||||
|
path: target/${{ matrix.target }}/release/hx
|
||||||
|
release:
|
||||||
|
needs: [build, version]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
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
|
||||||
|
with:
|
||||||
|
path: dist
|
||||||
|
# artifacts lose the executable bit, restore it before packaging
|
||||||
|
- working-directory: dist
|
||||||
|
run: |
|
||||||
|
for t in hx-*; do
|
||||||
|
chmod +x "$t/hx"
|
||||||
|
tar -czf "$t.tar.gz" -C "$t" hx
|
||||||
|
done
|
||||||
|
sha256sum *.tar.gz > SHA256SUMS
|
||||||
|
- env:
|
||||||
|
TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||||
|
API: ${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}
|
||||||
|
TAG: v${{ needs.version.outputs.version }}
|
||||||
|
SHA: ${{ gitea.sha }}
|
||||||
|
# Gitea creates the tag at target_commitish when it doesn't exist
|
||||||
|
run: |
|
||||||
|
id=$(curl -fsS -X POST -H "Authorization: token $TOKEN" -H "Content-Type: application/json" \
|
||||||
|
-d "{\"tag_name\":\"$TAG\",\"name\":\"$TAG\",\"target_commitish\":\"$SHA\"}" "$API/releases" | jq -r .id)
|
||||||
|
for f in dist/*.tar.gz dist/SHA256SUMS; do
|
||||||
|
curl -fsS -X POST -H "Authorization: token $TOKEN" \
|
||||||
|
-F "attachment=@$f" "$API/releases/$id/assets?name=$(basename "$f")"
|
||||||
|
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
|
|
||||||
@@ -59,7 +59,8 @@ max_tokens = 16384
|
|||||||
## Project dir + /tmp writable, $HOME hidden except `ro`/`rw`, filtered env (no API keys/tokens), no network.
|
## Project dir + /tmp writable, $HOME hidden except `ro`/`rw`, filtered env (no API keys/tokens), no network.
|
||||||
## File tools (read/write/edit) obey the same paths. mode = "on" without a working backend refuses to start.
|
## File tools (read/write/edit) obey the same paths. mode = "on" without a working backend refuses to start.
|
||||||
# [sandbox]
|
# [sandbox]
|
||||||
# mode = "off" # off | on (CLI: --sandbox / --no-sandbox)
|
# mode = "off" # off | on (CLI: --sandbox / --no-sandbox; /sandbox toggles at runtime)
|
||||||
|
# claude = true # false: claude (claude_cli provider) runs unconfined, no prompt
|
||||||
# backend = "auto" # auto | bwrap | seatbelt
|
# backend = "auto" # auto | bwrap | seatbelt
|
||||||
# network = false
|
# network = false
|
||||||
# rw = ["~/.cargo/registry", "~/.cargo/git"] # extra writable paths
|
# rw = ["~/.cargo/registry", "~/.cargo/git"] # extra writable paths
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"version": "0.1.0",
|
||||||
|
"sha256": {
|
||||||
|
"aarch64-apple-darwin": "b6c5b91a839ceb80be69d24a94fb8114f4150a039b7f8873381aa1efcb35a26c",
|
||||||
|
"x86_64-unknown-linux-musl": "a5079b8655af0046b4cca0af76e118b3d91c3048f6c3eab4f763a1bd4f85ba62"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,7 +15,12 @@ mod rpc;
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[command(name = "hx", version, about = "Minimal coding agent")]
|
#[command(
|
||||||
|
name = "hx",
|
||||||
|
// CI sets HX_VERSION to the release version; local builds use Cargo's
|
||||||
|
version = option_env!("HX_VERSION").unwrap_or(env!("CARGO_PKG_VERSION")),
|
||||||
|
about = "Minimal coding agent"
|
||||||
|
)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
cmd: Option<Cmd>,
|
cmd: Option<Cmd>,
|
||||||
@@ -45,6 +50,9 @@ struct Cli {
|
|||||||
/// Force the sandbox off (overrides config).
|
/// Force the sandbox off (overrides config).
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
no_sandbox: bool,
|
no_sandbox: bool,
|
||||||
|
/// Run `claude` unconfined even when the sandbox is on (overrides config).
|
||||||
|
#[arg(long)]
|
||||||
|
no_claude_sandbox: bool,
|
||||||
/// Output mode: text (default for -p), json (NDJSON events on stdout; needs -p), rpc (JSON-RPC on stdio).
|
/// Output mode: text (default for -p), json (NDJSON events on stdout; needs -p), rpc (JSON-RPC on stdio).
|
||||||
#[arg(long, value_enum, default_value_t = Mode::Text)]
|
#[arg(long, value_enum, default_value_t = Mode::Text)]
|
||||||
mode: Mode,
|
mode: Mode,
|
||||||
@@ -317,7 +325,10 @@ fn claude_extra(bin: &str) -> hx_core::sandbox::Extra {
|
|||||||
|
|
||||||
/// The `claude` command: sandboxed when the sandbox is on, unless the user let it out.
|
/// The `claude` command: sandboxed when the sandbox is on, unless the user let it out.
|
||||||
async fn claude_command(bin: String) -> tokio::process::Command {
|
async fn claude_command(bin: String) -> tokio::process::Command {
|
||||||
if hx_core::sandbox::active().is_none() || claude_outside().await {
|
if hx_core::sandbox::active().is_none()
|
||||||
|
|| !hx_core::sandbox::claude_sandboxed()
|
||||||
|
|| claude_outside().await
|
||||||
|
{
|
||||||
return tokio::process::Command::new(bin);
|
return tokio::process::Command::new(bin);
|
||||||
}
|
}
|
||||||
hx_core::sandbox::command_with(&bin, &claude_extra(&bin))
|
hx_core::sandbox::command_with(&bin, &claude_extra(&bin))
|
||||||
@@ -771,7 +782,13 @@ async fn main() -> Result<()> {
|
|||||||
if cli.no_sandbox {
|
if cli.no_sandbox {
|
||||||
sb.mode = hx_core::sandbox::Mode::Off;
|
sb.mode = hx_core::sandbox::Mode::Off;
|
||||||
}
|
}
|
||||||
|
if cli.no_claude_sandbox {
|
||||||
|
sb.claude = false;
|
||||||
|
}
|
||||||
hx_core::sandbox::init(&sb, &cwd).map_err(anyhow::Error::msg)?;
|
hx_core::sandbox::init(&sb, &cwd).map_err(anyhow::Error::msg)?;
|
||||||
|
if sb.mode == hx_core::sandbox::Mode::On && !sb.claude {
|
||||||
|
eprintln!("hx: sandbox on, but claude runs unconfined (sandbox.claude = false)");
|
||||||
|
}
|
||||||
if let Some(oc) = cfg.openai_compat.clone() {
|
if let Some(oc) = cfg.openai_compat.clone() {
|
||||||
let _ = COMPAT.set(oc);
|
let _ = COMPAT.set(oc);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,6 +73,11 @@ pub fn builtins(models: &[&str]) -> Vec<CmdSpec> {
|
|||||||
b("clear", "alias of /new", None),
|
b("clear", "alias of /new", None),
|
||||||
b("sessions", "browse, resume, delete sessions", None),
|
b("sessions", "browse, resume, delete sessions", None),
|
||||||
b("yolo", "toggle: run every tool without asking", None),
|
b("yolo", "toggle: run every tool without asking", None),
|
||||||
|
b(
|
||||||
|
"sandbox",
|
||||||
|
"sandbox on/off; `claude` toggles it for claude; no arg: status",
|
||||||
|
Enum(["on", "off", "claude"].map(String::from).into()),
|
||||||
|
),
|
||||||
b("lsp", "language server status", None),
|
b("lsp", "language server status", None),
|
||||||
b("copy", "copy the last answer to the clipboard", None),
|
b("copy", "copy the last answer to the clipboard", None),
|
||||||
b("usage", "subscription limits, resets, credits", None),
|
b("usage", "subscription limits, resets, credits", None),
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
use std::ffi::OsStr;
|
use std::ffi::OsStr;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::sync::OnceLock;
|
use std::sync::OnceLock;
|
||||||
|
use std::sync::atomic::{AtomicBool, Ordering};
|
||||||
|
|
||||||
#[derive(Default, Clone, Copy, PartialEq, Eq, Debug, serde::Deserialize)]
|
#[derive(Default, Clone, Copy, PartialEq, Eq, Debug, serde::Deserialize)]
|
||||||
#[serde(rename_all = "lowercase")]
|
#[serde(rename_all = "lowercase")]
|
||||||
@@ -45,6 +46,8 @@ pub struct Cfg {
|
|||||||
pub ro: Vec<String>,
|
pub ro: Vec<String>,
|
||||||
/// env vars passed to children; a trailing `*` matches a prefix
|
/// env vars passed to children; a trailing `*` matches a prefix
|
||||||
pub env_allow: Vec<String>,
|
pub env_allow: Vec<String>,
|
||||||
|
/// run `claude` (claude_cli provider) inside the sandbox too (default true)
|
||||||
|
pub claude: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Cfg {
|
impl Default for Cfg {
|
||||||
@@ -52,6 +55,7 @@ impl Default for Cfg {
|
|||||||
let s = |v: &[&str]| v.iter().map(|s| s.to_string()).collect();
|
let s = |v: &[&str]| v.iter().map(|s| s.to_string()).collect();
|
||||||
Cfg {
|
Cfg {
|
||||||
mode: Mode::Off,
|
mode: Mode::Off,
|
||||||
|
claude: true,
|
||||||
backend: Backend::Auto,
|
backend: Backend::Auto,
|
||||||
network: false,
|
network: false,
|
||||||
rw: s(&["~/.cargo/registry", "~/.cargo/git"]),
|
rw: s(&["~/.cargo/registry", "~/.cargo/git"]),
|
||||||
@@ -98,22 +102,47 @@ pub struct Sandbox {
|
|||||||
env_allow: Vec<String>,
|
env_allow: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
static SANDBOX: OnceLock<Option<Sandbox>> = OnceLock::new();
|
static CFG: OnceLock<(Cfg, PathBuf)> = OnceLock::new();
|
||||||
|
/// Built lazily on first enable (the backend probe spawns a process).
|
||||||
|
static SANDBOX: OnceLock<Sandbox> = OnceLock::new();
|
||||||
|
static ENABLED: AtomicBool = AtomicBool::new(false);
|
||||||
|
static CLAUDE: AtomicBool = AtomicBool::new(true);
|
||||||
|
|
||||||
/// Call once at startup. Errors (never silently falls back) if `mode = on` and no backend works.
|
/// Call once at startup. Errors (never silently falls back) if `mode = on` and no backend works.
|
||||||
pub fn init(cfg: &Cfg, cwd: &Path) -> Result<(), String> {
|
pub fn init(cfg: &Cfg, cwd: &Path) -> Result<(), String> {
|
||||||
let sb = if cfg.mode == Mode::On {
|
CFG.set((cfg.clone(), cwd.to_path_buf()))
|
||||||
Some(Sandbox::new(cfg, cwd)?)
|
.map_err(|_| "sandbox already initialised".to_string())?;
|
||||||
} else {
|
CLAUDE.store(cfg.claude, Ordering::Relaxed);
|
||||||
None
|
if cfg.mode == Mode::On {
|
||||||
};
|
set_enabled(true)?;
|
||||||
SANDBOX
|
}
|
||||||
.set(sb)
|
Ok(())
|
||||||
.map_err(|_| "sandbox already initialised".into())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn active() -> Option<&'static Sandbox> {
|
pub fn active() -> Option<&'static Sandbox> {
|
||||||
SANDBOX.get().and_then(Option::as_ref)
|
ENABLED
|
||||||
|
.load(Ordering::Relaxed)
|
||||||
|
.then(|| SANDBOX.get())
|
||||||
|
.flatten()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Turn the sandbox on/off at runtime. Affects only children spawned afterwards.
|
||||||
|
pub fn set_enabled(on: bool) -> Result<(), String> {
|
||||||
|
if on && SANDBOX.get().is_none() {
|
||||||
|
let (cfg, cwd) = CFG.get().ok_or("sandbox not initialised")?;
|
||||||
|
let _ = SANDBOX.set(Sandbox::new(cfg, cwd)?);
|
||||||
|
}
|
||||||
|
ENABLED.store(on, Ordering::Relaxed);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Does `claude` run inside the sandbox (while the sandbox is on)?
|
||||||
|
pub fn claude_sandboxed() -> bool {
|
||||||
|
CLAUDE.load(Ordering::Relaxed)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_claude_sandboxed(on: bool) {
|
||||||
|
CLAUDE.store(on, Ordering::Relaxed);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Drop-in for `tokio::process::Command::new` that applies the sandbox when it is on.
|
/// Drop-in for `tokio::process::Command::new` that applies the sandbox when it is on.
|
||||||
@@ -561,4 +590,17 @@ mod tests {
|
|||||||
"base unchanged"
|
"base unchanged"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn toggle() {
|
||||||
|
assert!(set_enabled(true).is_err(), "needs init");
|
||||||
|
let _ = init(&Cfg::default(), Path::new("/tmp"));
|
||||||
|
assert!(active().is_none());
|
||||||
|
if set_enabled(true).is_ok() {
|
||||||
|
assert!(active().is_some());
|
||||||
|
set_enabled(false).unwrap();
|
||||||
|
assert!(active().is_none());
|
||||||
|
}
|
||||||
|
assert!(Cfg::default().claude);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1384,6 +1384,36 @@ async fn submit(app: &mut App, mut line: String, c: &Ctx<'_>) {
|
|||||||
}
|
}
|
||||||
show(app, "skills", l);
|
show(app, "skills", l);
|
||||||
}
|
}
|
||||||
|
"sandbox" => {
|
||||||
|
use hx_core::sandbox as sb;
|
||||||
|
let r = match arg {
|
||||||
|
"" => Ok(()),
|
||||||
|
"on" => sb::set_enabled(true),
|
||||||
|
"off" => sb::set_enabled(false),
|
||||||
|
"claude" => {
|
||||||
|
sb::set_claude_sandboxed(!sb::claude_sandboxed());
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
_ => Err("usage: /sandbox [on|off|claude]".into()),
|
||||||
|
};
|
||||||
|
app.t.push(match r {
|
||||||
|
Ok(()) => Item::Info(format!(
|
||||||
|
"sandbox {} · claude {}{}",
|
||||||
|
if sb::active().is_some() { "on" } else { "off" },
|
||||||
|
if sb::claude_sandboxed() {
|
||||||
|
"sandboxed"
|
||||||
|
} else {
|
||||||
|
"unconfined"
|
||||||
|
},
|
||||||
|
if arg.is_empty() {
|
||||||
|
""
|
||||||
|
} else {
|
||||||
|
" · applies to new processes (restart LSP with /lsp)"
|
||||||
|
}
|
||||||
|
)),
|
||||||
|
Err(e) => Item::Error(e),
|
||||||
|
});
|
||||||
|
}
|
||||||
"yolo" => {
|
"yolo" => {
|
||||||
let on = app
|
let on = app
|
||||||
.state
|
.state
|
||||||
|
|||||||
@@ -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