Files
millerson-overlay.nix/packages/omniroute/package.nix
Alexander Miroshnichenko 6afcc00165
Some checks failed
CI / check (push) Has been cancelled
feat(packages): add omniroute package
Add OmniRoute v3.8.28 - a unified AI router aggregating 160+ providers
with auto fallback, MCP/A2A support, and OpenAI-compatible APIs.

Uses a hybrid approach: GitHub source for dependency resolution via
fetchNpmDeps, combined with pre-built dist/ from the npm tarball to
avoid the complex Next.js build in the Nix sandbox.
2026-06-19 09:39:05 +03:00

89 lines
2.1 KiB
Nix

{
lib,
buildNpmPackage,
fetchFromGitHub,
fetchurl,
nodejs_22,
makeBinaryWrapper,
}:
let
version = "3.8.28";
npmTarball = fetchurl {
url = "https://registry.npmjs.org/omniroute/-/omniroute-${version}.tgz";
hash = "sha256-/le4p5DSX5T7/srNuxVBLepzUPw8BgIVio+h0JnbfyY=";
};
in
buildNpmPackage (finalAttrs: {
pname = "omniroute";
inherit version;
src = fetchFromGitHub {
owner = "diegosouzapw";
repo = "OmniRoute";
rev = "v${finalAttrs.version}";
hash = "sha256-BRvpbhhLTYj2rKw+nZloaXkpu3ySs5sWZo9425xvAPs=";
};
nodejs = nodejs_22;
npmDepsHash = "sha256-Q1KLR3NkeFBB+tQzBazy+XWyIfpG8Magv+rdeqISNxw=";
# Skip Next.js build (requires network for Google Fonts).
# Pre-built dist/ is copied from the npm tarball in preConfigure.
dontNpmBuild = true;
nativeBuildInputs = [
makeBinaryWrapper
];
npmInstallFlags = [ "--ignore-scripts" ];
npmRebuildFlags = [ "--ignore-scripts" ];
env = {
HOME = "$TMPDIR";
};
preConfigure = ''
mkdir -p _npm_tmp
tar xzf ${npmTarball} -C _npm_tmp
cp -r _npm_tmp/package/dist .
rm -rf _npm_tmp
'';
installPhase = ''
runHook preInstall
mkdir -p $out/lib/node_modules/omniroute
cp -r . $out/lib/node_modules/omniroute/
mkdir -p $out/bin
makeWrapper "${nodejs_22}/bin/node" "$out/bin/omniroute" \
--add-flags "$out/lib/node_modules/omniroute/bin/omniroute.mjs"
makeWrapper "${nodejs_22}/bin/node" "$out/bin/omniroute-reset-password" \
--add-flags "$out/lib/node_modules/omniroute/bin/reset-password.mjs"
runHook postInstall
'';
passthru = {
category = "AI LLM Gateway";
updateScript = [
"nix-update"
"--flake"
".#omniroute"
];
};
meta = {
description = "Unified AI router with 160+ providers, RTK+Caveman compression, auto fallback, MCP/A2A, OpenAI-compatible APIs";
homepage = "https://github.com/diegosouzapw/OmniRoute";
changelog = "https://github.com/diegosouzapw/OmniRoute/releases/tag/v${finalAttrs.version}";
license = lib.licenses.mit;
mainProgram = "omniroute";
platforms = lib.platforms.all;
};
})