main
  1{ inputs, ... }:
  2let
  3  globals = import ../globals.nix { };
  4in
  5{
  6  # FIXME: migrate to pkgs and overlays on root
  7  additions =
  8    final: _prev:
  9    import ../pkgs {
 10      pkgs = final;
 11      inherit globals;
 12    };
 13  # Emacs 31 from the emacs-31 branch (not yet in emacs-overlay as a release)
 14  # Must be applied after emacs-overlay which provides emacs-unstable
 15  emacs-31 = final: prev: {
 16    emacs-31 = prev.emacs-git-pgtk.overrideAttrs (_old: {
 17      pname = "emacs-31";
 18      version = "31.0.50";
 19      src = final.fetchgit {
 20        url = "https://git.savannah.gnu.org/git/emacs.git";
 21        rev = "1754015c6034d65b047d0ada23a406f114d7850d"; # emacs-31 branch, 2026-05-20
 22        hash = "sha256-hSDMwhl4uVPy6NNyaPPmpu3swQfjE18S3XFgDtX3+BE=";
 23      };
 24    });
 25  };
 26
 27  modifications = final: prev: {
 28    # Pin SearXNG to latest commit for critical engine fixes:
 29    # - Google useragent bypass (#5892, 2026-03-23)
 30    # - Bing engine rework (#5793, 2026-03-18)
 31    # niri overlay removed — nixpkgs now ships 26.04 natively
 32
 33    searxng = prev.searxng.overrideAttrs (_oldAttrs: {
 34      version = "0-unstable-2026-03-23";
 35      src = final.fetchFromGitHub {
 36        owner = "searxng";
 37        repo = "searxng";
 38        rev = "2c1ce3bd37a2";
 39        hash = "sha256-Ml7aJXr4IudH/ZnlXDU8OdnUELBb6/vcpAAhAXwhW8A=";
 40      };
 41    });
 42    go_1_25_8 = prev.go_1_25.overrideAttrs (_finalAttrs: {
 43      version = "1.25.8";
 44      src = final.fetchurl {
 45        url = "https://go.dev/dl/go1.25.8.src.tar.gz";
 46        hash = "sha256-6YjUokRqx/4/baoImljpk2pSo4E1Wt7ByJgyMKjWxZ4=";
 47      };
 48    });
 49
 50    buildGo1258Module = prev.buildGoModule.override {
 51      go = final.go_1_25_8;
 52    };
 53
 54    cosign = prev.cosign.override {
 55      buildGoModule = final.buildGo126Module;
 56    };
 57
 58    # beets tests crash with QEMU/TCG assertion in pytestCheckPhase
 59    beets = prev.beets.overrideAttrs {
 60      doCheck = false;
 61      doInstallCheck = false;
 62    };
 63
 64    # Use feishin from master with mpv-unwrapped to avoid wrapper breakage
 65    # https://github.com/NixOS/nixpkgs/pull/459155
 66    feishin = final.master.feishin.override {
 67      mpv-unwrapped = prev.mpv-unwrapped;
 68    };
 69
 70  };
 71
 72  # When applied, the unstable nixpkgs set (declared in the flake inputs) will
 73  # be accessible through 'pkgs.unstable'
 74  unstable-packages = _final: prev: {
 75    master = import inputs.nixpkgs-master {
 76      system = prev.stdenv.hostPlatform.system;
 77      config.allowUnfree = true;
 78      overlays = [
 79        (_final: _prev: {
 80          inherit (_prev) claude-code;
 81          inherit (_prev) claude-agent-acp;
 82          inherit (_prev) codex;
 83          inherit (_prev) opencode;
 84          inherit (_prev) gemini-cli;
 85          inherit (_prev) cursor-cli;
 86          inherit (_prev) code-cursor;
 87          inherit (_prev) antigravity-cli;
 88          inherit (_prev) lazyworktree;
 89          inherit (_prev) devenv;
 90          inherit (_prev) apko;
 91          # example = prev.example.overrideAttrs (oldAttrs: rec {
 92          # ...
 93          # });
 94        })
 95      ];
 96    };
 97    unstable = import inputs.nixpkgs {
 98      system = prev.stdenv.hostPlatform.system;
 99      config.allowUnfree = true;
100      overlays = [
101        (_final: _prev: {
102          # example = prev.example.overrideAttrs (oldAttrs: rec {
103          # ...
104          # });
105        })
106      ];
107    };
108    wip = import inputs.nixpkgs-wip-consolidated {
109      system = prev.stdenv.hostPlatform.system;
110      config.allowUnfree = true;
111    };
112  };
113
114}