feat(rtl): service

This commit is contained in:
arcnmx 2025-01-27 15:23:27 -08:00
parent 6931de7d18
commit b4dbcc71f0
7 changed files with 156 additions and 6 deletions

View file

@ -4,17 +4,25 @@
pkgs,
...
}: let
inherit (lib.modules) mkIf mkDefault;
inherit (lib.options) mkOption;
inherit (lib.modules) mkIf mkDefault mkOptionDefault;
cfg = config.services.openwebrx;
user = "openwebrx";
in {
services.openwebrx = {
options.services.openwebrx = with lib.types; {
hardwareDev = mkOption {
type = nullOr int;
};
};
config.services.openwebrx = {
enable = mkDefault true;
package = mkDefault pkgs.openwebrxplus;
user = mkDefault user;
hardwareDev = mkIf config.hardware.rtl-sdr.enable (mkOptionDefault 0);
};
users = mkIf cfg.enable {
config.users = mkIf cfg.enable {
users.${user} = {
uid = 912;
isSystemUser = true;
@ -29,7 +37,7 @@ in {
};
};
sops.secrets = let
config.sops.secrets = let
sopsFile = mkDefault ./secrets/openwebrx.yaml;
in
mkIf cfg.enable {
@ -41,7 +49,7 @@ in {
};
};
networking.firewall = mkIf cfg.enable {
config.networking.firewall = mkIf cfg.enable {
interfaces.lan.allowedTCPPorts = mkIf cfg.enable [
cfg.port
];

18
nixos/rtl_tcp.nix Normal file
View file

@ -0,0 +1,18 @@
{
config,
gensokyo-zone,
lib,
...
}: let
inherit (lib.modules) mkIf;
inherit (gensokyo-zone.lib) mkAlmostOptionDefault;
cfg = config.services.rtl_tcp;
in {
services.rtl_tcp = {
enable = mkAlmostOptionDefault true;
};
hardware.rtl-sdr.enable = mkAlmostOptionDefault true;
networking.firewall.interfaces.lan = mkIf (cfg.enable && !cfg.openFirewall) {
allowedTCPPorts = [cfg.port];
};
}