From 31c3cd5f7d6a93793b958cb92e9e23e1107c5334 Mon Sep 17 00:00:00 2001
From: matt1432 <matt@nelim.org>
Date: Tue, 11 Jun 2024 11:13:40 -0400
Subject: [PATCH] feat(firefox): update and clean up firefox-gx

---
 flake.lock                          |   8 +-
 flake.nix                           |   2 +-
 home/firefox/custom-css.nix         | 139 ++++++++++++++++++++++++
 home/firefox/custom.css             | 162 ----------------------------
 home/firefox/default.nix            |   6 +-
 home/firefox/firefox-gx/default.nix |   6 +-
 inputs.nix                          |   2 +-
 7 files changed, 152 insertions(+), 173 deletions(-)
 create mode 100644 home/firefox/custom-css.nix
 delete mode 100644 home/firefox/custom.css

diff --git a/flake.lock b/flake.lock
index d8748192..a79fd5f4 100644
--- a/flake.lock
+++ b/flake.lock
@@ -190,17 +190,17 @@
     "firefox-gx-src": {
       "flake": false,
       "locked": {
-        "lastModified": 1712858061,
-        "narHash": "sha256-O0ggIMU3FmrkYoTLgHUPmzMr9n1B1UdppHYAS/S2Anc=",
+        "lastModified": 1717510595,
+        "narHash": "sha256-QWae4pNWUsoNUvz6MntUtBG242aer3n+JrSk2cw/NOA=",
         "owner": "Godiesc",
         "repo": "firefox-gx",
-        "rev": "1f6239d8d2ba1226b3736640e65dbbca442472bb",
+        "rev": "dde9941d4bf78b94d76bf06cccb2d1dce5372c56",
         "type": "github"
       },
       "original": {
         "owner": "Godiesc",
-        "ref": "v.9.1",
         "repo": "firefox-gx",
+        "rev": "dde9941d4bf78b94d76bf06cccb2d1dce5372c56",
         "type": "github"
       }
     },
diff --git a/flake.nix b/flake.nix
index a9a2f9bb..6d766582 100644
--- a/flake.nix
+++ b/flake.nix
@@ -64,8 +64,8 @@
     firefox-gx-src = {
       flake = false;
       owner = "Godiesc";
-      ref = "v.9.1";
       repo = "firefox-gx";
+      rev = "dde9941d4bf78b94d76bf06cccb2d1dce5372c56";
       type = "github";
     };
     flakegen.url = "github:jorsn/flakegen";
