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