8 cfg = config.services.realm;
9 configFormat = pkgs.formats.json { };
10 configFile = configFormat.generate "config.json" cfg.config;
22 meta.maintainers = with lib.maintainers; [ ocfox ];
26 enable = mkEnableOption "A simple, high performance relay server written in rust";
27 package = mkPackageOption pkgs "realm" { };
29 type = types.submodule {
30 freeformType = configFormat.type;
34 The realm configuration, see <https://github.com/zhboner/realm#overview> for documentation.
40 config = mkIf cfg.enable {
41 systemd.services.realm = {
44 MemoryDenyWriteExecute = true;
45 PrivateDevices = true;
47 ProtectKernelLogs = true;
48 ProtectKernelModules = true;
49 ProtectProc = "invisible";
50 ProtectKernelTunables = true;
51 ExecStart = "${getExe cfg.package} --config ${configFile}";
52 AmbientCapabilities = [
54 "CAP_NET_BIND_SERVICE"
57 wantedBy = [ "multi-user.target" ];