{ lib, pkgs, config, myconfig, mylibs, ... }: let cfg = config.services.myDatabases; in { options.services.myDatabases = { redis = { enable = lib.mkOption { default = cfg.enable; example = true; description = "Whether to enable redis database"; type = lib.types.bool; }; }; }; config = lib.mkIf cfg.enable { ids.uids.redis = myconfig.env.users.redis.uid; ids.gids.redis = myconfig.env.users.redis.gid; users.users.redis.uid = config.ids.uids.redis; users.groups.redis.gid = config.ids.gids.redis; services.redis = rec { enable = config.services.myDatabases.redis.enable; bind = "127.0.0.1"; unixSocket = myconfig.env.databases.redis.socket; extraConfig = '' unixsocketperm 777 maxclients 1024 ''; }; system.activationScripts.redis = '' mkdir -p $(dirname ${myconfig.env.databases.redis.socket}) chown redis $(dirname ${myconfig.env.databases.redis.socket}) ''; }; }