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    # Track latest niri release (nixpkgs is on 25.11, upstream has 26.04)
 32    niri =
 33      let
 34        src = final.fetchFromGitHub {
 35          owner = "niri-wm";
 36          repo = "niri";
 37          tag = "v26.04";
 38          hash = "sha256-ehSMsSpE+0k8r+2Vseu8kangsYxToZv3vinynsDp9zs=";
 39        };
 40      in
 41      prev.niri.overrideAttrs (_old: {
 42        version = "26.04";
 43        inherit src;
 44        postPatch = ''
 45          patchShebangs resources/niri-session
 46        '';
 47        cargoDeps = final.rustPlatform.fetchCargoVendor {
 48          inherit src;
 49          name = "niri-26.04-vendor";
 50          hash = "sha256-gfnalA3qI3a9h3PvsxgQLCrzapfjLLkxhTMJpwRh+ro=";
 51        };
 52      });
 53
 54    searxng = prev.searxng.overrideAttrs (_oldAttrs: {
 55      version = "0-unstable-2026-03-23";
 56      src = final.fetchFromGitHub {
 57        owner = "searxng";
 58        repo = "searxng";
 59        rev = "2c1ce3bd37a2";
 60        hash = "sha256-Ml7aJXr4IudH/ZnlXDU8OdnUELBb6/vcpAAhAXwhW8A=";
 61      };
 62    });
 63    go_1_25_8 = prev.go_1_25.overrideAttrs (_finalAttrs: {
 64      version = "1.25.8";
 65      src = final.fetchurl {
 66        url = "https://go.dev/dl/go1.25.8.src.tar.gz";
 67        hash = "sha256-6YjUokRqx/4/baoImljpk2pSo4E1Wt7ByJgyMKjWxZ4=";
 68      };
 69    });
 70
 71    buildGo1258Module = prev.buildGoModule.override {
 72      go = final.go_1_25_8;
 73    };
 74
 75    cosign = prev.cosign.override {
 76      buildGoModule = final.buildGo1258Module;
 77    };
 78
 79    # Use feishin from master with mpv-unwrapped to avoid wrapper breakage
 80    # https://github.com/NixOS/nixpkgs/pull/459155
 81    feishin = final.master.feishin.override {
 82      mpv-unwrapped = prev.mpv-unwrapped;
 83    };
 84
 85  };
 86
 87  # When applied, the unstable nixpkgs set (declared in the flake inputs) will
 88  # be accessible through 'pkgs.unstable'
 89  unstable-packages = _final: prev: {
 90    master = import inputs.nixpkgs-master {
 91      system = prev.stdenv.hostPlatform.system;
 92      config.allowUnfree = true;
 93      overlays = [
 94        (_final: _prev: {
 95          inherit (_prev) claude-code;
 96          inherit (_prev) claude-agent-acp;
 97          inherit (_prev) codex;
 98          inherit (_prev) opencode;
 99          inherit (_prev) gemini-cli;
100          inherit (_prev) cursor-cli;
101          inherit (_prev) code-cursor;
102          inherit (_prev) antigravity;
103          inherit (_prev) lazyworktree;
104          inherit (_prev) devenv;
105          inherit (_prev) apko;
106          # example = prev.example.overrideAttrs (oldAttrs: rec {
107          # ...
108          # });
109        })
110      ];
111    };
112    unstable = import inputs.nixpkgs {
113      system = prev.stdenv.hostPlatform.system;
114      config.allowUnfree = true;
115      overlays = [
116        (_final: _prev: {
117          # example = prev.example.overrideAttrs (oldAttrs: rec {
118          # ...
119          # });
120        })
121      ];
122    };
123    wip = import inputs.nixpkgs-wip-consolidated {
124      system = prev.stdenv.hostPlatform.system;
125      config.allowUnfree = true;
126    };
127  };
128
129}