Skip to content

Commit

Permalink
nixos/murmur: support setting custom state directory
Browse files Browse the repository at this point in the history
  • Loading branch information
DCsunset committed Oct 14, 2024
1 parent 7acade5 commit ceb908a
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions nixos/modules/services/networking/murmur.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ let
cfg = config.services.murmur;
forking = cfg.logFile != null;
configFile = pkgs.writeText "murmurd.ini" ''
database=/var/lib/murmur/murmur.sqlite
database=${cfg.stateDir}/murmur.sqlite
dbDriver=QSQLITE
autobanAttempts=${toString cfg.autobanAttempts}
Expand Down Expand Up @@ -69,6 +69,14 @@ in
'';
};

stateDir = mkOption {
type = types.str;
default = "/var/lib/murmur";
description = ''
Directory to store data for the server.
'';
};

autobanAttempts = mkOption {
type = types.int;
default = 10;
Expand Down Expand Up @@ -291,7 +299,7 @@ in
config = mkIf cfg.enable {
users.users.murmur = {
description = "Murmur Service user";
home = "/var/lib/murmur";
home = cfg.stateDir;
createHome = true;
uid = config.ids.uids.murmur;
group = "murmur";
Expand Down Expand Up @@ -343,6 +351,7 @@ in
ProtectKernelModules = true;
ProtectKernelTunables = true;
ProtectSystem = "full";
ReadWritePaths = [ cfg.stateDir ];
RestrictAddressFamilies = "~AF_PACKET AF_NETLINK";
RestrictNamespaces = true;
RestrictSUIDSGID = true;
Expand Down Expand Up @@ -386,9 +395,9 @@ in
r ${config.environment.etc."os-release".source},
r ${config.environment.etc."lsb-release".source},
owner rwk /var/lib/murmur/murmur.sqlite,
owner rw /var/lib/murmur/murmur.sqlite-journal,
owner r /var/lib/murmur/,
owner rwk ${cfg.stateDir}/murmur.sqlite,
owner rw ${cfg.stateDir}/murmur.sqlite-journal,
owner r ${cfg.stateDir},
r /run/murmur/murmurd.pid,
r /run/murmur/murmurd.ini,
r ${configFile},
Expand Down

0 comments on commit ceb908a

Please sign in to comment.