NixOS / calamares-nixos-extensions

NixOS calamares [maintainer=@vlinkz]
25 stars 23 forks source link

Make Firefox module ready to work with Gnome extension #31

Open Thatoo opened 6 months ago

Thatoo commented 6 months ago

As a newcomer installing the Gnome ISO, one would expect gnome extension to work right away with the "by default" installed firefox.

This PR comes after this discussion : https://github.com/NixOS/nixpkgs/issues/300577

Thatoo commented 6 months ago

Gnome user would expect to be able to use https://addons.mozilla.org/fr/firefox/addon/gnome-shell-integration right after installation time.

I even wonder if this firefox extension should not be installed by default during installation time thanks to icicle. If I understand what is written here, https://support.mozilla.org/en-US/kb/deploying-firefox-with-extensions , it would require to download the last version from https://addons.mozilla.org/firefox/downloads/latest/gnome-shell-integration/latest.xpi, rename it to chrome-gnome-shell@gnome.org.xpi (the add-on ID found in here https://gitlab.gnome.org/GNOME/gnome-browser-extension/-/blob/master/extension/manifest.firefox.json) and place it into the <firefox installation folder>/distribution/extensions/folder.

I'd be glad to add that to this PR too but I'm not sure how to do so. I don't know where would be this <firefox installation folder> in nixos.

Thatoo commented 6 months ago

One more advantage is that if a user wants, for example, to install some "special" firefox extension such as https://addons.mozilla.org/fr/firefox/addon/gsconnect/ or https://addons.mozilla.org/fr/firefox/addon/pwas-for-firefox/ the user would only need to learn to add it to both PATH and nativeMessagingHosts to make it possible for the extension to detect and use it. such as

  programs.firefox = {
    enable = true;
    package = pkgs.firefox;
    nativeMessagingHosts.packages = with pkgs; [
      browserpass
      gnomeExtensions.gsconnect
      unstable.firefoxpwa
    ];
  };

  programs.kdeconnect = {
    enable = true;
    package = pkgs.gnomeExtensions.gsconnect;
  };

  environment.systemPackages = with pkgs; [
    firefoxpwa
  ];
Thatoo commented 6 months ago

if

  programs.firefox = {
    enable = true;
    package = pkgs.firefox;
    nativeMessagingHosts.packages = with pkgs; [
      browserpass
    ];
  };

is not already present in the configuration.nix file after install, it will require much more work (dig in forums, ask and disturb again on matrix room..) for the new comers to reach to his/her goal.

Thatoo commented 6 months ago

Finally, I would offer to use this PR to solve some comment issue in the code :

    if gs.value("packagechooser_packagechooser") != "":
        cfg += cfgfirefox

    # Check if unfree packages are allowed
    free = True
    if gs.value("packagechooser_unfree") is not None:
        if gs.value("packagechooser_unfree") == "unfree":
            free = False
            cfg += cfgunfree

    cfg += cfgpkgs
    # Use firefox as default as a graphical web browser, and add kate to plasma desktop
    if gs.value("packagechooser_packagechooser") == "plasma":
        catenate(variables, "pkgs", "\n      kate\n    #  thunderbird\n    ")
    elif gs.value("packagechooser_packagechooser") != "":
        catenate(variables, "pkgs", "\n    #  thunderbird\n    ")
    else:
        catenate(variables, "pkgs", "")

I guess the comment line # Use firefox as default as a graphical web browser, and add kate to plasma desktop is a heritage and is not related to the today code. What do you think of

    # Use firefox as default as a graphical web browser
    if gs.value("packagechooser_packagechooser") != "":
        cfg += cfgfirefox

    # Check if unfree packages are allowed
    free = True
    if gs.value("packagechooser_unfree") is not None:
        if gs.value("packagechooser_unfree") == "unfree":
            free = False
            cfg += cfgunfree

    cfg += cfgpkgs
    # Add kate to plasma desktop and suggest Thunderbird as mail client
    if gs.value("packagechooser_packagechooser") == "plasma":
        catenate(variables, "pkgs", "\n      kate\n    #  thunderbird\n    ")
    elif gs.value("packagechooser_packagechooser") != "":
        catenate(variables, "pkgs", "\n    #  thunderbird\n    ")
    else:
        catenate(variables, "pkgs", "")
jtojnar commented 5 months ago

It has already been fixed by https://github.com/NixOS/calamares-nixos-extensions/commit/972e34bf91ada145a4c5ec90be78ff9c21f0dee0.

The messaging host does not need to be enabled manually since it is done by the connector module enabled in GNOME by default:

https://github.com/NixOS/nixpkgs/blob/aab82e1d8b862d0267e8863bb5c971fb1c17a81d/nixos/modules/services/x11/desktop-managers/gnome.nix#L389

I even wonder if this firefox extension should not be installed by default during installation time thanks to icicle.

I would not recommend installing GNOME Shell extensions from extension.gnome.org since some extensions require patching, which is only available in Nixpkgs.

Thatoo commented 5 months ago

It has already been fixed by 972e34b.

partly only

The messaging host does not need to be enabled manually since it is done by the connector module enabled in GNOME by default:

https://github.com/NixOS/nixpkgs/blob/aab82e1d8b862d0267e8863bb5c971fb1c17a81d/nixos/modules/services/x11/desktop-managers/gnome.nix#L389

If I understand well here https://github.com/NixOS/nixpkgs/commit/50c6895e772b76a9bb5d7be7158a60ea1fb02bea , it has not been enable in 23.11 but will be in 24.05, isn't it? That would explain why I faced the issue and opened this PR. Because currently, if I install nixos Gnome ISO and install firefox thanks to programs.firefox.enable = true; only, it doesn't work. I need to install it like that in 23;11 to have it working properly :

  programs.firefox = {
    enable = true;
    package = pkgs.firefox;
    nativeMessagingHosts.packages = with pkgs; [
      browserpass
    ];
  };

If it will be done in 24.05, I would recommend to keep the issue opened till 24.05 get released then.

I would not recommend installing GNOME Shell extensions from extension.gnome.org since some extensions require patching, which is only available in Nixpkgs.

OK