7 cfg = config.services.realm;
8 configFormat = pkgs.formats.json { };
9 configFile = configFormat.generate "config.json" cfg.config;
11 mkEnableOption mkPackageOption mkOption mkIf types getExe;
15 meta.maintainers = with lib.maintainers; [ ocfox ];
19 enable = mkEnableOption "A simple, high performance relay server written in rust";
20 package = mkPackageOption pkgs "realm" { };
22 type = types.submodule {
23 freeformType = configFormat.type;
27 The realm configuration, see <https://github.com/zhboner/realm#overview> for documentation.
33 config = mkIf cfg.enable {
34 systemd.services.realm = {
37 MemoryDenyWriteExecute = true;
38 PrivateDevices = true;
40 ProtectKernelLogs = true;
41 ProtectKernelModules = true;
42 ProtectProc = "invisible";
43 ProtectKernelTunables = true;
44 ExecStart = "${getExe cfg.package} --config ${configFile}";
45 AmbientCapabilities = [ "CAP_NET_ADMIN" "CAP_NET_BIND_SERVICE" ];
47 wantedBy = [ "multi-user.target" ];