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