diff options
author | Aaron Andersen <aaron@fosslib.net> | 2020-08-11 21:12:59 -0400 |
---|---|---|
committer | Aaron Andersen <aaron@fosslib.net> | 2020-08-12 07:10:56 -0400 |
commit | 3792fef4ec8ec089ae244a35172e540d34a9b06c (patch) | |
tree | c13ddc221396bee2ab4197faea40c2aeaa3c8c4e /nixos | |
parent | 9b56677634938860eedd06f9415432add0491ad7 (diff) |
nixos/mysql: add group option
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/modules/services/databases/mysql.nix | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/nixos/modules/services/databases/mysql.nix b/nixos/modules/services/databases/mysql.nix index 63e769e0b0bc..021a9bbe6eb5 100644 --- a/nixos/modules/services/databases/mysql.nix +++ b/nixos/modules/services/databases/mysql.nix @@ -59,6 +59,12 @@ in description = "User account under which MySQL runs"; }; + group = mkOption { + type = types.str; + default = "mysql"; + description = "Group under which MySQL runs."; + }; + dataDir = mkOption { type = types.path; example = "/var/lib/mysql"; @@ -319,21 +325,25 @@ in }) ]; - users.users.mysql = { - description = "MySQL server user"; - group = "mysql"; - uid = config.ids.uids.mysql; + users.users = optionalAttrs (cfg.user == "mysql") { + mysql = { + description = "MySQL server user"; + group = cfg.group; + uid = config.ids.uids.mysql; + }; }; - users.groups.mysql.gid = config.ids.gids.mysql; + users.groups = optionalAttrs (cfg.group == "mysql") { + mysql.gid = config.ids.gids.mysql; + }; environment.systemPackages = [ cfg.package ]; environment.etc."my.cnf".source = cfg.configFile; systemd.tmpfiles.rules = [ - "d '${cfg.dataDir}' 0700 ${cfg.user} mysql - -" - "z '${cfg.dataDir}' 0700 ${cfg.user} mysql - -" + "d '${cfg.dataDir}' 0700 '${cfg.user}' '${cfg.group}' - -" + "z '${cfg.dataDir}' 0700 '${cfg.user}' '${cfg.group}' - -" ]; systemd.services.mysql = let @@ -473,7 +483,7 @@ in "+${setupScript}"; # User and group User = cfg.user; - Group = "mysql"; + Group = cfg.group; # Runtime directory and mode RuntimeDirectory = "mysqld"; RuntimeDirectoryMode = "0755"; |