chore: nf-fmt-nix

This commit is contained in:
arcnmx 2024-06-16 10:41:37 -07:00
parent 37137017c2
commit c8bc78fb88
4 changed files with 152 additions and 140 deletions

View file

@ -13,7 +13,9 @@ let
inherit (lib.strings) hasPrefix; inherit (lib.strings) hasPrefix;
in { in {
options = with lib.types; { options = with lib.types; {
enable = mkEnableOption "camera" // { enable =
mkEnableOption "camera"
// {
default = true; default = true;
}; };
settings = mkOption { settings = mkOption {
@ -45,7 +47,8 @@ let
); );
}; };
}; };
in { in
{
pkgs, pkgs,
config, config,
gensokyo-zone, gensokyo-zone,

View file

@ -47,7 +47,8 @@ in {
protocol = "http"; protocol = "http";
prometheus.exporter.enable = let prometheus.exporter.enable = let
sslPort = config.ports.asterisk-ssl; sslPort = config.ports.asterisk-ssl;
in mkAlmostOptionDefault (!sslPort.enable || !sslPort.prometheus.exporter.enable); in
mkAlmostOptionDefault (!sslPort.enable || !sslPort.prometheus.exporter.enable);
}; };
asterisk-ssl = { asterisk-ssl = {
port = mkAlmostOptionDefault 8089; port = mkAlmostOptionDefault 8089;

View file

@ -155,10 +155,14 @@ let
default = "/metrics"; default = "/metrics";
}; };
ssl = { ssl = {
enable = mkEnableOption "HTTPS" // { enable =
mkEnableOption "HTTPS"
// {
default = any (port: port.ssl) (attrValues exporterPorts); default = any (port: port.ssl) (attrValues exporterPorts);
}; };
insecure = mkEnableOption "self-signed SSL" // { insecure =
mkEnableOption "self-signed SSL"
// {
default = true; default = true;
}; };
}; };

View file

@ -12,8 +12,12 @@ in {
serviceAttr = "motion"; serviceAttr = "motion";
assertions = let assertions = let
# in motion.conf, `0` represents the port being disabled # in motion.conf, `0` represents the port being disabled
configPort = port: if port.enable then port.port else 0; configPort = port:
in mkIf config.enable [ if port.enable
then port.port
else 0;
in
mkIf config.enable [
(nixosConfig: { (nixosConfig: {
assertion = configPort config.ports.default == nixosConfig.services.motion.settings.webcontrol_port or 0; assertion = configPort config.ports.default == nixosConfig.services.motion.settings.webcontrol_port or 0;
message = "webcontrol port mismatch"; message = "webcontrol port mismatch";