clean configurations
[myNix.git] / lbhost / conf.mysql.nix
blobc11d356b79d7d08d22fc30a481807d0660cf526d
1 { config
2 , pkgs
3 , lib
4 , ...
5 }:
7 let
8   inherit (builtins)
9     trace
10     map
11     attrNames
12     ;
13   inherit (lib)
14     filterAttrs
15     ;
16   inherit (config.lib.mylib)
17     maybe
18     binding
19     ;
20   hostname = config.networking.hostName;
21   normal-users = binding
22     attrNames
23     (filterAttrs
24       (name: conf:
25         name != "root" &&
26         (conf.name or "") != "root" &&
27         (conf.isNormalUser or (! (conf.isSystemUser or false)))
28       ))
29     (
30       (config.users.users or { }) //
31       (config.users.extraUsers or { })
32     );
33   maybe' = maybe (
34     hostname == "none"
35   );
38   services.mysql = maybe' {
39     enable = trace "MySQL server Enabled" true;
40     package = pkgs.mariadb;
41     settings = {
42       mysqld.bind-address = "localhost";
43     };
44     ensureUsers = map
45       (user-name:
46         {
47           name = user-name;
48           ensurePermissions = { "*.*" = "ALL PRIVILEGES"; };
49         }
50       )
51       normal-users;
52   };