diff --git a/home/firefox/custom-css.nix b/home/firefox/custom-css.nix
new file mode 100644
index 00000000..75aa063b
--- /dev/null
+++ b/home/firefox/custom-css.nix
@@ -0,0 +1,139 @@
+hostName:
+# css
+''
+  /* Hide unused menu rows */
+  .browser-toolbar>* #alltabs-button,
+  #appMenu-fxa-status2,
+  #appMenu-fxa-separator {
+      display: none !important;
+  }
+
+  :root * {
+      --margin-left-icons-personal: 3px !important;
+      --tab-height-personal: 40px !important;
+      --uc-tab-corner-height: 41px !important;
+      --uc-vertical-toolbar-width: 46px !important;
+  }
+
+  /* Fix url font-size */
+  #urlbar-input {
+      font-size: large !important;
+  }
+
+  /* Fix left side of tabs going past what it should */
+  scrollbox {
+      margin-left: 5px;
+  }
+
+  /* https://github.com/Godiesc/firefox-gx/blob/main/Tricks/README.md */
+  /* Extensions button into the "left-sidebar" - Immovable */
+  :root:not([chromehidden~="toolbar"],
+  [sizemode="fullscreen"]) #PersonalToolbar {
+      --padding-top-left-sidebar: 110px !important; /* 182px to one-line config */
+  }
+  :root:not([chromehidden~="toolbar"],
+  [sizemode="fullscreen"]) #unified-extensions-button {
+      --toolbarbutton-hover-background: transparent !important;
+      --toolbarbutton-active-background: transparent !important;
+      position: fixed;
+      display: flex;
+      top: 42px !important;
+      left: 1px !important;
+      z-index: 2 !important;
+      fill: var(--general-color) !important;
+      width: calc(var(--uc-vertical-toolbar-width) - 4px) !important;
+  }
+  :root:not([chromehidden~="toolbar"],
+  :root:not([chromehidden~="toolbar"],
+  [sizemode="fullscreen"]) #unified-extensions-button:hover,
+  [sizemode="fullscreen"]) #unified-extensions-button[open] {
+      transform: scale(1.24) !important;
+      transition: ease-in-out !important;
+  }
+  :root:not([chromehidden~="toolbar"],
+  [sizemode="fullscreen"]) #unified-extensions-button:active {
+      transform: scale(1.12) !important;
+      transition-duration: 0ms !important;
+  }
+
+  /* Fix extension dialog going off screen */
+  #appMenu-addon-installed-notification,
+  #notification-popup {
+      margin-top: -1px !important;
+      margin-inline: -505px !important;
+  }
+
+  #customizationui-widget-panel {
+      margin-top: -1px !important;
+  }
+
+  #PersonalToolbar .toolbarbutton-1 {
+      margin-block: 0px !important;
+  }
+
+  #PersonalToolbar #PlacesToolbarItems>.bookmark-item {
+      margin-block: 6px !important;
+  }
+
+  /* -------------------------------------------------------------- */
+  /* Fix menu */
+  :root:not([chromehidden~="toolbar"],
+  [sizemode="fullscreen"]) #PanelUI-menu-button,
+  :root[sizemode="maximized"] #appMenu-popup,
+  :root[sizemode="maximized"] #appMenu-popup {
+      --tab-height-personal: unset !important;
+  }
+
+  :root:not([chromehidden~="toolbar"])[sizemode="maximized"] #appMenu-popup>panelmultiview>box>box>panelview {
+      padding-top: unset !important;
+  }
+
+  /* Hamburger menu width */
+  :root:not([chromehidden~="toolbar"],
+  :root:not([chromehidden~="toolbar"]) #PanelUI-menu-button .toolbarbutton-badge-stack,
+  [sizemode="fullscreen"]):is([sizemode="maximized"]) #PanelUI-menu-button[open]>stack {
+      min-width: 46px !important;
+  }
+
+  toolbar .toolbarbutton-1>.toolbarbutton-badge-stack {
+      padding: 10px !important;
+  }
+
+  :root:not([chromehidden~="toolbar"]) #PanelUI-menu-button[open]>.toolbarbutton-badge-stack {
+      width: unset !important;
+      border-top-left-radius: ${
+    if hostName == "wim"
+    then "18"
+    else "0"
+  }px !important;
+  }
+
+  :root:not([chromehidden~="toolbar"]) #PanelUI-menu-button>stack {
+      display: unset;
+      align-items: unset !important;
+  }
+
+  /* Remove text and places panel correctly */
+  :root:not([chromehidden~="toolbar"]) #PanelUI-menu-button>stack::after {
+      width: unset !important;
+      content: unset;
+      color: unset !important;
+      text-shadow: unset !important;
+  }
+
+  :root:not([chromehidden~="toolbar"])[sizemode="maximized"] #appMenu-popup {
+      appearance: unset !important;
+      margin-top: -1px !important;
+      clip-path: unset;
+      --arrowpanel-menuitem-padding: unset !important;
+  }
+
+  :root:is([sizemode="maximized"]):not([tabsintitlebar],
+  [chromehidden~="toolbar"]) #appMenu-popup {
+      margin-top: unset !important;
+  }
+
+  .subviewbutton {
+      min-height: 40px !important;
+  }
+''
diff --git a/home/firefox/custom.css b/home/firefox/custom.css
deleted file mode 100644
index d1fdebff..00000000
--- a/home/firefox/custom.css
+++ /dev/null
@@ -1,162 +0,0 @@
-.browser-toolbar > * #alltabs-button,
-#appMenu-fxa-status2,
-#appMenu-fxa-separator {
-  display: none !important;
-}
-
-:root * {
-  --margin-left-icons-personal: 3px !important;
-  --tab-height-personal: 40px !important;
-  --uc-tab-corner-height: 41px !important;
-  --uc-vertical-toolbar-width: 46px !important;
-}
-
-/* Fix url font-size */
-#urlbar-input {
-    font-size: large !important;
-}
-
-/* Fix left side of tabs going past what it should */
-scrollbox {
-  margin-left: 5px;
-}
-
-/* https://github.com/Godiesc/firefox-gx/blob/main/Tricks/README.md */
-/* Extensions button into the "left-sidebar" - Immovable */
-
-:root:not([chromehidden~="toolbar"],[sizemode="fullscreen"]) #PersonalToolbar {
-  --padding-top-left-sidebar: 110px !important; /* 182px to one-line config */
-}
-
-:root:not([chromehidden~="toolbar"], [sizemode="fullscreen"]) #unified-extensions-button {
-  --toolbarbutton-hover-background: transparent !important;
-  --toolbarbutton-active-background: transparent !important;
-  position: fixed;
-  display: flex;
-  top: 42px !important;
-  left: 2px !important;
-  z-index: 2 !important;
-  fill: var(--general-color) !important;
-  width: calc(var(--uc-vertical-toolbar-width) - 4px) !important;
-}
-
-:root:not([chromehidden~="toolbar"], [sizemode="fullscreen"]) #unified-extensions-button:hover,
-:root:not([chromehidden~="toolbar"], [sizemode="fullscreen"]) #unified-extensions-button[open] {
-  transform: scale(1.12) !important;
-  transition: ease-in-out !important;
-}
-
-:root:not([chromehidden~="toolbar"], [sizemode="fullscreen"]) #unified-extensions-button:active {
-  transform: scale(1.0) !important;
-  transition-duration: 0ms !important;
-}
-
-#appMenu-addon-installed-notification,
-#notification-popup {
-  margin-top: -1px !important;
-  margin-inline: -505px !important;
-}
-
-#customizationui-widget-panel {
-  margin-top: -1px !important;
-  margin-inline: -200px !important;
-}
-
-#PersonalToolbar .toolbarbutton-1 {
-  margin-block: 0px !important;
-}
-#PersonalToolbar #PlacesToolbarItems > .bookmark-item {
-  margin-block: 6px !important;
-}
-
-/* -------------------------------------------------------------- */
-/* Fix menu */
-:root:not([chromehidden~="toolbar"], [sizemode="fullscreen"]) #PanelUI-menu-button, :root[sizemode="maximized"] #appMenu-popup,
-:root[sizemode="maximized"] #appMenu-popup {
-  --tab-height-personal: unset !important;
-}
-
-:root:not([chromehidden~="toolbar"])[sizemode="maximized"] #appMenu-popup > panelmultiview > box > box > panelview {
-  padding-top: unset !important;
-}
-
-/* Hamburger menu width */
-:root:not([chromehidden~="toolbar"], [sizemode="fullscreen"]):is([sizemode="maximized"]) #PanelUI-menu-button[open] > stack,
-:root:not([chromehidden~="toolbar"]) #PanelUI-menu-button .toolbarbutton-badge-stack {
-  min-width: 46px !important;
-}
-toolbar .toolbarbutton-1 > .toolbarbutton-badge-stack {
-  padding: 10px !important;
-}
-
-:root:not([chromehidden~="toolbar"]) #PanelUI-menu-button[open] > .toolbarbutton-badge-stack {
-  width: unset !important;
-}
-
-:root[sizemode="maximized"]:not([chromehidden~="toolbar"]) #appMenu-popup panelview {
-  width: unset !important;
-}
-
-:root:not([chromehidden~="toolbar"]) #PanelUI-menu-button > stack{
-  display: unset;
-  align-items: unset !important;
-}
-
-:root:not([chromehidden~="toolbar"]) #PanelUI-menu-button>stack::after {
-  width: unset !important;
-  content: unset;
-  color: unset !important;
-  padding-inline-start: unset !important;
-  padding-block: unset !important;
-  text-shadow: unset !important;
-}
-
-:root:not([chromehidden~="toolbar"])[sizemode="maximized"] #appMenu-popup {
-  appearance: unset !important;
-  margin-top: -1px !important;
-  clip-path: unset;
-  --arrowpanel-menuitem-padding: unset !important;
-}
-
-:root:is([sizemode="maximized"]):not([tabsintitlebar], [chromehidden~="toolbar"]) #appMenu-popup {
-  margin-top: unset !important;
-}
-
-.subviewbutton:is(#appMenu-popup toolbarbutton):not(.subviewbutton-back) {
-  padding-inline-start: unset !important;
-}
-.subviewbutton:not(.subviewbutton-iconic, .toolbarbutton-text, [checked="true"])>.toolbarbutton-icon, .syncNowBtn {
-  width: unset;
-  height: unset;
-  margin-inline-end: unset !important;
-}
-
-#appMenu-zoom-controls{
-  padding-inline-start: unset !important;
-}
-
-#appMenu-fxa-status2:not([fxastatus])>#appMenu-fxa-label2 {
-  margin-inline-end: unset !important;
-}
-
-:root:not([chromehidden~="toolbar"])[sizemode="maximized"] #appMenu-fxa-status2 {
-  padding-top: unset !important;
-  border-image: unset !important;
-  border-top: unset !important;
-}
-
-:root:is([sizemode="normal"], [sizemode="fullscreen"]) #appMenu-fxa-label2 {
-  margin-inline-start: unset !important;
-}
-
-#appMenu-fxa-status2:not([fxastatus="signedin"]) {
-  margin-inline-end: unset !important;
-  margin-inline-start: unset !important;
-}
-#appMenu-fxa-status2:not([fxastatus="signedin"]):hover toolbarbutton {
-  background-color: unset !important;
-}
-
-:root:not([chromehidden~="toolbar"])[sizemode="maximized"] #appMenu-popup {
-  --arrowpanel-menuitem-padding: unset !important;
-}
diff --git a/home/firefox/default.nix b/home/firefox/default.nix
index ccd4e8d8..9387697e 100644
--- a/home/firefox/default.nix
+++ b/home/firefox/default.nix
@@ -1,8 +1,11 @@
 {
+  config,
   pkgs,
   firefox-gx-src,
   ...
 }: let
