Troubleshooting a custom GDM session

Hi,

I’m very new to NixOS, so I might be doing something very wrong or I probably don’t understand something, but I have problems with adding a custom session to GDM.

I use i3, but I never liked configuring all the details myself (like lock, display settings etc), so I was using gnome-flashback with i3 on top of it. As far as I’m aware there’s no such option for NixOS, so I’m trying to set it up myself.

I’ve looked into how other window managers are set up and I added a following option:

  # Configure i3 + gnome:
  services.xserver.windowManager.session = [{
    name = "i3 + gnome";
    start = ''
      echo "executed code from nixos configuration" >> /tmp/xsession.log
      /bin/i3-gnome-flashback-session
      waitPID=$!
    '';
  }];

A new option is visible in the GDM menu, but choosing it returns to the login screen. At first I thought it’s a problem with i3-gnome-flashback-session script, but it seems that it doesn’t even execute the echo line.

Any ideas on how to further debug it or fix it?

Actually, there is a NixOS module for gnome-flashback if you search in the NixOS options here
To set it up you would do something like this in your configuration.nix

services.xserver = {
  enable = true;
  displayManager.gdm.enable = true;
  desktopManager.gnome3 = {
    enable = true;
    flashback.customSessions = [
        {
          wmCommand = "${pkgs.i3}/bin/i3";
          wmLabel = "Gnome3 + i3";
          wmName = "gnome3-i3";
        }
    ];
  };
};

Thanks, that actually works!

It has too much components there, unfortunately, ie. a top and bottom bars from gnome. I suppose that if components are defined as a variable here I can’t configure it easily. For now I’ll try to add it as my own package, but maybe it’s a good thing to get a first contribution :slight_smile:

yeah, I do a similar thing where I have a custom kdeslim.nix file so I can run some plasma5 components on i3 but not the whole thing and then I just import through my configs.
Similarly you could also just override the package if it’s one small attribute you want to change, but I’m guessing for this situation writing something else would be cleaner.

I wasn’t aware of overriding packages and indeed it seems like it might be a quicker option (also considering that I have little experience with nix packages), but I can’t make it work anyway.

I tried a following config and it fails on GDM login:

  nixpkgs.config = {
    packageOverrides = pkgs: {
      gnome-flashback = (pkgs.gnome-flashback.override {
        requiredComponents = "RequiredComponents=gnome3-i3;gnome-flashback;org.gnome.SettingsDaemon.A11ySettings;org.gnome.SettingsDaemon.Color;org.gnome.SettingsDaemon.Datetime;org.gnome.SettingsDaemon.Housekeeping;org.gnome.SettingsDaemon.Keyboard;org.gnome.SettingsDaemon.MediaKeys;org.gnome.SettingsDaemon.Power;org.gnome.SettingsDaemon.PrintNotifications;org.gnome.SettingsDaemon.Rfkill;org.gnome.SettingsDaemon.ScreensaverProxy;org.gnome.SettingsDaemon.Sharing;org.gnome.SettingsDaemon.Smartcard;org.gnome.SettingsDaemon.Sound;org.gnome.SettingsDaemon.Wacom;org.gnome.SettingsDaemon.XSettings;";
      });
    };
  };

  services.xserver.desktopManager.gnome3 = {
    enable = true;
    flashback.customSessions = [
        {
          wmCommand = "${pkgs.i3}/bin/i3";
          wmLabel = "Gnome3 + i3";
          wmName = "gnome3-i3";
        }
    ];
  };

Yeah that’s basically it but one small thing, you should be using the overrideAttrs function here not override. The difference is documented here but basically overrides can change the value of the inputs at the top between the curly braces and overrideAttrs can override the attributes inside the expression or function itself
Have not tested this but maybe this works I think.

nixpkgs.config = {
  packageOverrides = pkgs: {
    gnome3.gnome-flashback = pkgs.gnome3.gnome-flashback.overrideAttrs ( oldattrs: {
      requiredComponents = "RequiredComponents=gnome3-i3;gnome-flashback;org.gnome.SettingsDaemon.A11ySettings;org.gnome.SettingsDaemon.Color;org.gnome.SettingsDaemon.Datetime;org.gnome.SettingsDaemon.Housekeeping;org.gnome.SettingsDaemon.Keyboard;org.gnome.SettingsDaemon.MediaKeys;org.gnome.SettingsDaemon.Power;org.gnome.SettingsDaemon.PrintNotifications;org.gnome.SettingsDaemon.Rfkill;org.gnome.SettingsDaemon.ScreensaverProxy;org.gnome.SettingsDaemon.Sharing;org.gnome.SettingsDaemon.Smartcard;org.gnome.SettingsDaemon.Sound;org.gnome.SettingsDaemon.Wacom;org.gnome.SettingsDaemon.XSettings;";
    });
  };
};

Also the attribute name for the gnome-flashback package is gnome3.gnome-flashback. You can find attributes using the cli command nix search or this webpage
To understand overrides better I recommend you read the manual and watch the NixCon video about it

requiredComponents is not an attribute so it is not possible to override it. It would be better to change the module so that we can customize the required components similarly to how it is done here: gnome-flashback: add option to replace gnome-screensaver with xscreensaver by chpatrick · Pull Request #76540 · NixOS/nixpkgs · GitHub

NixOs supports xfce+i3 out of the box: Xfce - NixOS Wiki

This might be a good replacement for gnome-flashback if it turns out too complicated to make it work.

Thanks for additional comments. I will definitely read more about nix before doing more modifications and I’ll try to send a patch to allow to configure required components. In the meantime I will just leave with the gnome-panel being there, but if I have time to create a working config, I’ll post it here.