2023-09-17 19:51:08 +00:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
lib,
|
|
|
|
inputs,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
with lib; let
|
2024-05-30 13:59:20 +00:00
|
|
|
name = "ldap_backend";
|
|
|
|
cfg = config.services.skynet."${name}";
|
2023-09-17 19:51:08 +00:00
|
|
|
port_backend = "8087";
|
|
|
|
in {
|
2023-06-18 21:49:31 +00:00
|
|
|
imports = [
|
2023-07-21 20:56:19 +00:00
|
|
|
inputs.skynet_ldap_backend.nixosModule."x86_64-linux"
|
2023-10-09 16:40:40 +00:00
|
|
|
../../config/users.nix
|
2023-06-18 21:49:31 +00:00
|
|
|
];
|
|
|
|
|
2024-05-30 13:59:20 +00:00
|
|
|
options.services.skynet."${name}" = {
|
2023-06-18 21:49:31 +00:00
|
|
|
enable = mkEnableOption "Skynet LDAP backend server";
|
|
|
|
|
|
|
|
domain = {
|
|
|
|
tld = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "ie";
|
|
|
|
};
|
|
|
|
|
|
|
|
base = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "skynet";
|
|
|
|
};
|
|
|
|
|
|
|
|
sub = mkOption {
|
|
|
|
type = types.str;
|
2023-08-06 18:00:02 +00:00
|
|
|
default = "api.account";
|
2023-06-18 21:49:31 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
#backups = [ "/etc/silver_ul_ical/database.db" ];
|
|
|
|
|
2023-09-12 11:05:38 +00:00
|
|
|
age.secrets.ldap_details.file = ../../secrets/ldap/details.age;
|
|
|
|
age.secrets.ldap_mail.file = ../../secrets/email/details.age;
|
2023-10-27 01:49:59 +00:00
|
|
|
age.secrets.ldap_wolves.file = ../../secrets/wolves/details.age;
|
2023-06-18 21:49:31 +00:00
|
|
|
|
2024-05-30 12:34:59 +00:00
|
|
|
services.skynet.acme.domains = [
|
2023-08-06 19:09:15 +00:00
|
|
|
"${cfg.domain.sub}.${cfg.domain.base}.${cfg.domain.tld}"
|
|
|
|
];
|
|
|
|
|
2024-05-30 12:25:52 +00:00
|
|
|
services.skynet.dns.records = [
|
2023-09-17 19:51:08 +00:00
|
|
|
{
|
|
|
|
record = cfg.domain.sub;
|
|
|
|
r_type = "CNAME";
|
2024-05-30 16:55:29 +00:00
|
|
|
value = config.services.skynet.host.name;
|
2023-09-17 19:51:08 +00:00
|
|
|
}
|
2023-06-18 21:49:31 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
services.nginx.virtualHosts."${cfg.domain.sub}.${cfg.domain.base}.${cfg.domain.tld}" = {
|
|
|
|
forceSSL = true;
|
|
|
|
useACMEHost = "skynet";
|
|
|
|
locations."/".proxyPass = "http://localhost:${port_backend}";
|
|
|
|
};
|
|
|
|
|
2024-05-30 13:59:20 +00:00
|
|
|
# this got imported
|
2023-06-18 21:49:31 +00:00
|
|
|
services.skynet_ldap_backend = {
|
|
|
|
enable = true;
|
|
|
|
|
|
|
|
# contains teh password in env form
|
2023-08-27 21:31:08 +00:00
|
|
|
env = {
|
2023-09-12 11:05:38 +00:00
|
|
|
ldap = config.age.secrets.ldap_details.path;
|
|
|
|
mail = config.age.secrets.ldap_mail.path;
|
2023-10-27 01:49:59 +00:00
|
|
|
wolves = config.age.secrets.ldap_wolves.path;
|
2023-06-18 21:49:31 +00:00
|
|
|
};
|
|
|
|
|
2023-09-16 14:52:23 +00:00
|
|
|
host_port = "127.0.0.1:${port_backend}";
|
2023-10-09 17:04:01 +00:00
|
|
|
users = config.skynet.users;
|
2023-06-18 21:49:31 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|