{ description = "Custom Firefox build"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; }; nixConfig = { extra-experimental-features = [ "pipe-operator" "pipe-operators" ]; extra-substituters = [ "https://cache.kyouma.net" ]; extra-trusted-public-keys = [ "cache.kyouma.net:Frjwu4q1rnwE/MnSTmX9yx86GNA/z3p/oElGvucLiZg=" ]; }; outputs = { self, nixpkgs, ... }: let inherit (nixpkgs) lib; in { packages = lib.genAttrs [ "x86_64-linux" "aarch64-linux" ] (system: let pkgs = nixpkgs.legacyPackages.${system}.pkgsMusl; mimalloc = pkgs.mimalloc.override { secureBuild = true; }; extraWrapper = prevAttrs: { buildCommand = prevAttrs.buildCommand + '' sed -i \ -e '$i export MIMALLOC_PURGE_DELAY=150' \ -e '$i export MIMALLOC_PURGE_DECOMMITS=0' \ -e '$i export MIMALLOC_RESERVE_HUGE_OS_PAGES=2' \ "$out/bin/${prevAttrs.meta.mainProgram}" ''; }; in { default = self.packages.${system}.firefox; firefox = (pkgs.wrapFirefox self.packages.${system}.firefox-unwrapped { extraPoliciesFiles = [ ./policy.nix ]; }).overrideAttrs extraWrapper; firefox-unwrapped = ((pkgs.buildMozillaMach { pname = "firefox"; inherit (pkgs.firefox-beta-unwrapped) src version meta tests; extraConfigureFlags = [ "--enable-default-toolkit=cairo-gtk3-wayland-only" ]; extraBuildInputs = [ mimalloc ]; }).overrideAttrs (prevAttrs: { env = prevAttrs.env or { } // { LDFLAGS = lib.toList prevAttrs.env.LDFLAGS or [ ] ++ [ "-lmimalloc" ] |> toString; }; })).override { alsaSupport = false; ffmpegSupport = true; gssSupport = false; jackSupport = false; jemallocSupport = false; ltoSupport = true; pgoSupport = true; pipewireSupport = true; pulseaudioSupport = true; sndioSupport = false; waylandSupport = true; crashreporterSupport = false; googleAPISupport = false; }; thunderbird = (pkgs.wrapThunderbird self.packages.${system}.thunderbird-unwrapped { }).overrideAttrs extraWrapper; thunderbird-unwrapped = (pkgs.thunderbird-latest-unwrapped.overrideAttrs (prevAttrs: { configureFlags = prevAttrs.configureFlags or [ ] ++ [ "--enable-default-toolkit=cairo-gtk3-wayland-only" ]; })).override { alsaSupport = false; ffmpegSupport = false; gssSupport = false; jackSupport = false; jemallocSupport = false; ltoSupport = true; pgoSupport = true; pipewireSupport = false; pulseaudioSupport = false; sndioSupport = false; waylandSupport = true; privacySupport = true; drmSupport = false; }; }); hydraJobs = self.packages |> lib.foldlAttrs (jobs: system: packages: lib.recursiveUpdate jobs (lib.mapAttrs (name: package: { ${system} = package; }) packages)) { }; }; }