fixed it
This commit is contained in:
parent
5b4cc25a87
commit
d79b9ea141
2 changed files with 187 additions and 181 deletions
|
|
@ -163,7 +163,7 @@
|
||||||
|
|
||||||
modules = {
|
modules = {
|
||||||
games.steam.enable = false;
|
games.steam.enable = false;
|
||||||
modules.websites = {
|
websites = {
|
||||||
enable = true;
|
enable = true;
|
||||||
certMail = "acme@voorwaarts.nl";
|
certMail = "acme@voorwaarts.nl";
|
||||||
mainDomains = {
|
mainDomains = {
|
||||||
|
|
@ -187,6 +187,7 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
users.defaultUserShell = pkgs.zsh;
|
users.defaultUserShell = pkgs.zsh;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,10 @@ let
|
||||||
cfg = config.modules.websites;
|
cfg = config.modules.websites;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.modules.nginx =
|
options.modules.websites =
|
||||||
{
|
{
|
||||||
enable = lib.mkEnableOption "enable web hosting";
|
enable = lib.mkEnableOption "enable web hosting";
|
||||||
cert_mail = lib.mkOption {
|
certMail = lib.mkOption {
|
||||||
type = lib.types.str;
|
type = lib.types.str;
|
||||||
description = "the email address the certificate will be requested to";
|
description = "the email address the certificate will be requested to";
|
||||||
};
|
};
|
||||||
|
|
@ -15,17 +15,20 @@ in
|
||||||
type = with lib.types; attrsOf (submodule {
|
type = with lib.types; attrsOf (submodule {
|
||||||
options =
|
options =
|
||||||
let
|
let
|
||||||
proxyOption = lib.mkOption { type = int; description = "what url to proxy the requests to"; };
|
proxyOption = lib.mkOption { type = str; description = "what url to proxy the requests to"; };
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
enable = lib.mkEnableOption "enable this website";
|
enable = lib.mkEnableOption "enable this website";
|
||||||
extra_sites = attrsOf
|
extra_sites = lib.mkOption {
|
||||||
|
description = "extra sites that use this certificate";
|
||||||
|
type = attrsOf
|
||||||
(submodule {
|
(submodule {
|
||||||
options = {
|
options = {
|
||||||
enable = lib.mkEnableOption "enable this website";
|
enable = lib.mkEnableOption "enable this website";
|
||||||
proxy = proxyOption;
|
proxy = proxyOption;
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
};
|
||||||
proxy = proxyOption;
|
proxy = proxyOption;
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
@ -37,21 +40,19 @@ in
|
||||||
lib.attrsets.mapAttrsToList
|
lib.attrsets.mapAttrsToList
|
||||||
(
|
(
|
||||||
name: config:
|
name: config:
|
||||||
lib.mkIf config.enable (
|
|
||||||
[ name ] ++ lib.attrsets.mapAttrsToList (n: c: lib.mkIf c.enable n) config.extra_sites
|
[ name ] ++ lib.attrsets.mapAttrsToList (n: c: lib.mkIf c.enable n) config.extra_sites
|
||||||
)
|
)
|
||||||
)
|
|
||||||
cfg.mainDomains
|
cfg.mainDomains
|
||||||
);
|
);
|
||||||
certs = lib.attrsets.MapAttrs
|
certs = lib.attrsets.mapAttrs
|
||||||
(
|
(
|
||||||
name: config:
|
name: config:
|
||||||
lib.mkIf config.enable {
|
lib.mkIf config.enable {
|
||||||
extraDomainNames = lib.attrsets.MapAttrsToList (n: c: lib.mkIf c.enable n) config.extra_sites;
|
extraDomainNames = lib.attrsets.mapAttrsToList (n: c: lib.mkIf c.enable n) config.extra_sites;
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
cfg.mainDomains;
|
cfg.mainDomains;
|
||||||
hosts = lib.attrsets.MapAtrrs
|
hosts = lib.attrsets.concatMapAttrs
|
||||||
(
|
(
|
||||||
name: config:
|
name: config:
|
||||||
let
|
let
|
||||||
|
|
@ -81,19 +82,23 @@ in
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
lib.mkIf config.enable (
|
lib.mkIf config.enable (
|
||||||
lib.mkMerge (
|
lib.mkMerge [
|
||||||
{
|
{
|
||||||
|
${name} = {
|
||||||
forceSSL = true;
|
forceSSL = true;
|
||||||
enableACME = true;
|
enableACME = true;
|
||||||
extraConfig = extra;
|
extraConfig = extra;
|
||||||
locations."/" = {
|
locations."/" = {
|
||||||
proxyPass = config.proxy;
|
proxyPass = config.proxy;
|
||||||
};
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
++ (lib.attrsets.MapAttrsToList
|
(lib.attrsets.mapAttrs
|
||||||
(n: c: lib.mkIf c.enable (proxy c.proxy))
|
(n: c:
|
||||||
config.extra_sites)
|
proxy c.proxy
|
||||||
)
|
)
|
||||||
|
config.extra_sites)
|
||||||
|
]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
cfg.mainDomains;
|
cfg.mainDomains;
|
||||||
|
|
@ -105,7 +110,7 @@ in
|
||||||
};
|
};
|
||||||
security.acme = {
|
security.acme = {
|
||||||
acceptTerms = true;
|
acceptTerms = true;
|
||||||
defaults.email = cfg.cert_mail;
|
defaults.email = cfg.certMail;
|
||||||
certs = certs;
|
certs = certs;
|
||||||
};
|
};
|
||||||
services.nginx = {
|
services.nginx = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue