Sibling to ensure_core_avatar (#320). Same one-shot marker-guarded upload pattern, this time aimed at the Forgejo per-org avatar endpoint (`POST /api/v1/orgs/{org}/avatar`). ## SVG-to-PNG at build time Mara: *don't check in the png. instead generate png on the fly or in build.* `hive-c0re/build.rs` renders `branding/agent-configs.svg` → `$OUT_DIR/agent-configs.png` via `rsvg-convert` (librsvg) on every compile; `forge.rs` then `include_bytes!`s the OUT_DIR PNG. The raster never gets checked into git — SVG stays source of truth, the PNG is a build artifact. - `hive-c0re/Cargo.toml`: declares `build = "build.rs"` - `flake.nix`: adds `librsvg` to `naersk-lib.buildPackage` `nativeBuildInputs` (covers both the runtime package and the clippy check derivation) and to the dev shell so local `cargo build` finds `rsvg-convert` on PATH. - For dev builds outside Nix, install librsvg (Debian: `librsvg2-bin`, macOS: `brew install librsvg`). ## Icon design Sibling visual to the main hyperhive mark — same dark base + outer ring + corner-bracket frame so the family reads at a glance. Centre swaps the hexagonal hive for a stacked-config-files motif: three offset sheets, folded-corner affordance, curly-brace `{ }` glyph telegraphing "config file." Brace font-size dropped 78→56 + letter-spacing -3 (#424 mara: "braces cross the boundaries of the page") so the glyphs sit comfortably inside the 120-wide front sheet with clear breathing room on the left/right edges. The stack is shifted so the front sheet centres on canvas-(150, 150); brace text anchors there with `dominant-baseline=central` for true vertical centring. ## Validation - `cargo check` clean (only pre-existing warnings). - One-shot marker honoured: re-runs of `ensure_all` skip after the first success; `rm /var/lib/hyperhive/forge-agent-configs-avatar-set` forces re-upload (useful for icon revisions). - Behaviour mirrors the existing `ensure_core_avatar` pattern. Browser smoke test isn't possible from inside iris's container. Worth eyeballing post-deploy: `http://localhost:3000/agent-configs` should show the new avatar where the default identicon used to be.
217 lines
7.6 KiB
Nix
217 lines
7.6 KiB
Nix
{
|
|
description = "hyperhive — multi-Claude-Code-agent orchestration on nixos-containers";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
|
|
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
|
naersk = {
|
|
url = "github:nix-community/naersk";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
treefmt-nix = {
|
|
url = "github:numtide/treefmt-nix";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
};
|
|
|
|
outputs =
|
|
inputs@{
|
|
self,
|
|
nixpkgs,
|
|
nixpkgs-unstable,
|
|
naersk,
|
|
treefmt-nix,
|
|
}:
|
|
let
|
|
inherit (nixpkgs) lib;
|
|
systems = [
|
|
"aarch64-linux"
|
|
"x86_64-linux"
|
|
];
|
|
treefmt-config = {
|
|
projectRootFile = "flake.nix";
|
|
programs = {
|
|
keep-sorted.enable = true;
|
|
nixfmt.enable = true;
|
|
rustfmt.enable = true;
|
|
taplo.enable = true;
|
|
};
|
|
};
|
|
forAllSystems =
|
|
f:
|
|
lib.genAttrs systems (
|
|
system:
|
|
f rec {
|
|
inherit system;
|
|
pkgs = nixpkgs.legacyPackages.${system};
|
|
treefmt-eval = treefmt-nix.lib.evalModule pkgs treefmt-config;
|
|
naersk-lib = pkgs.callPackage naersk { };
|
|
}
|
|
);
|
|
in
|
|
{
|
|
packages = forAllSystems (
|
|
{ pkgs, naersk-lib, ... }:
|
|
{
|
|
default = naersk-lib.buildPackage {
|
|
src = ./.;
|
|
# librsvg ships `rsvg-convert`, which hive-c0re/build.rs
|
|
# invokes to render branding/agent-configs.svg into the
|
|
# PNG it embeds via `include_bytes!` (#424). Keeps the
|
|
# raster out of git — SVG stays source-of-truth, PNG is
|
|
# a build artifact in $OUT_DIR.
|
|
nativeBuildInputs = [ pkgs.librsvg ];
|
|
meta.description = "hyperhive workspace (hive-c0re, hive-ag3nt, hive-m1nd)";
|
|
};
|
|
# Bundled browser assets — see ./nix/frontend.nix. Output is
|
|
# $out/{dashboard,agent}/ which the Rust binaries serve via
|
|
# tower_http::ServeDir (wired up in Phase 4 of #273).
|
|
frontend = pkgs.callPackage ./nix/frontend.nix {
|
|
branding-svg = ./branding/hyperhive.svg;
|
|
};
|
|
}
|
|
);
|
|
|
|
overlays = {
|
|
default = final: prev: {
|
|
hyperhive = self.packages.${prev.stdenv.hostPlatform.system}.default;
|
|
# Bundled frontend dist (see ./nix/frontend.nix). Output is
|
|
# $out/{dashboard,agent}/; consumers pick the surface they
|
|
# need. Exposed via the overlay so containers' nix evaluations
|
|
# can reach it as `pkgs.hyperhive-frontend` once the overlay
|
|
# is applied (manager + agent containers both apply it via
|
|
# `mkContainer` further down).
|
|
hyperhive-frontend = self.packages.${prev.stdenv.hostPlatform.system}.frontend;
|
|
};
|
|
claude-unstable =
|
|
final: prev:
|
|
let
|
|
# The overlay imports its own nixpkgs-unstable instance to
|
|
# pin claude-code there. That instance has its own config
|
|
# (independent from the user's prev.config), so we have to
|
|
# set allowUnfreePredicate inline to whitelist claude-code
|
|
# specifically — otherwise the unstable import itself
|
|
# refuses to evaluate. This is scoped: only claude-code
|
|
# bypasses unfree, nothing else.
|
|
unstable = import nixpkgs-unstable {
|
|
inherit (prev.stdenv.hostPlatform) system;
|
|
config.allowUnfreePredicate = pkg: builtins.elem (prev.lib.getName pkg) [ "claude-code" ];
|
|
};
|
|
in
|
|
{
|
|
inherit (unstable) claude-code;
|
|
};
|
|
};
|
|
|
|
nixosModules = {
|
|
agent-base = ./nix/templates/agent-base.nix;
|
|
manager = ./nix/templates/manager.nix;
|
|
# The hive-c0re module wants `pkgs.hyperhive` for its default
|
|
# `services.hive-c0re.package`. To avoid making operators apply an
|
|
# overlay (which would also pollute their host pkgs with our
|
|
# build), we thread the package straight from this flake's
|
|
# `packages.<system>.default` via a `hyperhivePackage` argument.
|
|
# The `claude-unstable` overlay only matters inside our container
|
|
# builds (already applied internally in `nixosConfigurations`).
|
|
hive-c0re = import ./nix/modules/hive-c0re.nix {
|
|
hyperhivePackage = system: self.packages.${system}.default;
|
|
hyperhiveFrontend = system: self.packages.${system}.frontend;
|
|
hyperhiveFlake = "${self}";
|
|
};
|
|
hive-forge = ./nix/modules/hive-forge.nix;
|
|
# Convenience alias: one import covers the full hyperhive host
|
|
# stack (hive-c0re + hive-forge, since hive-c0re already pulls
|
|
# in hive-forge). Intended usage:
|
|
#
|
|
# imports = [ hyperhive.nixosModules.default ];
|
|
# services.hive-c0re.enable = true;
|
|
#
|
|
default = self.nixosModules.hive-c0re;
|
|
};
|
|
|
|
nixosConfigurations =
|
|
let
|
|
mkContainer =
|
|
module:
|
|
nixpkgs.lib.nixosSystem {
|
|
system = "x86_64-linux";
|
|
modules = [
|
|
module
|
|
{
|
|
nixpkgs.overlays = [
|
|
self.overlays.default
|
|
self.overlays.claude-unstable
|
|
];
|
|
}
|
|
];
|
|
};
|
|
in
|
|
{
|
|
agent-base = mkContainer self.nixosModules.agent-base;
|
|
manager = mkContainer self.nixosModules.manager;
|
|
};
|
|
|
|
devShells = forAllSystems (
|
|
{ pkgs, ... }:
|
|
{
|
|
default = pkgs.mkShell {
|
|
packages = with pkgs; [
|
|
cargo
|
|
clippy
|
|
librsvg # rsvg-convert — hive-c0re/build.rs invokes it (#424)
|
|
pkg-config
|
|
rust-analyzer
|
|
rustc
|
|
rustfmt
|
|
sqlite
|
|
];
|
|
};
|
|
}
|
|
);
|
|
|
|
formatter = forAllSystems ({ treefmt-eval, ... }: treefmt-eval.config.build.wrapper);
|
|
|
|
checks = forAllSystems (
|
|
{
|
|
treefmt-eval,
|
|
pkgs,
|
|
naersk-lib,
|
|
...
|
|
}:
|
|
{
|
|
formatting = treefmt-eval.config.build.check self;
|
|
# Clippy as a check: reuse naersk's vendored-deps environment but
|
|
# replace the build phase with `cargo clippy --workspace --all-targets
|
|
# -- -D warnings`. Naersk's own `mode = "clippy"` mangles the `--`
|
|
# separator, so we go through overrideAttrs instead.
|
|
clippy =
|
|
(naersk-lib.buildPackage {
|
|
src = ./.;
|
|
# Skip the actual build; we only care about the clippy lint.
|
|
doCheck = false;
|
|
copyTarget = false;
|
|
# hive-c0re/build.rs needs rsvg-convert on PATH (#424);
|
|
# mirror the runtime derivation's nativeBuildInputs so
|
|
# clippy's vendored-deps build phase doesn't break on
|
|
# the missing tool.
|
|
nativeBuildInputs = [ pkgs.librsvg ];
|
|
}).overrideAttrs
|
|
(old: {
|
|
name = "${old.name}-clippy";
|
|
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ pkgs.clippy ];
|
|
buildPhase = ''
|
|
runHook preBuild
|
|
cargo clippy --workspace --all-targets -- -D warnings
|
|
runHook postBuild
|
|
'';
|
|
installPhase = ''
|
|
runHook preInstall
|
|
mkdir -p $out
|
|
touch $out/.clippy-passed
|
|
runHook postInstall
|
|
'';
|
|
});
|
|
}
|
|
);
|
|
};
|
|
}
|