From 2715bf7bf5c8a59b6e3c7a315d5ec95952f4467c Mon Sep 17 00:00:00 2001 From: "Gustavo \"Guz\" L. de Mello" Date: Sat, 27 Jan 2024 12:03:36 -0300 Subject: [PATCH] feat: adguard home basic setup --- hosts/homex/configuration.nix | 10 +++++++ modules/nixos/homelab/adguard.nix | 46 +++++++++++++++++++++++++++++++ modules/nixos/homelab/default.nix | 1 + 3 files changed, 57 insertions(+) create mode 100644 modules/nixos/homelab/adguard.nix diff --git a/hosts/homex/configuration.nix b/hosts/homex/configuration.nix index 624f8d4..3cce066 100644 --- a/hosts/homex/configuration.nix +++ b/hosts/homex/configuration.nix @@ -19,6 +19,13 @@ enable = true; flakeDir = "/home/guz/.nix#homex"; + adguard = { + enable = true; + settings.server = { + port = 3010; + }; + }; + forgejo = { enable = true; settings.users."user1" = { @@ -27,6 +34,9 @@ password = /. + config.sops.secrets."forgejo/user1/password".path; admin = true; }; + settings.server = { + port = 3020; + }; }; }; diff --git a/modules/nixos/homelab/adguard.nix b/modules/nixos/homelab/adguard.nix new file mode 100644 index 0000000..cd4165b --- /dev/null +++ b/modules/nixos/homelab/adguard.nix @@ -0,0 +1,46 @@ +{ config, lib, pkgs, ... }: + +let + cfg = config.homelab.adguard; +in +{ + imports = [ ]; + options.homelab.adguard = with lib; with lib.types; { + enable = mkEnableOption ""; + extraArgs = mkOption { + type = listOf str; + default = [ ]; + }; + settings = { + server.domain = mkOption { + type = str; + default = "localhost"; + }; + server.port = mkOption { + type = port; + default = 3000; + }; + server.address = mkOption { + type = str; + default = "0.0.0.0"; + }; + }; + }; + config = lib.mkIf cfg.enable { + networking.firewall = { + allowedTCPPorts = [ 53 ]; + allowedUDPPorts = [ 53 51820 ]; + }; + services.adguardhome = { + enable = true; + settings = { + bind_port = cfg.settings.server.port; + bind_host = cfg.settings.server.address; + http = { + address = "${cfg.settings.server.address}:${toString cfg.settings.server.port}"; + }; + }; + }; + }; +} + diff --git a/modules/nixos/homelab/default.nix b/modules/nixos/homelab/default.nix index a2d4aef..66d10a4 100644 --- a/modules/nixos/homelab/default.nix +++ b/modules/nixos/homelab/default.nix @@ -24,6 +24,7 @@ in { imports = [ ./forgejo.nix + ./adguard.nix ]; options.homelab = with lib; with lib.types; { enable = mkEnableOption "";