mirror of
https://github.com/gensokyo-zone/infrastructure.git
synced 2026-02-09 12:29:19 -08:00
chore: nf-fmt-nix
This commit is contained in:
parent
37137017c2
commit
c8bc78fb88
4 changed files with 152 additions and 140 deletions
|
|
@ -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,14 +47,15 @@ let
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
in {
|
in
|
||||||
|
{
|
||||||
pkgs,
|
pkgs,
|
||||||
config,
|
config,
|
||||||
gensokyo-zone,
|
gensokyo-zone,
|
||||||
utils,
|
utils,
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (lib.options) mkOption mkPackageOption mkEnableOption;
|
inherit (lib.options) mkOption mkPackageOption mkEnableOption;
|
||||||
inherit (lib.modules) mkIf mkMerge mkAfter mkOptionDefault;
|
inherit (lib.modules) mkIf mkMerge mkAfter mkOptionDefault;
|
||||||
inherit (lib.attrsets) attrValues mapAttrsToList;
|
inherit (lib.attrsets) attrValues mapAttrsToList;
|
||||||
|
|
@ -60,13 +63,13 @@ in {
|
||||||
inherit (lib.meta) getExe;
|
inherit (lib.meta) getExe;
|
||||||
cfg = config.services.motion;
|
cfg = config.services.motion;
|
||||||
lib'motion = config.lib.motion;
|
lib'motion = config.lib.motion;
|
||||||
in {
|
in {
|
||||||
options.services.motion = with lib.types; {
|
options.services.motion = with lib.types; {
|
||||||
enable = mkEnableOption "motion";
|
enable = mkEnableOption "motion";
|
||||||
package = mkPackageOption pkgs "motion" {};
|
package = mkPackageOption pkgs "motion" {};
|
||||||
cameras = mkOption {
|
cameras = mkOption {
|
||||||
type = attrsOf (submoduleWith {
|
type = attrsOf (submoduleWith {
|
||||||
modules = [ cameraModule ];
|
modules = [cameraModule];
|
||||||
specialArgs = {
|
specialArgs = {
|
||||||
inherit pkgs gensokyo-zone lib'motion;
|
inherit pkgs gensokyo-zone lib'motion;
|
||||||
nixosConfig = config;
|
nixosConfig = config;
|
||||||
|
|
@ -166,4 +169,4 @@ in {
|
||||||
mkMotionSetting = key: value: "${key} ${lib'motion.mkMotionValue value}";
|
mkMotionSetting = key: value: "${key} ${lib'motion.mkMotionValue value}";
|
||||||
mkMotionSettings = mapAttrsToList lib'motion.mkMotionSetting;
|
mkMotionSettings = mapAttrsToList lib'motion.mkMotionSetting;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -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";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue