Skip to content

The agent that grows with you

3.8 KB
Raw Blame
# nix/packages.nix — Hermes Agent package built with uv2nix
{ inputs, ... }:
{
  perSystem =
    {
      pkgs,
      lib,
      inputs',
      ...
    }:
    let

      sandbox = pkgs.callPackage ./sandbox.nix { };

      # pm/lock.json translated into derivations — one per tool package
      # with an artifact for this system. The lockfile carries resolved
      # urls + hashes, so nix consumes it as pure data. callPackage adds
      # .override/.overrideDerivation to the returned SET; keep only the
      # real derivations.
      pmPackages = lib.filterAttrs (_: lib.isDerivation) (
        pkgs.callPackage ./pm-packages.nix { }
      );

      dirtyRevision = inputs.self.dirtyRev or null;
      # inputs.self.sourceInfo is a string (store path) in current Nix, not a
      # record. The metadata fields are available as top-level attributes on
      # inputs.self directly. A flake URL's requested ref is intentionally not
      # exposed as self.ref after Nix resolves it to an immutable source, so
      # branch is normally null for remote flakes. Preserve null rather than
      # inventing a sentinel that could be a real branch name.
      rev =
        inputs.self.rev or (if dirtyRevision != null then builtins.substring 0 40 dirtyRevision else null);
      rawRef = inputs.self.ref or null;
      branch = if rawRef != null then builtins.replaceStrings [ "refs/heads/" ] [ "" ] rawRef else null;
      dirty = dirtyRevision != null;
      lastModified = inputs.self.lastModified or null;
      minimal = pkgs.callPackage ./hermes-agent.nix {
        inherit (inputs) uv2nix pyproject-nix pyproject-build-systems;
        # Passed explicitly so `override (prev: ...)` sees it: a function form that appends to
        # `prev.extraDependencyGroups` worked before the shipped groups moved to
        # defaultDependencyGroups, and an argument default never lands in `prev`.
        extraDependencyGroups = [ ];
        npm-lockfile-fix = inputs'.npm-lockfile-fix.packages.default;
        inherit pmPackages;
        inherit
          rev
          branch
          dirty
          lastModified
          ;
      };

      # All platform-portable optional integrations pre-built. These are the
      # variant's own groups, not the user's extras, so an
      # `.override { extraDependencyGroups = ...; }` adds to them.
      full = minimal.override {
        defaultDependencyGroups = [
          "anthropic"
          "azure-identity"
          "bedrock"
          "daytona"
          "dingtalk"
          "edge-tts"
          "exa"
          "fal"
          "feishu"
          "firecrawl"
          "messaging"
          "modal"
          "parallel-web"
          "tts-premium"
          "vercel"
          "voice"
        ]
        # matrix is Linux-only (oqs/liboqs lacks aarch64-darwin wheels).
        ++ lib.optionals pkgs.stdenv.hostPlatform.isLinux [ "matrix" ];
      };
    in
    {
      packages = {
        node-gyp =
          (pkgs.callPackage ./lib.nix {
            inherit (pkgs) npm-lockfile-fix;
            inherit pmPackages;
          }).node-gyp;
        default = full;

        inherit sandbox;

        inherit minimal;

        # Ships discord.py + python-telegram-bot + slack-sdk so a plain
        # `nix profile install .#messaging` connects to Discord/Telegram/Slack
        # on first run — lazy-install can't write to the read-only /nix/store.
        messaging = minimal.override {
          defaultDependencyGroups = [ "messaging" ];
        };

        tui = full.hermesTui;
        web = full.hermesWeb;
        webapp = full.hermesWebapp;
        desktop = full.hermesDesktop;

        update-npm-lockfile = full.hermesNpmLib.updateNpmLockfile;
      }
      # Every pm lockfile tool as its own installable derivation:
      # `nix build .#pm-ripgrep`, `nix build .#pm-gh`, ...
      // lib.mapAttrs' (name: drv: lib.nameValuePair "pm-${name}" drv) pmPackages;
    };
}