Add declarative group configuration

This commit is contained in:
Charlotte 🦝 Delenk 2022-02-20 18:19:39 +01:00
parent 81894c151e
commit 7fe4bd4e52
Signed by: darkkirb
GPG key ID: AB2BD8DAF2E37122
3 changed files with 52 additions and 2 deletions

View file

@ -1,4 +1,4 @@
{ ... }: {
{ config, ... }: {
imports = [
../../modules/minecraft/server.nix
../../modules/minecraft/luckperms.nix
@ -57,6 +57,24 @@
config = {
enable-ops = false;
};
groups = {
admin = {
name = "admin";
permissions = [
"*"
];
prefixes = [
{
"&d@" = {
priority = 0;
};
}
];
};
};
};
};
networking.firewall.allowedTCPPorts = [
config.services.minecraft.properties.server-port
];
}

View file

@ -5,9 +5,17 @@ let
cfg = config.services.minecraft.luckperms;
opt = options.services.minecraft.luckperms;
luckperms-yml = pkgs.writeText "luckperms.yml" (generators.toYAML { } cfg.config);
groups = builtins.mapAttrs (name: value: pkgs.writeText "${name}.yml" (generators.toYAML { } value)) cfg.groups;
permCopy = builtins.map
(group: ''
cat ${groups.${group}} > plugins/LuckPerms/yaml-storage/groups/${group}.yml
'')
(builtins.attrNames groups);
startScript = pkgs.writeScript "luckperms" ''
mkdir -p plugins/LuckPerms
cat ${luckperms-yml} > plugins/LuckPerms/config.yml
mkdir -p plugins/LuckPerms/yaml-storage/groups/
${builtins.toString permCopy}
'';
in
{
@ -295,6 +303,29 @@ in
description = "Resolve command selectors";
};
};
groups = mkOption {
default = {
default = {
name = "default";
};
};
type = types.attrsOf (types.submodule {
options = {
name = mkOption {
type = types.str;
};
permissions = mkOption {
default = [ ];
type = types.listOf types.str;
};
prefixes = mkOption {
default = [ ];
type = types.listOf (types.attrsOf types.anything);
};
};
});
description = "Group configuration";
};
};
config = mkIf cfg.enable {
services.minecraft.plugins = [{

View file

@ -92,7 +92,7 @@ let
SOA = {
nameServer = "ns2.darkkirb.de.";
adminEmail = "lotte@chir.rs";
serial = 3;
serial = 4;
};
NS = [
"ns2.darkkirb.de."
@ -165,6 +165,7 @@ let
api = createZone { };
git = createZone { };
mail = createZone { };
mc = createZone { };
int = delegateTo [
"ns2.darkkirb.de."