{ callPackage }:
let
  src = callPackage ./src.nix { };
in
rec {

  inherit (src) packageVersion firefox source;

  extraPatches = [ ];

  extraConfigureFlags = [
    "--with-app-name=librewolf"
    "--with-unsigned-addon-scopes=app,system"
  ];

  extraPostPatch = ''
    while read patch_name; do
      echo "applying LibreWolf patch: $patch_name"
      patch -p1 < ${source}/$patch_name
    done <${source}/assets/patches.txt

    cp -r ${source}/themes/browser .
    cp ${source}/assets/search-config.json services/settings/dumps/main/search-config.json
    sed -i '/MOZ_SERVICES_HEALTHREPORT/ s/True/False/' browser/moz.configure
    sed -i '/MOZ_NORMANDY/ s/True/False/' browser/moz.configure
  '';

  extraPrefsFiles = [ "${src.settings}/librewolf.cfg" ];

  extraPoliciesFiles = [ "${src.settings}/distribution/policies.json" ];

  extraPassthru = {
    librewolf = { inherit src extraPatches; };
    inherit extraPrefsFiles extraPoliciesFiles;
  };
}

