Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

firefox: add firefox-gnome-theme #702

Merged
merged 4 commits into from
Jan 6, 2025

Conversation

brckd
Copy link
Contributor

@brckd brckd commented Dec 27, 2024

This adds the firefoxGnomeTheme.enable option which installs the Firefox GNOME theme with the Stylix palette on Firefox derivatives. Note that the new modules/firefox/userChrome.mustache is mostly a syntactically modified version of modules/gtk/gtk.mustache.

Preview the Firefox GNOME theme on LibreWolf with other slight modifications.

Note the similarity to the GNOME Web browser.
Firefox GNOME theme on LibreWolf

modules/firefox/userChrome.mustache Outdated Show resolved Hide resolved
modules/firefox/hm.nix Outdated Show resolved Hide resolved
modules/firefox/hm.nix Outdated Show resolved Hide resolved
modules/firefox/hm.nix Outdated Show resolved Hide resolved
Copy link
Collaborator

@trueNAHO trueNAHO left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the silly question, but how do I test this theme with the following patch when profileNames is on its default value:

commit 64059ce04de4750e498403a1cb2edca3b16f8cd6
Author: NAHO <[email protected]>
Date:   2025-01-02 19:29:57 +0100

    stylix: enable Firefox GNOME theme

diff --git a/flake.lock b/flake.lock
index ea850645..174b043d 100644
--- a/flake.lock
+++ b/flake.lock
@@ -128,6 +128,22 @@
         "type": "github"
       }
     },
+    "firefox-gnome-theme": {
+      "flake": false,
+      "locked": {
+        "lastModified": 1734969791,
+        "narHash": "sha256-A9PxLienMYJ/WUvqFie9qXrNC2MeRRYw7TG/q7DRjZg=",
+        "owner": "rafaelmardojai",
+        "repo": "firefox-gnome-theme",
+        "rev": "92f4890bd150fc9d97b61b3583680c0524a8cafe",
+        "type": "github"
+      },
+      "original": {
+        "owner": "rafaelmardojai",
+        "repo": "firefox-gnome-theme",
+        "type": "github"
+      }
+    },
     "flake-parts": {
       "inputs": {
         "nixpkgs-lib": [
@@ -578,6 +594,7 @@
         "base16-fish": "base16-fish",
         "base16-helix": "base16-helix",
         "base16-vim": "base16-vim",
+        "firefox-gnome-theme": "firefox-gnome-theme",
         "flake-compat": [],
         "flake-utils": [
           "flake-utils"
@@ -597,15 +614,16 @@
         "tinted-tmux": "tinted-tmux"
       },
       "locked": {
-        "lastModified": 1733262405,
-        "narHash": "sha256-/AT315It87ll6mlZLYcmfoe6Uogx9MjPBCCZZZTq8xY=",
-        "owner": "danth",
+        "lastModified": 1735834808,
+        "narHash": "sha256-6cKEhlS4Kx0RqRnDKrAfOLh6Xp678aJQ7hr8XGoRpKs=",
+        "owner": "brckd",
         "repo": "stylix",
-        "rev": "ffba1f1bab63ea49541f812c72a4fcf305461d67",
+        "rev": "86b40128f6196dff357c99c400ec351a763c5843",
         "type": "github"
       },
       "original": {
-        "owner": "danth",
+        "owner": "brckd",
+        "ref": "firefox/add-firefox-gnome-theme",
         "repo": "stylix",
         "type": "github"
       }
diff --git a/flake.nix b/flake.nix
index 998409de..027e76e9 100644
--- a/flake.nix
+++ b/flake.nix
@@ -136,7 +136,7 @@
         systems.follows = "systems";
       };

-      url = "github:danth/stylix";
+      url = "github:brckd/stylix/firefox/add-firefox-gnome-theme";
     };

     systems.url = "github:nix-systems/default";
diff --git a/modules/inputs/stylix/default.nix b/modules/inputs/stylix/default.nix
index a846fb8a..d6dd0005 100644
--- a/modules/inputs/stylix/default.nix
+++ b/modules/inputs/stylix/default.nix
@@ -54,6 +54,7 @@
       };

       polarity = "dark";
+      targets.librewolf.firefoxGnomeTheme.enable = true;
     };
   };
 }

@brckd
Copy link
Contributor Author

brckd commented Jan 2, 2025

@trueNAHO That's not a silly question actually. The theme alongside the Firefox module's other tweaks is only applied to the profiles specified in profileNames. The default profileNames is an empty list, so it's not applied to any Firefox profile at all. You'll need declare at least one Firefox profile in Home Manager and add that to profileNames.

{
  programs.firefox.profiles."naho" = {
    # Default profile if not specified otherwise. Additional profiles require `id` to be set.
    name = "NAHO";
  };
  stylix.targets.firefox.profileNames = [ "naho" ];
}

Perhaps we should create a separate PR that declares a warning when the Firefox module is used without any specified profileNames?

@trueNAHO
Copy link
Collaborator

trueNAHO commented Jan 3, 2025

The theme alongside the Firefox module's other tweaks is only applied to the profiles specified in profileNames. The default profileNames is an empty list, so it's not applied to any Firefox profile at all. You'll need declare at least one Firefox profile in Home Manager and add that to profileNames.

{
  programs.firefox.profiles."naho" = {
    # Default profile if not specified otherwise. Additional profiles require `id` to be set.
    name = "NAHO";
  };
  stylix.targets.firefox.profileNames = [ "naho" ];
}

Perhaps we should create a separate PR that declares a warning when the Firefox module is used without any specified profileNames?

I have already brought this up with

