Files
millerson-overlay.nix/packages/marmel/package.nix
T
alex 892f30e82a
CI / check (push) Has been cancelled
fix(marmel): bump to 3f238ff, give e2e child a trust store
Track main at 3f238ff (per-role reasoning_effort, #12), 21 commits past
d6627d7 ("1.0.0 (#6)"). cargoHash is unchanged: Cargo.lock is identical
across that range, so the vendored tree is byte-for-byte the same.

The new tests/test_session_boot.rs spawns the real binary with
env_clear(), which drops SSL_CERT_FILE. rustls-native-certs is then left
with a fixed list of /etc paths to probe, none of which exist in the Nix
sandbox, so the child dies in reqwest::Client::new() and four exit-code
assertions observe the panic's 101. The patch forwards the runner's
SSL_CERT_FILE to the child and leaves every assertion intact.

The underlying defect is upstream's rather than Nix's:
src/llm/client.rs builds its client with unwrap_or_default() on a
Result<Client, reqwest::Error>, and reqwest's Client::default() is
Client::new(), which repeats the same build and .expect()s it. The
fallback can therefore never recover; it turns a reportable "no CA
certificates" error into a panic. Reproduced on a stock busybox image
with no /etc/ssl at all, so it hits any minimal container, not just
sandboxed builds.

Tested: 1251 tests pass across 31 targets, 0 failures.
2026-10-16 14:32:15 +03:00

99 lines
4.0 KiB
Nix

{
lib,
rustPlatform,
fetchFromGitHub,
cacert,
}:
rustPlatform.buildRustPackage rec {
pname = "marmel";
# Upstream publishes no git tags and no GitHub releases, and Cargo.toml still
# says 1.0.0, so the version is meaningless and the source is tracked by
# branch head. Bump with nix-update (see passthru.updateScript).
version = "1.0.0";
src = fetchFromGitHub {
owner = "Na1w";
repo = "marmel";
rev = "3f238ff217ee2e1033c937c840bd2d33ec57abc4";
hash = "sha256-ijSsUAJom/uIiE09PM1kfXqNVCRqnipAQo72KXlr8sQ=";
};
cargoHash = "sha256-etqW3xcxkiNfkiPxl/Emt5pQCkNnoIhHFkX0Zqfs4rc=";
nativeCheckInputs = [ cacert ];
patches = [ ./session-boot-trust-store.patch ];
# The test suite builds `reqwest::Client`s, and rustls rejects construction
# outright when no system trust store is found ("No CA certificates were
# loaded from the system"). rustls-native-certs probes only SSL_CERT_FILE,
# SSL_CERT_DIR and a fixed list of /etc dirs (/etc/ssl, /etc/pki/tls, ...),
# none of which exist in the build sandbox, so point the tests at nixpkgs'
# bundle. Build-time only; the installed binary still uses the host's trust
# store at runtime.
preCheck = ''
export SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt
'';
# Serialise the test harness. The lib suite shares process-global worker
# registries and steer/abort buses (src/orchestrator/workers.rs,
# src/orchestrator/bus.rs, src/orchestrator/preemption.rs), so the
# manager-loop tests fail nondeterministically when the harness runs them on
# parallel threads: rebuilding one unchanged derivation yielded 3 failures,
# then 1 failure, then 0 with serial threads. Drop this flag once upstream
# makes that state per-instance.
#
# The two sandbox-exec tests are skipped. They re-exec `sh` through
# `marmel --internal-sandbox-exec`, and apply_landlock_linux() allow-lists
# FHS paths only (/usr, /bin, /lib, /opt, /etc, /var) plus /tmp. Landlock
# matches inodes rather than symlinked views, and every binary on NixOS
# resolves into the store (`/bin/sh` is
# /nix/store/<hash>-bash-interactive-5.3p9/bin/bash), so the exec is denied:
# "Failed to exec shell in sandbox: Permission denied (os error 13)". Checked
# against this build on a NixOS host, where the same command succeeds once
# the workspace root is `/` and therefore covers /nix/store. Inside the build
# sandbox the tests are doubly impossible: /usr, /lib, /run and /var do not
# exist, so the `if let Ok(fd)` guards silently drop those rules, and
# /etc/resolv.conf is absent because the sandbox has no network. 342 of 344
# tests still run. Upstream main still carries the FHS-only list; drop these
# skips if that ever gains /nix/store.
cargoTestFlags = [
"--"
"--test-threads=1"
"--skip"
"harness::sandbox::tests::test_internal_sandbox_exec_dev_null_and_dns"
"--skip"
"harness::sandbox::tests::test_internal_sandbox_cross_directory_rename"
];
# Role prompts are embedded with `include_str!`, so the binary needs no
# runtime data files. The annotated example configs are the de-facto
# first-run documentation, since a backend URL and model are mandatory.
postInstall = ''
install -Dm644 marmel.toml.example $out/share/doc/${pname}/examples/marmel.toml.example
install -Dm644 marmel.toml.cloud $out/share/doc/${pname}/examples/marmel.toml.cloud
'';
passthru = {
category = "AI Coding Agents";
updateScript = [
"nix-update"
"--flake"
".#marmel"
"--version=branch=main"
];
};
meta = {
description = "Autonomous agentic coding assistant with Manager + specialist subagent orchestration over any OpenAI-compatible LLM backend";
homepage = "https://github.com/Na1w/marmel";
# Upstream README states MIT, but the repository ships no LICENSE file and
# Cargo.toml has no license field.
license = lib.licenses.mit;
sourceProvenance = with lib.sourceTypes; [ fromSource ];
mainProgram = "marmel";
platforms = lib.platforms.unix;
};
}