From 4b28c3f1c6ffc60e2f9455e922132bfcd1dbe752 Mon Sep 17 00:00:00 2001 From: Lucas Chaim Date: Sun, 29 Sep 2024 19:37:12 -0300 Subject: [PATCH] feat: Patch Brave webapps The generated .desktop files seem to point to the brave binary on the nix store at the time of creation, so for now I just sed them to the generic executable on path --- modules/home/gui/chromium.nix | 38 ++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/modules/home/gui/chromium.nix b/modules/home/gui/chromium.nix index b47ee12..d022a76 100644 --- a/modules/home/gui/chromium.nix +++ b/modules/home/gui/chromium.nix @@ -1,16 +1,36 @@ { config, inputs, + lib, pkgs, ... }: let inherit (inputs.home-manager.lib) hm; -in { - programs.chromium = { - enable = true; - commandLineArgs = [ - "--disable-gpu-compositing" # @TODO Remove after NVIDIA figures this out - ]; - package = pkgs.brave; - }; -} +in + lib.mkIf (config.my.modules.gui.enable) { + programs.chromium = { + enable = true; + commandLineArgs = [ + "--disable-gpu-compositing" # @TODO Remove after NVIDIA figures this out + ]; + package = pkgs.brave; + }; + + home.activation.patchBraveWebapps = let + inherit (config.programs.chromium) package; + executable = package.meta.mainProgram; + script = + hm.dag.entryAfter + ["writeBoundary"] + # bash + '' + # Patches webapps so that they point to the executable on path + run --quiet \ + find '${config.home.homeDirectory}/.local/share/applications' \ + -type f -name 'brave-*.desktop' \ + | xargs --no-run-if-empty \ + sed --in-place 's,Exec=[^ ]*,Exec=${executable},g' + ''; + in + lib.mkIf (package == pkgs.brave) script; + }