stylix.targets.firefox.profileNames = [ "stylix" ];

in the following discussion:

Is it possible to simplify this testbed by having the /modules/firefox/hm.nix module imply the stylix profile as the default? Or is there a reason it does not already do that?

Profiles don't only affect the theme; many users will be coming with existing Home Manager configurations where they used a different name for their default profile. Changing the name of an existing profile requires manually renaming the files related to that profile.

-- danth, "treewide: add application testbeds"

I am still unsure whether we should apply some profile by default or use lib.info or lib.warn.

@brckd
Copy link
Contributor Author

brckd commented Jan 4, 2025

Both are valid options but out of scope for this PR IMO. Did you get your testcase working? I could also add a testbed as recommended by the discussion you just linked.

@trueNAHO
Copy link
Collaborator

trueNAHO commented Jan 4, 2025

Both are valid options but out of scope for this PR IMO.

Agreed.

Did you get your testcase working?

I did not try it out yet.

I could also add a testbed as recommended by the discussion you just linked.

That might be even better.

@brckd brckd force-pushed the firefox/add-firefox-gnome-theme branch from 86b4012 to 22fe6a4 Compare January 5, 2025 01:25
@brckd brckd force-pushed the firefox/add-firefox-gnome-theme branch from 22fe6a4 to c27d1d3 Compare January 6, 2025 16:35
@brckd
Copy link
Contributor Author

brckd commented Jan 6, 2025

Is anything stopping this from being merged?

Copy link
Owner

@danth danth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested in a modified version of the testbed with this option enabled; everything seems to be working perfectly.

(Having a ready made testbed with this enabled would be nice, but is not a requirement for this PR. This is complicated by the fact that the testbed system currently only supports one configuration per module.)

Is this suitable to backport to release-24.11? I would love to use this in my own configuration. [Edit: see #753]

@danth danth requested a review from trueNAHO January 6, 2025 22:15
Copy link
Collaborator

@trueNAHO trueNAHO left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is anything stopping this from being merged?

Sorry for the delay.

I have tested this PR in my setup with the following commit:

commit ee42e874bff9adab167cfb0144554bb5d2e8bb43
Author: NAHO <[email protected]>
Date:   2025-01-06 23:00:45 +0100

    librewolf: enable Firefox GNOME theme

diff --git a/modules/inputs/home-manager/programs/librewolf/default.nix b/modules/inputs/home-manager/programs/librewolf/default.nix
index e39d55a0..55865a20 100644
--- a/modules/inputs/home-manager/programs/librewolf/default.nix
+++ b/modules/inputs/home-manager/programs/librewolf/default.nix
@@ -3,11 +3,35 @@
   lib,
   ...
 }: {
+  imports = [../../../stylix];
+
   options.dotfiles.inputs.home-manager.programs.librewolf.enable =
     lib.dotfiles.mkEnableOption;

   config =
     lib.mkIf
     config.dotfiles.inputs.home-manager.programs.librewolf.enable
-    {programs.librewolf.enable = true;};
+    (
+      lib.mkMerge [
+        (
+          let
+            # The profile name of the firefox derivatives is a leaky
+            # encapsulation as mentioned in [1].
+            #
+            # [1]: https://github.com/danth/stylix/pull/702#issuecomment-2569747876
+            profile = "stylix";
+          in {
+            dotfiles.inputs.stylix.enable = true;
+            programs.librewolf.profiles.${profile}.name = profile;
+
+            stylix.targets.librewolf = {
+              firefoxGnomeTheme.enable = true;
+              profileNames = [profile];
+            };
+          }
+        )
+
+        {programs.librewolf.enable = true;}
+      ]
+    );
 }

@trueNAHO trueNAHO merged commit 1d7b70e into danth:master Jan 6, 2025
danth pushed a commit that referenced this pull request Jan 6, 2025
Link: #702

Tested-by: Daniel Thwaites <[email protected]>
Approved-by: Daniel Thwaites <[email protected]>
Reviewed-by: NAHO <[email protected]>
Tested-by: NAHO <[email protected]>
(cherry picked from commit 1d7b70e)
danth pushed a commit that referenced this pull request Jan 6, 2025
Link: #702

Tested-by: Daniel Thwaites <[email protected]>
Approved-by: Daniel Thwaites <[email protected]>
Reviewed-by: NAHO <[email protected]>
Tested-by: NAHO <[email protected]>
(cherry picked from commit 1d7b70e)
@brckd
Copy link
Contributor Author

brckd commented Jan 6, 2025

(Having a ready made testbed with this enabled would be nice, but is not a requirement for this PR. This is complicated by the fact that the testbed system currently only supports one configuration per module.)

Oh snap, I forgot to add that! Should that be a separate testbed, since the option is not enabled by default?

Sorry for the delay.

Sorry for having sounded impatient. I was trying to make sure I didn't miss anything myself that would have delayed the process.

@trueNAHO
Copy link
Collaborator

trueNAHO commented Jan 6, 2025

(Having a ready made testbed with this enabled would be nice, but is not a requirement for this PR. This is complicated by the fact that the testbed system currently only supports one configuration per module.)

Oh snap, I forgot to add that! Should that be a separate testbed, since the option is not enabled by default?

Ideally, yes.

@danth
Copy link
Owner

danth commented Jan 11, 2025

Should that be a separate testbed, since the option is not enabled by default?

Yeah, we should have one testbed for regular Firefox and one with the GNOME theme enabled. Unfortunately we'll need to adapt the testbed system first because it currently only allows one testbed.nix per module.

@trueNAHO trueNAHO mentioned this pull request Jan 18, 2025
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants