feat: simplified the config for running services, only one hosts config is required now in each server config file
This commit is contained in:
parent
f8c7860eb5
commit
379cb84839
34 changed files with 200 additions and 581 deletions
59
applications/_base.nix
Normal file
59
applications/_base.nix
Normal file
|
@ -0,0 +1,59 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
# root service
|
||||
cfg = config.services.skynet;
|
||||
in {
|
||||
imports = [
|
||||
./acme.nix
|
||||
./dns.nix
|
||||
./nginx.nix
|
||||
];
|
||||
|
||||
options.services.skynet = {
|
||||
# since we use this basically everywhere provide a standard way to set it
|
||||
host = {
|
||||
ip = mkOption {
|
||||
type = types.str;
|
||||
};
|
||||
name = mkOption {
|
||||
type = types.str;
|
||||
};
|
||||
hostname = mkOption {
|
||||
type = types.str;
|
||||
default = "${cfg.host.name}.skynet.ie";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
services.skynet.dns.records = [
|
||||
{
|
||||
record = cfg.host.name;
|
||||
r_type = "A";
|
||||
value = cfg.host.ip;
|
||||
server = true;
|
||||
}
|
||||
{
|
||||
record = cfg.host.ip;
|
||||
r_type = "PTR";
|
||||
value = cfg.host.hostname;
|
||||
}
|
||||
];
|
||||
|
||||
services.nginx = {
|
||||
virtualHosts = {
|
||||
# for every server unless explisitly defined redirect the ip to skynet.ie
|
||||
"${cfg.host.ip}" = {
|
||||
forceSSL = true;
|
||||
useACMEHost = "skynet";
|
||||
locations."/".return = "307 https://skynet.ie";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue