mcchunkie/module.nix

69 lines
1.7 KiB
Nix
Raw Permalink Normal View History

2024-03-28 10:02:01 -06:00
{ lib, config, pkgs, ... }:
let cfg = config.services.mcchunkie;
in {
options = with lib; {
services.mcchunkie = {
enable = lib.mkEnableOption "Enable mcchunkie";
user = mkOption {
type = with types; oneOf [ str int ];
default = "mcchunkie";
description = ''
The user the service will use.
'';
};
group = mkOption {
type = with types; oneOf [ str int ];
default = "mcchunkie";
description = ''
The group the service will use.
'';
};
dataDir = mkOption {
type = types.path;
default = "/var/lib/mcchunkie";
description = "Path mcchunkie will use to store data";
};
package = mkOption {
type = types.package;
default = pkgs.mcchunkie;
defaultText = literalExpression "pkgs.mcchunkie";
description = "The package to use for mcchunkie";
};
};
};
config = lib.mkIf (cfg.enable) {
users.groups.${cfg.group} = { };
users.users.${cfg.user} = {
description = "mcchunkie service user";
isSystemUser = true;
home = "${cfg.dataDir}";
createHome = true;
group = "${cfg.group}";
};
systemd.services.mcchunkie = {
enable = true;
description = "mcchunkie server";
2024-07-02 14:56:51 -06:00
after = [ "network-online.target" ];
2024-06-12 10:12:40 -06:00
wants = [ "network-online.target" ];
2024-07-02 14:56:51 -06:00
wantedBy = [ "multi-user.target" ];
2024-03-28 10:02:01 -06:00
environment = { HOME = "${cfg.dataDir}"; };
serviceConfig = {
User = cfg.user;
Group = cfg.group;
ExecStart = ''
2024-03-28 12:26:16 -06:00
${cfg.package}/bin/mcchunkie -db ${cfg.dataDir}/db
2024-03-28 10:02:01 -06:00
'';
};
};
};
}