mirror of
https://github.com/gensokyo-zone/infrastructure.git
synced 2026-02-09 12:29:19 -08:00
fix(access): deluge
This commit is contained in:
parent
5a5844cc08
commit
edf2d60410
10 changed files with 217 additions and 18 deletions
|
|
@ -142,6 +142,17 @@
|
|||
};
|
||||
};
|
||||
|
||||
config.local = {
|
||||
enable = mkOptionDefault false;
|
||||
denyGlobal = mkOptionDefault cfg.enable;
|
||||
trusted = mkOptionDefault cfg.denyGlobal;
|
||||
};
|
||||
};
|
||||
serverModule = {config, ...}: let
|
||||
cfg = config.local;
|
||||
in {
|
||||
imports = [localModule];
|
||||
|
||||
config.local = {
|
||||
enable = mkOptionDefault false;
|
||||
denyGlobal = mkOptionDefault cfg.enable;
|
||||
|
|
@ -149,9 +160,15 @@
|
|||
};
|
||||
};
|
||||
in {
|
||||
options = with lib.types; {
|
||||
services.nginx.virtualHosts = mkOption {
|
||||
options.services.nginx = with lib.types; {
|
||||
virtualHosts = mkOption {
|
||||
type = attrsOf (submodule [hostModule]);
|
||||
};
|
||||
stream.servers = mkOption {
|
||||
type = attrsOf (submoduleWith {
|
||||
modules = [serverModule];
|
||||
shorthandOnlyDefinesConfig = false;
|
||||
});
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,6 +40,10 @@ let
|
|||
type = str;
|
||||
default = "default";
|
||||
};
|
||||
getAddressFor = mkOption {
|
||||
type = str;
|
||||
default = "getAddressFor";
|
||||
};
|
||||
network = mkOption {
|
||||
type = str;
|
||||
default = "lan";
|
||||
|
|
@ -61,7 +65,7 @@ let
|
|||
enable = lib.warnIf (!port.enable) "${cfg.system}.exports.services.${cfg.name}.ports.${cfg.port} isn't enabled" (
|
||||
mkAlmostOptionDefault port.enable
|
||||
);
|
||||
addr = mkAlmostOptionDefault (access.getAddressFor system.name cfg.network);
|
||||
addr = mkAlmostOptionDefault (access.${cfg.getAddressFor} system.name cfg.network);
|
||||
port = mkOptionDefault port.port;
|
||||
ssl.enable = mkIf port.ssl (mkAlmostOptionDefault true);
|
||||
};
|
||||
|
|
|
|||
46
modules/system/exports/deluge.nix
Normal file
46
modules/system/exports/deluge.nix
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
{
|
||||
lib,
|
||||
gensokyo-zone,
|
||||
...
|
||||
}: let
|
||||
inherit (gensokyo-zone.lib) mapAlmostOptionDefaults mkAlmostOptionDefault;
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.attrsets) mapAttrs;
|
||||
in {
|
||||
config.exports.services.deluge = {config, ...}: {
|
||||
nixos = {
|
||||
serviceAttr = "deluge";
|
||||
assertions = let
|
||||
mkAssertion = f: nixosConfig: let
|
||||
cfg = nixosConfig.services.deluge;
|
||||
in
|
||||
f nixosConfig cfg;
|
||||
in
|
||||
mkIf config.enable [
|
||||
(mkAssertion (nixosConfig: cfg: {
|
||||
assertion = config.ports.default.port == cfg.config.daemon_port;
|
||||
message = "config.daemon_port mismatch";
|
||||
}))
|
||||
(mkAssertion (nixosConfig: cfg: {
|
||||
assertion = config.ports.web.port == cfg.web.port;
|
||||
message = "web.port mismatch";
|
||||
}))
|
||||
(mkAssertion (nixosConfig: cfg: {
|
||||
assertion = config.ports.web.enable == cfg.web.enable;
|
||||
message = "web.enable mismatch";
|
||||
}))
|
||||
];
|
||||
};
|
||||
defaults.port.listen = mkAlmostOptionDefault "lan";
|
||||
ports = mapAttrs (_: mapAlmostOptionDefaults) {
|
||||
default = {
|
||||
port = 58846;
|
||||
transport = "tcp";
|
||||
};
|
||||
web = {
|
||||
port = 8112;
|
||||
protocol = "http";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue