NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
19.06k stars 14.77k forks source link

Allow patches to chromium package #372993

Closed ArtemYurlov closed 1 week ago

ArtemYurlov commented 1 week ago

The problem

At the moment we cannot patch chromium, e.g. with something like

{ pkgs ? import <nixpkgs> {} }:
pkgs.chromium.override {
  browser = pkgs.chromium.browser.overrideAttrs (oldAttrs: {
    patches = (oldAttrs.patches or []) ++ [ ./my_patch.patch ];
  });
}

this does not work because chromium.browser is hard-coded in a local scope before the final stdenv.mkDerivation, so it never sees the override.

Solution

Add a browser ? null parameter as input in chromium/default.nix

{ newScope
# ...
, pkgs
, browser ? null
}:

let
  # Instead of unconditionally pulling chromium.browser from below,
  #    pick the "browser" we were passed if non-null, or use the default.
  chromium = rec {
    browser = if browser != null
      then browser
      else callPackage ./browser.nix {
        inherit ungoogled enableWideVine ...;
      };
  };

Please let me know if I'm missing an existing way to patch the browser.

Thanks!

cc @networkException @emilylange

emilylange commented 1 week ago

Duplicate of #276884.