Instance config should go in ./config
This commit is contained in:
parent
70ba6a4474
commit
82f929eb0d
|
@ -1,12 +1,11 @@
|
||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
with lib;
|
|
||||||
let
|
let
|
||||||
user = import ./types/user.nix { inherit lib; };
|
user = import ./types/user.nix { inherit lib; };
|
||||||
host = import ./types/host.nix { inherit lib; };
|
host = import ./types/host.nix { inherit lib; };
|
||||||
|
|
||||||
in {
|
in {
|
||||||
options.instance = with types; {
|
options.instance = with lib.types; {
|
||||||
hostname = mkOption {
|
hostname = mkOption {
|
||||||
type = str;
|
type = str;
|
||||||
description = "Hostname of this specific host (without domain).";
|
description = "Hostname of this specific host (without domain).";
|
||||||
|
@ -67,56 +66,4 @@ in {
|
||||||
description = "Seed used to generate configuration.";
|
description = "Seed used to generate configuration.";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = let
|
|
||||||
local-host = config.instance.hostname;
|
|
||||||
local-domain = config.fudo.hosts.${local-host}.domain;
|
|
||||||
local-site = config.fudo.hosts.${local-host}.site;
|
|
||||||
|
|
||||||
host = config.fudo.hosts.${local-host};
|
|
||||||
|
|
||||||
host-user-list = host.local-users;
|
|
||||||
domain-user-list = config.fudo.domains."${local-domain}".local-users;
|
|
||||||
site-user-list = config.fudo.sites."${local-site}".local-users;
|
|
||||||
local-users =
|
|
||||||
getAttrs (host-user-list ++ domain-user-list ++ site-user-list) config.fudo.users;
|
|
||||||
|
|
||||||
host-admin-list = host.local-admins;
|
|
||||||
domain-admin-list = config.fudo.domains."${local-domain}".local-admins;
|
|
||||||
site-admin-list = config.fudo.sites."${local-site}".local-admins;
|
|
||||||
local-admins = host-admin-list ++ domain-admin-list ++ site-admin-list;
|
|
||||||
|
|
||||||
host-group-list = host.local-groups;
|
|
||||||
domain-group-list = config.fudo.domains."${local-domain}".local-groups;
|
|
||||||
site-group-list = config.fudo.sites."${local-site}".local-groups;
|
|
||||||
local-groups =
|
|
||||||
getAttrs (host-group-list ++ domain-group-list ++ site-group-list)
|
|
||||||
config.fudo.groups;
|
|
||||||
|
|
||||||
local-hosts =
|
|
||||||
filterAttrs (host: hostOpts: hostOpts.site == local-site) config.fudo.hosts;
|
|
||||||
|
|
||||||
local-networks =
|
|
||||||
host.local-networks ++
|
|
||||||
config.fudo.domains.${local-domain}.local-networks ++
|
|
||||||
config.fudo.sites.${local-site}.local-networks;
|
|
||||||
|
|
||||||
local-profile = host.profile;
|
|
||||||
|
|
||||||
host-fqdn = "${config.instance.hostname}.${local-domain}";
|
|
||||||
|
|
||||||
in {
|
|
||||||
instance = {
|
|
||||||
inherit
|
|
||||||
host-fqdn
|
|
||||||
local-domain
|
|
||||||
local-site
|
|
||||||
local-users
|
|
||||||
local-admins
|
|
||||||
local-groups
|
|
||||||
local-hosts
|
|
||||||
local-profile
|
|
||||||
local-networks;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue