Help! I cant have Pantheon, Gnome and Plasma installed on my system at the same time

Hi there I installed nixos with Pantheon and then later decided I also want Gnome and Plasma so I added it to configuration.nix

  # Enable the Pantheon Desktop Environment.
  services.xserver.displayManager.lightdm.enable = true;
  services.xserver.desktopManager.pantheon.enable = true;

  services.xserver.displayManager.gdm.enable = false;
  services.xserver.desktopManager.gnome.enable = true;

  services.displayManager.sddm.enable = false;
  services.desktopManager.plasma6.enable = true;

however when i run sudo nixos-rebuild switch t gives errors:

[titus@nixos:~]$ sudo nixos-rebuild switch
building Nix...
building the system configuration...
error:
       … while calling the 'head' builtin

         at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:1575:11:

         1574|         || pred here (elemAt values 1) (head values) then
         1575|           head values
             |           ^
         1576|         else

       … while evaluating the attribute 'value'

         at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:809:9:

          808|     in warnDeprecation opt //
          809|       { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          810|         inherit (res.defsFinal') highestPrio;

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: The option `services.displayManager.defaultSession' has conflicting definition values:
       - In `/nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/services/x11/desktop-managers/pantheon.nix': "pantheon"
       - In `/nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/services/desktop-managers/plasma6.nix': "plasma"
       Use `lib.mkForce value` or `lib.mkDefault value` to change the priority on any of these definitions.

Does anyone know how to fix this?

1 Like

You should disable one of them. (pantheon/plasma6) (AFAIK)

You can solve this using NixOS specialisations.

@Solene blogged about this:

Ugh. Looks like it is worse nowadays. Previously, it was just the NIX_GSETTINGS_OVERRIDES_DIR variable, which I have on my to-do list to eventually remove in favour of using the new dconf module. Now it is also defaultSession, which DE modules should not really set and ssh-askpass.

As the error says, you can use lib.mkForce the resolve the conflict. You can choose a value from one of the mentioned modules.

For example, to use GSettings settings (NIX_GSETTINGS_OVERRIDES_DIR) from GNOME, copy the following and wrap the value with lib.mkForce:

In this case, it refers to some variables so you will need to copy them as well:

  environment.sessionVariables.NIX_GSETTINGS_OVERRIDES_DIR =
    let
      cfg = config.services.xserver.desktopManager.gnome;
      nixos-background-light = pkgs.nixos-artwork.wallpapers.simple-blue;
      nixos-background-dark = pkgs.nixos-artwork.wallpapers.simple-dark-gray;
      flashbackEnabled = cfg.flashback.enableMetacity || lib.length cfg.flashback.customSessions > 0;
      nixos-gsettings-desktop-schemas = pkgs.gnome.nixos-gsettings-overrides.override {
        inherit (cfg) extraGSettingsOverrides extraGSettingsOverridePackages favoriteAppsOverride;
        inherit flashbackEnabled nixos-background-dark nixos-background-light;
      };
    in
    lib.mkForce (pkgs.glib.getSchemaPath nixos-gsettings-desktop-schemas);

You will need the same for ssh.askPassword, Have gnome & plasma at the same time? - #2 by BatteredBunny

If you do not use auto-login, you can also set defaultSession to null, which will make DM pre-select the last used session:

services.displayManager.defaultSession = lib.mkForce null;
1 Like

Yeah the issue of different desktop environments overiding configurations led me away from nixOS for a while but I heard its gotten better now so I reinstalled nixOS. Thank you for the solution :slight_smile: I will now try it out

Hi @jtojnar Thank you so much!, I tried your solution and It was this :pinching_hand: close to working! One small issue after I nixos-rebuild switch your solution at the end of the output this error appears:

ln: failed to create symbolic link '/nix/store/9mkpxwnwf99yrir14q71x37r0kmggvpp-user-units/xdg-desktop-portal-gtk.service': File exists
error: builder for '/nix/store/08xh5qr3dgs6byrcmw7rzzx4mpk4i9qy-user-units.drv' failed with exit code 1
error: 1 dependencies of derivation '/nix/store/f5c0gj34zkw1fzi95yrvwpni3104x473-etc.drv' failed to build
error: 1 dependencies of derivation '/nix/store/v3mirdj5r2dg00hsm1w27qzqxsxsfqi5-nixos-system-nixos-24.05.984.0b8e7a1ae5a9.drv' failed to build

Which I recall from my last crack at nixOS 3 months ago as being an issue that prevents any more generations of a system.

Do you know how to fix this?

I tried running sudo rm -rf /nix/store/9mkpxwnwf99yrir14q71x37r0kmggvpp-user-units/xdg-desktop-portal-gtk.service

But It said it was a read only file system, which is bizarre cause I thought sudo priveleges let you delete anything