Remove some optional packages in Gnome3 under NixOS

The GNOME3 desktop comes with a number of optional applications, some of them I don’t need. In the default.nix file for GNOME3, these applications are listed in the optionalPackages variable. How can I install GNOME3 without some of these applications under NixOS? I suppose I need to build a cusmom derivation in my configuration.nix file but how do I do this exactly?

1 Like

You can list the packages you do not want as follows in your
configuration.nix

environment.gnome3.excludePackages = [ pkgs.gnome3.gnome-weather 
pkgs.gnome3.simple-scan ];

you can even disable all optional packages

environment.gnome3.excludePackages = pkgs.gnome3.optionalPackages;

and add the ones you need explicitly to environment.systemPackages.

5 Likes

Thanks a lot!

I’ve disabled all optional packages and added some explicitly in environment.systemPackages as you suggested. Oddly, GNOME Documents and 'Books` apps are still installed, but otherwise, it does the trick.

1 Like

Documents (Books) require a DBus service so they are installed using a NixOS module:

https://github.com/NixOS/nixpkgs/blob/73d348c8eb161984e69e8755ea798dfce83324fe/nixos/modules/services/x11/desktop-managers/gnome3.nix#L107

You can uninstall them by adding the following to your configuration.nix:


services.gnome3.gnome-documents.enable = false;

You may also be interested in https://github.com/NixOS/nixpkgs/issues/10241