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;
in {
options = with lib.types; {
enable = mkEnableOption "camera" // {
enable =
mkEnableOption "camera"
// {
default = true;
};
settings = mkOption {
@ -45,14 +47,15 @@ let
);
};
};
in {
in
{
pkgs,
config,
gensokyo-zone,
utils,
lib,
...
}: let
}: let
inherit (lib.options) mkOption mkPackageOption mkEnableOption;
inherit (lib.modules) mkIf mkMerge mkAfter mkOptionDefault;
inherit (lib.attrsets) attrValues mapAttrsToList;
@ -60,13 +63,13 @@ in {
inherit (lib.meta) getExe;
cfg = config.services.motion;
lib'motion = config.lib.motion;
in {
in {
options.services.motion = with lib.types; {
enable = mkEnableOption "motion";
package = mkPackageOption pkgs "motion" {};
cameras = mkOption {
type = attrsOf (submoduleWith {
modules = [ cameraModule ];
modules = [cameraModule];
specialArgs = {
inherit pkgs gensokyo-zone lib'motion;
nixosConfig = config;
@ -166,4 +169,4 @@ in {
mkMotionSetting = key: value: "${key} ${lib'motion.mkMotionValue value}";
mkMotionSettings = mapAttrsToList lib'motion.mkMotionSetting;
};
}
}

View file

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

View file

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

View file

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