Like this?
```
    systemd.services.searx = {
      description = "Searx server, the meta search engine.";
      after = [ "network.target" ];
      wantedBy = [ "multi-user.target" ];
      environment.SEARX_SETTINGS_PATH = "${configFile}";
      serviceConfig = {
        User = "searx";
        ExecStart = "${pkgs.pythonPackages.searx}/bin/searx-run";
      };
    };
```
this fails because env variable is set as empty string, there is a difference if variable has empty string or is non-existent, optionalString does not work here also because it sets empty string if condition was not true.