{
  config,
  lib,
  ...
}:
let
  cfg = config.machine.searxng;
in
with lib;
mkIf cfg.enable {
  sops.secrets = {
    "searxng/secretKey" = {
      sopsFile = ./../../secrets/common.yaml;
      owner = config.users.users.matrix-synapse.name;
      inherit (config.users.users.matrix-synapse) group;
    };
  };
  sops.templates.searxng-env = {
    content = ''
      SEARXNG_SECRET_KEY=${config.sops.placeholder."searxng/secretKey"};
    '';
  };
}
