From e327504f4ec276566f141aa3be52f66f0d7a5860 Mon Sep 17 00:00:00 2001 From: Alexander Miroshnichenko Date: Wed, 6 May 2026 18:21:18 +0300 Subject: [PATCH] feat(mcp-gateway): add NixOS module with systemd service Provides services.mcp-gateway module for easy systemd integration: config.services.mcp-gateway = { enable = true; configFile = "/etc/mcp-gateway/gateway.yaml"; }; --- flake.nix | 4 ++++ modules/mcp-gateway.nix | 46 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 modules/mcp-gateway.nix diff --git a/flake.nix b/flake.nix index d3b10a5..ed60dad 100644 --- a/flake.nix +++ b/flake.nix @@ -55,6 +55,10 @@ // { packages = inputs.nixpkgs.lib.recursiveUpdate blueprintOutputs.packages extraPackages; + nixosModules = { + mcp-gateway = ./modules/mcp-gateway.nix; + }; + overlays = { default = import ./overlays { inherit (blueprintOutputs) packages; diff --git a/modules/mcp-gateway.nix b/modules/mcp-gateway.nix new file mode 100644 index 0000000..cae5ebf --- /dev/null +++ b/modules/mcp-gateway.nix @@ -0,0 +1,46 @@ +{ config, lib, pkgs, ... }: + +let + cfg = config.services.mcp-gateway; + package = pkgs.mcp-gateway; +in + +{ + options.services.mcp-gateway = { + enable = lib.mkEnableOption "MCP Gateway service"; + + package = lib.mkOption { + type = lib.types.package; + default = package; + description = "The mcp-gateway package to use."; + }; + + configFile = lib.mkOption { + type = lib.types.path; + default = "/etc/mcp-gateway/gateway.yaml"; + description = "Path to the mcp-gateway configuration file."; + }; + + settings = lib.mkOption { + type = with lib.types; attrsOf (attrsOf anything); + default = {}; + description = "Configuration options for the systemd service."; + }; + }; + + config = lib.mkIf cfg.enable { + systemd.services.mcp-gateway = { + description = "MCP Gateway"; + wantedBy = [ "multi-user.target" ]; + wants = [ "network-online.target" ]; + after = [ "network-online.target" ]; + + serviceConfig = { + Type = "simple"; + ExecStart = "${cfg.package}/bin/mcp-gateway --config ${cfg.configFile} serve"; + Restart = "on-failure"; + RestartSec = 5; + } // cfg.settings; + }; + }; +}