+  inherit (config.vars) hostName;
+
   firefox-addons = pkgs.recurseIntoAttrs (pkgs.callPackage ./addons {});
 
   firefox-gx = pkgs.callPackage ./firefox-gx {
@@ -24,7 +27,7 @@ in {
 
       userChrome = ''
         @import url("file://${firefox-gx}/chrome/userChrome.css");
-        @import url("file://${./custom.css}");
+        ${import ./custom-css.nix hostName}
       '';
 
       settings = {
@@ -46,6 +49,7 @@ in {
         "browser.tabs.delayHidingAudioPlayingIconMS" = 0;
         "layout.css.backdrop-filter.enabled" = true;
         "browser.newtabpage.activity-stream.improvesearch.handoffToAwesomebar" = false;
+        "browser.newtabpage.activity-stream.newtabWallpapers.enabled" = true;
 
         /*
         To active container tabs without any extension
diff --git a/home/firefox/firefox-gx/default.nix b/home/firefox/firefox-gx/default.nix
index b96ddd4f..d3e3e008 100644
--- a/home/firefox/firefox-gx/default.nix
+++ b/home/firefox/firefox-gx/default.nix
@@ -12,10 +12,8 @@ stdenvNoCC.mkDerivation {
   installPhase = ''
     # Personal changes
     sed -i 's/var(--fuchsia))/var(--purple))/' ./chrome/components/ogx_root-personal.css
-
-    # Fix new tab background for nix
-    substituteInPlace ./chrome/components/ogx_root-personal.css \
-      --replace-fail '../newtab/wallpaper-dark.png' "$out/chrome/newtab/private-dark.png"
+    sed -i 's#../newtab/wallpaper-dark1.png#../newtab/wallpaper-dark2.png#' ./chrome/components/ogx_root-personal.css
+    #
 
     mkdir -p $out
     cp -r ./* $out
diff --git a/inputs.nix b/inputs.nix
index 9643fc3c..6d5bd4cf 100644
--- a/inputs.nix
+++ b/inputs.nix
@@ -256,7 +256,7 @@ let
     {
       owner = "Godiesc";
       repo = "firefox-gx";
-      ref = "v.9.1";
+      rev = "dde9941d4bf78b94d76bf06cccb2d1dce5372c56";
     }
     {
       name = "git-theme-src";