nixos-config/modules/minecraft/luckperms.nix

411 lines
12 KiB
Nix
Raw Normal View History

2022-06-12 15:39:15 +00:00
{
config,
lib,
options,
pkgs,
...
}:
with lib; let
luckperms = pkgs.callPackage ../../packages/minecraft/luckperms.nix {};
2022-02-20 15:30:04 +00:00
cfg = config.services.minecraft.luckperms;
opt = options.services.minecraft.luckperms;
2022-06-12 15:39:15 +00:00
luckperms-yml = pkgs.writeText "luckperms.yml" (generators.toYAML {} cfg.config);
groups = builtins.mapAttrs (name: value: pkgs.writeText "${name}.yml" (generators.toYAML {} value)) cfg.groups;
users = builtins.mapAttrs (name: value: pkgs.writeText "${name}.yml" (generators.toYAML {} value)) cfg.users;
groupPermCopy =
builtins.map
2022-02-20 17:19:39 +00:00
(group: ''
cat ${groups.${group}} > plugins/LuckPerms/yaml-storage/groups/${group}.yml
'')
(builtins.attrNames groups);
2022-06-12 15:39:15 +00:00
userPermCopy =
builtins.map
2022-02-20 17:52:23 +00:00
(user: ''
cat ${users.${user}} > plugins/LuckPerms/yaml-storage/users/${user}.yml
'')
2022-02-20 17:55:23 +00:00
(builtins.attrNames users);
2022-02-20 16:28:44 +00:00
startScript = pkgs.writeScript "luckperms" ''
mkdir -p plugins/LuckPerms
cat ${luckperms-yml} > plugins/LuckPerms/config.yml
2022-02-20 17:19:39 +00:00
mkdir -p plugins/LuckPerms/yaml-storage/groups/
2022-02-20 17:52:23 +00:00
${builtins.toString groupPermCopy}
mkdir -p plugins/LuckPerms/yaml-storage/users/
${builtins.toString userPermCopy}
2022-02-20 16:28:44 +00:00
'';
2022-06-12 15:39:15 +00:00
in {
2022-02-20 19:16:11 +00:00
imports = [
./vault.nix
];
2022-02-20 15:30:04 +00:00
options.services.minecraft.luckperms = {
enable = mkOption {
default = false;
type = types.bool;
description = "Enable LuckPerms";
};
2022-02-20 16:28:44 +00:00
config = {
server = mkOption {
default = "global";
type = types.str;
description = "Server Name to use for LuckPerms";
};
use-server-uuid-cache = mkOption {
default = false;
type = types.bool;
description = "Use the server UUID cache";
};
storage-method = mkOption {
default = "yaml";
type = types.str;
description = "Storage method to use for LuckPerms";
};
sync-minutes = mkOption {
default = -1;
type = types.int;
description = "How often to sync with the database";
};
watch-files = mkOption {
default = true;
type = types.bool;
description = "Watch for changes";
};
messaging-service = mkOption {
default = "auto";
type = types.str;
description = "Messaging service to use for LuckPerms";
};
auto-push-updates = mkOption {
default = true;
type = types.bool;
description = "Automatically push updates to the database";
};
push-log-entries = mkOption {
default = true;
type = types.bool;
description = "Push log entries to the database";
};
broadcast-received-log-entries = mkOption {
default = true;
type = types.bool;
description = "Broadcast log entries to the server";
};
temporary-add-behaviour = mkOption {
default = "deny";
2022-06-12 15:39:15 +00:00
type = types.enum ["accumulate" "replace" "deny"];
2022-02-20 16:28:44 +00:00
description = "How to handle temporary permissions";
};
primary-group-calculation = mkOption {
default = "parents-by-weight";
2022-06-12 15:39:15 +00:00
type = types.enum ["stored" "parents-by-weight" "all-parents-by-weight"];
2022-02-20 16:28:44 +00:00
description = "How to calculate the primary group";
};
argument-based-command-permissions = mkOption {
default = false;
type = types.bool;
description = "Enable argument-based command permissions";
};
require-sender-group-membership-to-modify = mkOption {
default = false;
type = types.bool;
description = "Require sender group membership to modify permissions";
};
log-notify = mkOption {
default = true;
type = types.bool;
description = "Log notifications";
};
log-notify-filtered-descriptions = mkOption {
2022-06-12 15:39:15 +00:00
default = [];
2022-02-20 16:28:44 +00:00
type = types.listOf types.str;
description = "Log filtered descriptions";
};
auto-install-translations = mkOption {
default = true;
type = types.bool;
description = "Automatically install translations";
};
inheritance-traversal-algorithm = mkOption {
default = "depth-first-pre-order";
2022-06-12 15:39:15 +00:00
type = types.enum ["breadth-first" "depth-first-pre-order" "depth-first-post-order"];
2022-02-20 16:28:44 +00:00
description = "Inheritance traversal algorithm";
};
post-traversal-inheritance-sort = mkOption {
default = false;
type = types.bool;
description = "Sort post-traversal inheritance";
};
context-satisfy-mode = mkOption {
default = "at-least-one-value-per-key";
2022-06-12 15:39:15 +00:00
type = types.enum ["at-least-one-value-per-key" "all-values-per-key"];
2022-02-20 16:28:44 +00:00
description = "Context satisfy mode";
};
disabled-contexts = mkOption {
2022-06-12 15:39:15 +00:00
default = [];
2022-02-20 16:28:44 +00:00
type = types.listOf types.str;
description = "Disabled contexts";
};
include-global = mkOption {
default = true;
type = types.bool;
description = "Include global permissions";
};
include-global-world = mkOption {
default = true;
type = types.bool;
description = "Include global world permissions";
};
apply-global-groups = mkOption {
default = true;
type = types.bool;
description = "Apply global groups";
};
apply-global-world-groups = mkOption {
default = true;
type = types.bool;
description = "Apply global world groups";
};
meta-value-selection-default = mkOption {
default = "inheritance";
2022-06-12 15:39:15 +00:00
type = types.enum ["inheritance" "highest-number" "lowest-number"];
2022-02-20 16:28:44 +00:00
description = "Meta value selection default";
};
meta-value-selection = mkOption {
2022-06-12 15:39:15 +00:00
default = {};
type = types.attrsOf (types.enum ["inheritance" "highest-number" "lowest-number"]);
2022-02-20 16:28:44 +00:00
description = "Meta value selection";
};
apply-wildcards = mkOption {
default = true;
type = types.bool;
description = "Apply wildcards";
};
apply-sponge-implicit-wildcards = mkOption {
default = false;
type = types.bool;
description = "Apply Sponge implicit wildcards";
};
apply-default-negated-permissions-before-wildcards = mkOption {
default = false;
type = types.bool;
description = "Apply default negated permissions before wildcards";
};
apply-regex = mkOption {
default = true;
type = types.bool;
description = "Apply regex";
};
apply-shorthand = mkOption {
default = true;
type = types.bool;
description = "Apply shorthand";
};
apply-bukkit-child-permissions = mkOption {
default = true;
type = types.bool;
description = "Apply Bukkit child permissions";
};
apply-bukkit-default-permissions = mkOption {
default = true;
type = types.bool;
description = "Apply Bukkit default permissions";
};
apply-bukkit-attachment-permissions = mkOption {
default = true;
type = types.bool;
description = "Apply Bukkit attachment permissions";
};
disabled-context-calculators = mkOption {
2022-06-12 15:39:15 +00:00
default = [];
2022-02-20 16:28:44 +00:00
type = types.listOf types.str;
description = "Disabled context calculators";
};
world-rewrite = mkOption {
2022-06-12 15:39:15 +00:00
default = {};
2022-02-20 16:28:44 +00:00
type = types.attrsOf types.str;
description = "World rewrite";
};
group-weight = mkOption {
2022-06-12 15:39:15 +00:00
default = {};
2022-02-20 16:28:44 +00:00
type = types.attrsOf types.int;
description = "Group weight";
};
enable-ops = mkOption {
default = true;
type = types.bool;
description = "Enable ops";
};
auto-op = mkOption {
default = false;
type = types.bool;
description = "Automatically op players";
};
commands-allow-op = mkOption {
default = false;
type = types.bool;
description = "Commands allow op";
};
vault-unsafe-lookups = mkOption {
default = false;
type = types.bool;
description = "Vault unsafe lookups";
};
vault-group-use-displaynames = mkOption {
default = true;
type = types.bool;
description = "Vault group use displaynames";
};
vault-npc-group = mkOption {
default = "default";
type = types.str;
description = "Vault NPC group";
};
vault-npc-op-status = mkOption {
default = false;
type = types.bool;
description = "Vault NPC op status";
};
use-vault-server = mkOption {
default = false;
type = types.bool;
description = "Use Vault server";
};
vault-server = mkOption {
default = "global";
type = types.str;
description = "Vault server";
};
vault-include-global = mkOption {
default = true;
type = types.bool;
description = "Vault include global";
};
vault-ignore-world = mkOption {
default = false;
type = types.bool;
description = "Vault ignore world";
};
debug-logins = mkOption {
default = false;
type = types.bool;
description = "Debug logins";
};
allow-invalid-usernames = mkOption {
default = false;
type = types.bool;
description = "Allow invalid usernames";
};
skip-bulkupdate-confirmation = mkOption {
default = false;
type = types.bool;
description = "Skip bulkupdate confirmation";
};
prevent-primary-group-removal = mkOption {
default = false;
type = types.bool;
description = "Prevent primary group removal";
};
update-client-command-list = mkOption {
default = true;
type = types.bool;
description = "Update client command list";
};
register-command-list-data = mkOption {
default = true;
type = types.bool;
description = "Register command list data";
};
resolve-command-selectors = mkOption {
default = false;
type = types.bool;
description = "Resolve command selectors";
};
};
2022-02-20 17:19:39 +00:00
groups = mkOption {
default = {
default = {
name = "default";
};
};
type = types.attrsOf (types.submodule {
options = {
name = mkOption {
type = types.str;
};
2022-02-20 17:52:23 +00:00
parents = mkOption {
2022-06-12 15:39:15 +00:00
default = [];
2022-02-20 17:52:23 +00:00
type = types.listOf types.str;
};
2022-02-20 17:19:39 +00:00
permissions = mkOption {
2022-06-12 15:39:15 +00:00
default = [];
2022-02-21 10:48:18 +00:00
type = types.listOf (types.oneOf [
types.str
(types.attrsOf (types.submodule {
options = {
value = mkOption {
type = types.bool;
default = true;
};
context = mkOption {
2022-06-12 15:39:15 +00:00
default = {};
2022-02-21 10:48:18 +00:00
type = types.attrsOf types.str;
};
};
}))
]);
2022-02-20 17:19:39 +00:00
};
prefixes = mkOption {
2022-06-12 15:39:15 +00:00
default = [];
2022-02-20 17:19:39 +00:00
type = types.listOf (types.attrsOf types.anything);
};
2022-02-20 17:52:23 +00:00
meta = mkOption {
2022-06-12 15:39:15 +00:00
default = {};
2022-02-20 17:52:23 +00:00
type = types.attrsOf types.anything;
};
2022-02-20 17:19:39 +00:00
};
});
description = "Group configuration";
};
2022-02-20 17:52:23 +00:00
users = mkOption {
2022-06-12 15:39:15 +00:00
default = {};
2022-02-20 17:52:23 +00:00
type = types.attrsOf (types.submodule {
options = {
uuid = mkOption {
type = types.str;
};
name = mkOption {
type = types.str;
};
primary-group = mkOption {
type = types.str;
default = "default";
};
parents = mkOption {
2022-06-12 15:39:15 +00:00
default = ["default"];
2022-02-20 17:52:23 +00:00
type = types.listOf types.str;
};
permissions = mkOption {
2022-06-12 15:39:15 +00:00
default = [];
2022-02-20 17:52:23 +00:00
type = types.listOf types.str;
};
prefixes = mkOption {
2022-06-12 15:39:15 +00:00
default = [];
2022-02-20 17:52:23 +00:00
type = types.listOf (types.attrsOf types.anything);
};
meta = mkOption {
2022-06-12 15:39:15 +00:00
default = {};
2022-02-20 17:52:23 +00:00
type = types.attrsOf types.anything;
};
};
});
};
2022-02-20 15:30:04 +00:00
};
config = mkIf cfg.enable {
2022-06-12 15:39:15 +00:00
services.minecraft.plugins = [
{
package = luckperms;
2022-06-12 15:42:42 +00:00
inherit startScript;
2022-06-12 15:39:15 +00:00
}
];
2022-02-20 15:30:04 +00:00
};
}