From 9f61b9a378f28eb72da051fdaa55ec972cab1057 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Fri, 2 Feb 2024 13:51:43 +0200 Subject: [PATCH] firefox: wrap with nixGL better --- shared/home/default.nix | 48 ++++++++++++++++++++++++++++++++--------- 1 file changed, 38 insertions(+), 10 deletions(-) diff --git a/shared/home/default.nix b/shared/home/default.nix index 090e3dd..1849b1e 100644 --- a/shared/home/default.nix +++ b/shared/home/default.nix @@ -31,6 +31,43 @@ -- "$@" ''; }; + + # from https://github.com/Gerg-L/demoninajar/blob/39964f198dbfa34c21f81c35370fab312b476051/homes/veritas_manjaro/nixGL.nix#L42 + mkWrapped = wrap: orig-pkg: execName: + pkgs.makeOverridable + ( + attrs: let + pkg = orig-pkg.override attrs; + outs = pkg.meta.outputsToInstall; + paths = pkgs.lib.attrsets.attrVals outs pkg; + nonTrivialOuts = pkgs.lib.lists.remove "out" outs; + metaAttributes = + pkgs.lib.attrsets.getAttrs + ( + [ + "name" + "pname" + "version" + "meta" + ] + ++ nonTrivialOuts + ) + pkg; + in + pkgs.symlinkJoin ( + { + inherit paths; + nativeBuildInputs = [pkgs.makeBinaryWrapper]; + postBuild = '' + mv $out/bin/${execName} $out/bin/.${execName}-mkWrapped-original + makeWrapper ${wrap}/bin/${wrap.name} $out/bin/${execName} --add-flags $out/bin/.${execName}-mkWrapped-original + ''; + } + // metaAttributes + ) + ) + {}; + glintel = mkWrapped pkgs.nixgl.nixGLIntel; in { home = { inherit stateVersion; @@ -49,7 +86,6 @@ in { ]) (lib.mkIf hmOnly [ - pkgs.nixgl.nixGLIntel ncdu tokei scrcpy @@ -58,14 +94,6 @@ in { vimv-rs bandwhich hyperfine - (runCommand "ff" {} '' - mkdir -p $out/bin - { - echo '#!/bin/sh' - echo 'exec ${pkgs.nixgl.nixGLIntel}/bin/nixGLIntel ${firefox}/bin/firefox "$@"' - } > $out/bin/ff - chmod a+x $out/bin/ff - '') ]) ]; @@ -74,7 +102,7 @@ in { firefox = lib.mkIf fullDesktop { enable = true; - package = pkgs.firefox-bin; + package = glintel pkgs.firefox-bin "firefox"; policies.DisableAppUpdate = true; profiles = { xdefault = {