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.override {
 42        # niri 26.04 requires libdisplay-info < 0.4.0, nixpkgs has 0.4.0
 43        libdisplay-info = prev.libdisplay-info.overrideAttrs (_old: rec {
 44          version = "0.3.0";
 45          src = final.fetchurl {
 46            url = "https://gitlab.freedesktop.org/emersion/libdisplay-info/-/releases/${version}/downloads/libdisplay-info-${version}.tar.xz";
 47            hash = "sha256-aud82Tf5z30TIdNcEWBixJEehEcBCmpxOsQob3qdWYc=";
 48          };
 49        });
 50      }).overrideAttrs
 51        (_old: {
 52          version = "26.04";
 53          inherit src;
 54          postPatch = ''
 55            patchShebangs resources/niri-session
 56          '';
 57          cargoDeps = final.rustPlatform.fetchCargoVendor {
 58            inherit src;
 59            name = "niri-26.04-vendor";
 60            hash = "sha256-gfnalA3qI3a9h3PvsxgQLCrzapfjLLkxhTMJpwRh+ro=";
 61          };
 62        });
 63
 64    searxng = prev.searxng.overrideAttrs (_oldAttrs: {
 65      version = "0-unstable-2026-03-23";
 66      src = final.fetchFromGitHub {
 67        owner = "searxng";
 68        repo = "searxng";
 69        rev = "2c1ce3bd37a2";
 70        hash = "sha256-Ml7aJXr4IudH/ZnlXDU8OdnUELBb6/vcpAAhAXwhW8A=";
 71      };
 72    });
 73    go_1_25_8 = prev.go_1_25.overrideAttrs (_finalAttrs: {
 74      version = "1.25.8";
 75      src = final.fetchurl {
 76        url = "https://go.dev/dl/go1.25.8.src.tar.gz";
 77        hash = "sha256-6YjUokRqx/4/baoImljpk2pSo4E1Wt7ByJgyMKjWxZ4=";
 78      };
 79    });
 80
 81    buildGo1258Module = prev.buildGoModule.override {
 82      go = final.go_1_25_8;
 83    };
 84
 85    cosign = prev.cosign.override {
 86      buildGoModule = final.buildGo126Module;
 87    };
 88
 89    # beets tests crash with QEMU/TCG assertion in pytestCheckPhase
 90    beets = prev.beets.overrideAttrs {
 91      doCheck = false;
 92      doInstallCheck = false;
 93    };
 94
 95    # Use feishin from master with mpv-unwrapped to avoid wrapper breakage
 96    # https://github.com/NixOS/nixpkgs/pull/459155
 97    feishin = final.master.feishin.override {
 98      mpv-unwrapped = prev.mpv-unwrapped;
 99    };
100
101  };
102
103  # When applied, the unstable nixpkgs set (declared in the flake inputs) will
104  # be accessible through 'pkgs.unstable'
105  unstable-packages = _final: prev: {
106    master = import inputs.nixpkgs-master {
107      system = prev.stdenv.hostPlatform.system;
108      config.allowUnfree = true;
109      overlays = [
110        (_final: _prev: {
111          inherit (_prev) claude-code;
112          inherit (_prev) claude-agent-acp;
113          inherit (_prev) codex;
114          inherit (_prev) opencode;
115          inherit (_prev) gemini-cli;
116          inherit (_prev) cursor-cli;
117          inherit (_prev) code-cursor;
118          inherit (_prev) antigravity-cli;
119          inherit (_prev) lazyworktree;
120          inherit (_prev) devenv;
121          inherit (_prev) apko;
122          # example = prev.example.overrideAttrs (oldAttrs: rec {
123          # ...
124          # });
125        })
126      ];
127    };
128    unstable = import inputs.nixpkgs {
129      system = prev.stdenv.hostPlatform.system;
130      config.allowUnfree = true;
131      overlays = [
132        (_final: _prev: {
133          # example = prev.example.overrideAttrs (oldAttrs: rec {
134          # ...
135          # });
136        })
137      ];
138    };
139    wip = import inputs.nixpkgs-wip-consolidated {
140      system = prev.stdenv.hostPlatform.system;
141      config.allowUnfree = true;
142    };
143  };
144
145}