depot/lib/identity.nix

38 lines
1 KiB
Nix
Raw Normal View History

2023-08-31 01:55:45 +03:00
{ lib, ... }:
{
lib = { config, ... }: with config.identity; {
identity = {
inherit (config.meta) domain;
autoDomain = name: "${builtins.hashString "md5" name}.dev.${domain}";
ldap = {
server = with ldap.server; {
# TODO: unhardcode everything here
protocol = "ldaps";
hostname = "authsys.virtual-machines.${domain}";
port = 636;
url = "${protocol}://${connectionString}";
connectionString = "${hostname}:${builtins.toString port}";
};
accounts = with ldap.accounts; {
domainComponents = ldap.lib.convertDomain domain;
uidAttribute = "uid";
uidFilter = "(${uidAttribute}=%u)";
userSearchBase = "cn=users,cn=accounts,${domainComponents}";
};
lib = {
convertDomain = domain: with builtins; lib.pipe domain [
(split "\\.")
(filter isString)
(map (x: "dc=${x}"))
(concatStringsSep ",")
];
};
};
};
};
}