summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlorian Engel <engelflorian@posteo.de>2023-09-09 08:19:22 +0200
committerFlorian Engel <engelflorian@posteo.de>2023-09-09 08:19:22 +0200
commit20acd199f4202da863f290b50345d30c85db913c (patch)
treebffdc89f7df68fcfbfdc01960f65a7ba52745072
parent364ab12942df06290234d0335156e8281fae3c21 (diff)
downloadnixpkgs-20acd199f4202da863f290b50345d30c85db913c.tar
nixpkgs-20acd199f4202da863f290b50345d30c85db913c.tar.gz
nixpkgs-20acd199f4202da863f290b50345d30c85db913c.tar.bz2
nixpkgs-20acd199f4202da863f290b50345d30c85db913c.tar.lz
nixpkgs-20acd199f4202da863f290b50345d30c85db913c.tar.xz
nixpkgs-20acd199f4202da863f290b50345d30c85db913c.tar.zst
nixpkgs-20acd199f4202da863f290b50345d30c85db913c.zip
nixos/adguardhome: Fix openFirewall
When not setting `settings` and setting `openFirewall = true`
evaluation would fail because it tries to access `settings.bind_port`
while `settings == null`
-rw-r--r--nixos/modules/services/networking/adguardhome.nix5
-rw-r--r--nixos/tests/adguardhome.nix1
2 files changed, 3 insertions, 3 deletions
diff --git a/nixos/modules/services/networking/adguardhome.nix b/nixos/modules/services/networking/adguardhome.nix
index 1701e5b439c..399d838ccc6 100644
--- a/nixos/modules/services/networking/adguardhome.nix
+++ b/nixos/modules/services/networking/adguardhome.nix
@@ -17,6 +17,7 @@ let
     text = builtins.toJSON cfg.settings;
     checkPhase = "${pkgs.adguardhome}/bin/adguardhome -c $out --check-config";
   };
+  defaultBindPort = 3000;
 
 in
 {
@@ -86,7 +87,7 @@ in
             '';
           };
           bind_port = mkOption {
-            default = 3000;
+            default = defaultBindPort;
             type = port;
             description = lib.mdDoc ''
               Port to serve HTTP pages on.
@@ -169,6 +170,6 @@ in
       };
     };
 
-    networking.firewall.allowedTCPPorts = mkIf cfg.openFirewall [ cfg.settings.bind_port ];
+    networking.firewall.allowedTCPPorts = mkIf cfg.openFirewall [ cfg.settings.bind_port or defaultBindPort ];
   };
 }
diff --git a/nixos/tests/adguardhome.nix b/nixos/tests/adguardhome.nix
index 9f8ddc33f57..a6f790b83f5 100644
--- a/nixos/tests/adguardhome.nix
+++ b/nixos/tests/adguardhome.nix
@@ -7,7 +7,6 @@
     emptyConf = { lib, ... }: {
       services.adguardhome = {
         enable = true;
-        settings = {};
       };
     };