Personal Nix setup
at main 1.3 kB view raw
1{ lib, helpers, config, ... }: 2 3with lib; let 4 cfg = config.modules.games; 5in { 6 options.modules.games = { 7 enable = mkOption { 8 default = false; 9 example = true; 10 description = "Whether to enable game server options."; 11 type = types.bool; 12 }; 13 14 datadir = mkOption { 15 type = types.path; 16 default = "/var/lib/games"; 17 description = "Base directory for all game servers created with this module."; 18 example = "/mnt/nfs/steam"; 19 }; 20 21 user = mkOption { 22 type = types.str; 23 default = "games"; 24 description = "User to use when running game servers and creating top-level resources"; 25 }; 26 27 group = mkOption { 28 type = types.str; 29 default = cfg.user; 30 defaultText = literalExpression "\${cfg.user}"; 31 description = "Group to use when running game servers"; 32 }; 33 }; 34} // helpers.linuxAttrs { 35 config = mkIf cfg.enable { 36 users.users."${cfg.user}" = { 37 home = "${cfg.datadir}"; 38 group = cfg.group; 39 isSystemUser = true; 40 createHome = true; 41 homeMode = "750"; 42 }; 43 44 users.groups."${cfg.group}" = {}; 45 46 systemd.tmpfiles.rules = [ 47 "d ${cfg.datadir}/.steam 0755 ${cfg.user} ${cfg.group} - -" 48 ]; 49 }; 50 51 imports = [ 52 ./palworld 53 ]; 54}