Unverified Commit 6958a347 authored by Pol Dellaiera's avatar Pol Dellaiera Committed by GitHub
Browse files

nixos/searx: add openFirewall option (#500388)

parents 3c98c3d5 abd4cb9e
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -54,6 +54,19 @@ in
        description = "Whether to enable Searx, the meta search engine.";
      };

      openFirewall = mkOption {
        type = types.bool;
        default = false;
        description = ''
          Whether to open the port in the firewall.
          Enabling this option adds the port specified in {option}`services.settings.server.port` to {option}`networking.firewall.allowedTCPPorts`.

          ::: {.note}
          When this option is set to true, {option}`services.settings.server.port` must be set as well or an error will be thrown.
          :::
        '';
      };

      domain = mkOption {
        type = types.str;
        description = ''
@@ -244,6 +257,13 @@ in
  ];

  config = mkIf cfg.enable {
    assertions = [
      {
        assertion = cfg.openFirewall -> cfg.settings ? server.port;
        message = "services.searx.settings.server.port must be set when openFirewall is enabled.";
      }
    ];

    environment = {
      etc = {
        "searxng/favicons.toml" = lib.mkIf (cfg.faviconsSettings != { }) {
@@ -392,6 +412,8 @@ in
        isSystemUser = true;
      };
    };

    networking.firewall = lib.mkIf cfg.openFirewall { allowedTCPPorts = [ cfg.settings.server.port ]; };
  };

  meta.maintainers = with maintainers; [