fruitbasket/modules/hydra.nix

68 lines
2 KiB
Nix
Raw Normal View History

2023-08-23 16:53:43 +02:00
{ config, ... }:
let
domain = "hydra.${config.networking.domain}";
2023-08-23 16:53:43 +02:00
in
{
2023-08-23 17:12:08 +02:00
sops.secrets."hydra_ldap_search" = { owner = "hydra"; group = "hydra"; mode = "440"; };
nix.settings.allowed-uris = [ "https://github.com/nix-community" ]; # whitelisted to fetch nix-index
2023-08-23 16:53:43 +02:00
services.hydra = {
enable = true;
port = 4000;
hydraURL = domain;
notificationSender = "hydra@localhost";
buildMachinesFiles = [ ];
useSubstitutes = true;
extraConfig = ''
2023-08-23 17:12:08 +02:00
<ldap>
2023-08-23 16:53:43 +02:00
<config>
<credential>
class = Password
password_field = password
password_type = self_check
</credential>
<store>
class = LDAP
ldap_server = localhost
<ldap_server_options>
timeout = 30
</ldap_server_options>
2023-08-23 17:12:08 +02:00
binddn = "uid=search,ou=users,dc=ifsr,dc=de"
2023-08-23 16:53:43 +02:00
include ${config.sops.secrets.hydra_ldap_search.path}
start_tls = 0
<start_tls_options>
verify = none
</start_tls_options>
user_basedn = "ou=users,dc=ifsr,dc=de"
2023-08-23 17:12:08 +02:00
user_filter = "(&(objectClass=posixAccount)(uid=%s))"
2023-08-23 16:53:43 +02:00
user_scope = one
2023-08-23 17:12:08 +02:00
user_field = uid
2023-08-23 16:53:43 +02:00
<user_search_options>
deref = always
</user_search_options>
# Important for role mappings to work:
use_roles = 1
role_basedn = "ou=groups,dc=ifsr,dc=de"
role_filter = "(&(objectClass=groupOfNames)(member=%s))"
role_scope = one
role_field = cn
role_value = dn
<role_search_options>
deref = always
</role_search_options>
2023-08-23 17:12:08 +02:00
</store>
2023-08-23 16:53:43 +02:00
</config>
<role_mapping>
# Make all users in the hydra_admin group Hydra admins
admins = admin
</role_mapping>
</ldap>
'';
};
services.nginx.virtualHosts."${domain}" = {
locations."/" = {
proxyPass = "http://127.0.0.1:${toString config.services.hydra.port}";
};
};
}