Files
millerson-overlay.nix/packages/marmel/package.nix
T
alex 589936cd8d
CI / check (push) Has been cancelled
feat(marmel): add arbitrary HTTP headers patch
Apply upstream 56d0b1f so top-level, specialist, validator and MCP request headers can be configured. nix build .#marmel passes with the patch.
2026-11-09 10:03:47 +03:00

112 lines
4.9 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, dated by nix-update's 0-unstable-* scheme. Bump with
# nix-update (see passthru.updateScript).
version = "0-unstable-2026-11-07";
src = fetchFromGitHub {
owner = "Na1w";
repo = "marmel";
rev = "afcc1dc971ae4acd59b157f031d4bdbc9d52a7d0";
hash = "sha256-OiF2Lc4s01MuXX2HfWMePBJ9M/uuhI69gInqqDPhbgQ=";
};
cargoHash = "sha256-Xw9OT8HXVlnZ0XqIMnnFwQ/y9xKxOtmcwomJsRxUx5E=";
# arbitrary HTTP headers for LLM and MCP requests.
patches = [ ./arbitrary-http-headers.patch ];
nativeCheckInputs = [ cacert ];
# The test suite exercises real HTTP round-trips against loopback servers and
# builds its `reqwest::Client`s through rustls-native-certs, which 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. Without a CA
# bundle the client build fails ("No CA certificates were loaded from the
# system") and every request fails terminally with ChatError::TrustStore, so
# point the tests at nixpkgs' bundle. Build-time only; the installed binary
# still uses the host's trust store at runtime.
# Upstream's harness::fs::path_tests scratch-root helper puts its scratch
# dirs under <cwd>/target/ and asserts that root lies outside
# std::env::temp_dir(). In the build sandbox TMPDIR is /build, which is an
# ancestor of the unpacked source dir /build/source, so that premise check
# fails for all 8 tests ("scoped root /build/source/target/marmel-path-tests-N
# sits inside the temp allow-list entry /build"). Pointing TMPDIR at a
# directory outside $NIX_BUILD_TOP restores the premise, so all 8
# path-security tests keep running instead of being skipped.
preCheck = ''
export SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt
mkdir -p /tmp/marmel-check-tmp
export TMPDIR=/tmp/marmel-check-tmp
'';
# 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.
#
# Only the DNS sandbox-exec test is skipped. It re-execs `sh` through
# `marmel --internal-sandbox-exec` and then reads /etc/resolv.conf, which the
# no-network build sandbox does not provide (upstream's own decision note in
# src/harness/sandbox.rs says the same: the exec half works on a store host,
# the resolv.conf half is a fixture question). Upstream now lists
# /nix/store and /gnu/store in BUILTIN_READONLY_PATHS, so the cross-directory
# rename test and test_internal_sandbox_extra_readonly_paths_never_grant_write
# run for real here: no SKIP line is printed and the lib suite passes with that
# single filter. No test count is quoted here on purpose: the suite grows on
# almost every bump, so any hard-coded number rots immediately.
cargoTestFlags = [
"--"
"--test-threads=1"
"--skip"
"harness::sandbox::tests::test_internal_sandbox_exec_dev_null_and_dns"
];
# 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";
# nix-update rejects a leading dot in the attribute path (".#marmel" →
# AttributePathError), so the bare attribute name is what the bare
# `nix-update --flake` invocation takes. Verify with
# `nix-update --flake marmel --use-update-script`.
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, and since c98179d023 ("docs: add MIT license and
# update license metadata", Na1w/marmel#40) the repository also ships a
# LICENSE file at the root and Cargo.toml declares `license = "MIT"`, which
# both agree with lib.licenses.mit.
license = lib.licenses.mit;
sourceProvenance = with lib.sourceTypes; [ fromSource ];
mainProgram = "marmel";
platforms = lib.platforms.unix;
};
}