Files
imladris/configs/mcp.nix

57 lines
1.5 KiB
Nix

# MCP (Metacircular Control Plane) agent user and configuration.
#
# Creates a dedicated 'mcp' system user with rootless podman support
# and a systemd service for the agent daemon.
{ pkgs, ... }:
{
users.users.mcp = {
isSystemUser = true;
group = "mcp";
home = "/srv/mcp";
shell = pkgs.shadow; # nologin equivalent
subUidRanges = [{ startUid = 100000; count = 65536; }];
subGidRanges = [{ startGid = 100000; count = 65536; }];
# Lingering enables user services (podman) to run without an active login session.
linger = true;
};
users.groups.mcp = {};
systemd.services.mcp-agent = {
description = "MCP Agent";
after = [ "network-online.target" ];
wants = [ "network-online.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "simple";
ExecStart = "/usr/local/bin/mcp-agent server --config /srv/mcp/mcp-agent.toml";
Restart = "on-failure";
RestartSec = 5;
User = "mcp";
Group = "mcp";
Environment = [
"HOME=/srv/mcp"
"XDG_RUNTIME_DIR=/run/user/%U"
];
NoNewPrivileges = true;
ProtectSystem = "strict";
ProtectHome = true;
PrivateTmp = true;
PrivateDevices = true;
ProtectKernelTunables = true;
ProtectKernelModules = true;
ProtectControlGroups = true;
RestrictSUIDSGID = true;
RestrictNamespaces = true;
LockPersonality = true;
MemoryDenyWriteExecute = true;
RestrictRealtime = true;
ReadWritePaths = "/srv";
};
};
}