22
0
mirror of https://github.com/SuperSandro2000/nixos-modules.git synced 2024-06-11 10:44:10 +02:00
nixos-modules/modules/portunus.nix

54 lines
1.5 KiB
Nix
Raw Normal View History

{ config, lib, ... }:
let
cfg = config.services.portunus;
in
{
options.services.portunus = {
2023-01-17 00:23:31 +01:00
addToHosts = lib.mkOption {
type = lib.types.bool;
default = false;
2023-01-17 02:14:18 +01:00
description = lib.mdDoc "Whether to add a hosts entry for the portunus domain pointing to externalIp";
2023-01-17 00:23:31 +01:00
};
2023-02-23 00:34:37 +01:00
internalIp4 = lib.mkOption {
type = with lib.types; nullOr str;
default = null;
description = lib.mdDoc "Internal IPv4 of portunus instance. This is used in the addToHosts option.";
};
2023-02-23 00:34:37 +01:00
internalIp6 = lib.mkOption {
type = with lib.types; nullOr str;
default = null;
description = lib.mdDoc "Internal IPv6 of portunus instance. This is used in the addToHosts option.";
};
2023-01-17 00:23:31 +01:00
ldapPreset = lib.mkOption {
type = lib.types.bool;
2023-01-17 00:56:46 +01:00
default = false;
2023-01-17 02:14:18 +01:00
description = lib.mdDoc "Whether to set config.security.ldap to portunus specific settings.";
};
};
2023-01-17 00:23:31 +01:00
config = {
networking.hosts = lib.mkIf cfg.addToHosts {
2023-02-23 00:34:37 +01:00
${cfg.internalIp4} = [ cfg.domain ];
${cfg.internalIp6} = [ cfg.domain ];
2023-01-17 00:23:31 +01:00
};
security.ldap = lib.mkIf cfg.ldapPreset {
roleBaseDN = "ou=groups";
roleField = "cn";
roleFilter = "(&(objectclass=groupOfNames)(member=%s))";
roleValue = "dn";
searchUID = "search";
server = cfg.domain;
userField = "uid";
# TODO: add enum setting for login with username, email or both
# userFilter = "(&(objectclass=person)(|(uid=%s)(mail=%s)))";
userFilter = "(&(objectclass=person)(uid=%s))";
userBaseDN = "ou=users";
};
};
}