Gnome broken since I tried to use i3 (unsuccessfully)

Hi! I’m not sure if it’s the good place to ask my question. I apologize because I don’t have a lot of information right now, I tried to investigate, but I really don’t know where to start! :confused:

Few days ago I tried to migrate to i3, and I get difficulties to make it work. Actually, I didn’t success. I simply followed the documentation from the wiki here and it just or crashed on load, or got trouble with X11. Note that the command nix-shell -p j4-dmenu-desktop --run i3-dmenu-desktop works well. :thinking:

I’m still a noob with nix, so I just went back to gnome, I checkout the previous configuration and now, I have that kind of bugs:

  • Need to retry to load gnome several times when I start the session
  • Reload firefox twice or I get black screen
  • Gnome take time to initialize

As I said, I’m a noob and I don’t even know how to check logs. I’m limiting myself to the configuration.nix until I read several documentation about nix. I would appreciate a diagnosis of what’s happening now with gnome, or anything I did wrong. :pray:

Ask me if I can do anything to help to diagnose.

Additional information: I’m on the unstable channel.

{ config, pkgs, ... }:
{
  imports =
    [ # Include the results of the hardware scan.
      ./hardware-configuration.nix
    ];

  # Use the systemd-boot EFI boot loader.
  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;

  networking.hostName = "adrien"; # Define your hostname.
  # networking.wireless.enable = true;  # Enables wireless support via wpa_supplicant.

  # Set your time zone.
  time.timeZone = "Europe/Madrid";

  # The global useDHCP flag is deprecated, therefore explicitly set to false here.
  # Per-interface useDHCP will be mandatory in the future, so this generated config
  # replicates the default behaviour.
  networking.useDHCP = false;
  networking.interfaces.wlp0s20f3.useDHCP = true;

  nixpkgs.config.allowUnfree = true;

  # Configure network proxy if necessary
  # networking.proxy.default = "http://user:password@proxy:port/";
  # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";

  # Select internationalisation properties.
  i18n.defaultLocale = "fr_FR.UTF-8";
  console = {
    font = "Lat2-Terminus16";
    keyMap = "fr";
  };

  # Enable the X11 windowing system.
  services.xserver.enable = true;

  # To use Flatpak you must enable XDG Desktop Portals with xdg.portal.enable.
  xdg.portal.enable = true;
  services.flatpak.enable = true;

  # Enable the GNOME Desktop Environment.
  services.xserver.displayManager.gdm.enable = true;
  # todo Enable i3 Desktop Environment too
  services.xserver = {
    desktopManager = {
      gnome.enable = true;
    };
    #windowManager.i3 = {
    #  enable = true;
    #  extraPackages = with pkgs; [
    #    dmenu #application launcher most people use
    #    i3status # gives you the default i3 status bar
    #    i3lock #default i3 screen locker
    #    i3blocks #if you are planning on using i3blocks over i3status
    # ];
    #};
  };

  # Configure keymap in X11
  services.xserver.layout = "fr";
  services.xserver.xkbOptions = "eurosign:e";

  # Enable CUPS to print documents.
  # services.printing.enable = true;

  # Enable sound.
  sound.enable = true;
  hardware.pulseaudio.enable = true;

  # Enable touchpad support (enabled default in most desktopManager).
  services.xserver.libinput.enable = true;

  # Define a user account. Don't forget to set a password with ‘passwd’.
  # uncomment to get docker
  # virtualisation.docker.enable = true;
  users.users.adrien = {
    isNormalUser = true;
    extraGroups = [ "wheel" "docker" ]; # Enable ‘sudo’ for the user.
  };

  # List packages installed in system profile. To search, run:
  # $ nix search wget
  environment.systemPackages = with pkgs; [
    # wget
    firefox
    rustup
    cmake
    pkg-config
    openssl
    bintools-unwrapped
    discord
    git
    powertop acpi
    direnv nix-direnv
    gnupg1 # in user you may want to `add default-cache-ttl 3600` in ~/.gnupg/gpg-agent.conf
    pinentry # Don't forget to add the line bellow
    pinentry-curses
    protobuf # Needed by tokio-console-subscriber

    nodejs
    yarn

    gnumake
    gcc
  ];

  programs.neovim = {
    enable = true;
    configure = {
      plug.plugins = with pkgs.vimPlugins; [
        vim-nix
        nerdtree
        vim-monokai
        vim-markdown
      ];

      customRC = ''
        syntax on
        colorscheme monokai
        set number
        set relativenumber
        autocmd BufWritePre * %s/\s\+$//e
      '';
    };
    viAlias = true;
    # configure.customRC = builtins.readFile /home/adrien/.config/nvim/init.vim;
  };

  environment = {
    sessionVariables = rec {
      RUST_BACKTRACE = "1";
      PKG_CONFIG_PATH = "${pkgs.openssl.dev}/lib/pkgconfig";
      RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
    };
    pathsToLink = [
      "/share/nix-direnv"
    ];
  };

  # To use correctly gpg, in the user you should have:
  # $ cat ~/.gnupg/gpg-agent.conf
  # pinentry-program /run/current-system/sw/bin/pinentry
 
  services.pcscd.enable = true;
  programs.gnupg.agent = {
    enable = true;
    pinentryFlavor = "curses";
    enableSSHSupport = true;
  };

  # nix options for derivations to persist garbage collection
  nix.extraOptions = ''
    keep-outputs = true
    keep-derivations = true
  '';
  # if you also want support for flakes (this makes nix-direnv use the
  # unstable version of nix):
  nixpkgs.overlays = [
    (self: super: { nix-direnv = super.nix-direnv.override { enableFlakes = true; }; } )
  ];

  documentation.dev.enable = true;
  environment.extraOutputsToInstall = [ "info" "man" "devman" ];

  users.defaultUserShell = pkgs.zsh;
  programs.zsh = {
    enable = true;
    enableCompletion = true;
    autosuggestions.enable = true;
    promptInit = ''
      source ${pkgs.grml-zsh-config}/etc/zsh/zshrc
    '';
  };


  # Auto upgrade the system =-)
  system.autoUpgrade.enable = true;

  # Do the garbage collection & optimisation weekly.
  nix.gc = {
    automatic = true;
    dates = "weekly";
    options = "--delete-older-than 30d";
  };

  nix.optimise.automatic = true;

  # Open ports in the firewall.
  networking.firewall.allowedTCPPorts = [ 22 ];
  networking.firewall.allowedUDPPorts = [ ];

  networking.nameservers = [
    "2a07:a8c0::85:4ac4"
    "2a07:a8c1::85:4ac4"
    "45.90.28.69"
    "45.90.30.69"
  ]; # NextDNS

  # Enable the OpenSSH daemon.
  services.openssh.enable = true;

  # Power management
  powerManagement.enable = true;
  services.upower.enable = true;
  services.thermald.enable = true;
  services.tlp.enable = true;
  services.power-profiles-daemon.enable = false;

  # This value determines the NixOS release from which the default
  # settings for stateful data, like file locations and database versions
  # on your system were taken. It‘s perfectly fine and recommended to leave
  # this value at the release version of the first install of this system.
  # Before changing this value read the documentation for this option
  # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
  system.stateVersion = "21.11"; # Did you read the comment?

}

Thanks everyone!

Given the symptoms I’d maybe suspect some GPU issue. Gnome uses the GPU and I’m guessing i3 doesn’t? Either way, what graphics card do you have?

I’d also check journalctl and see what relevant log entries there are when you have these issues.

1 Like

Thank you for the response!

I checked the journal and I found an error that I can reproduce easily, but difficult to understand :thinking:
For the readability, I truncate the start of each line in the trace, it was:

mai 12 08:44:08 adrien /nix/store/855dn1bi3fcsqh5xkqkh29bhb4c2zy97-gdm-42.0/libexec/gdm-x-session[2040]

I have these graphic cards:

  • nVidia GA107M [GeForce RTX 3050 Ti Mobile]
  • ntel TigerLake-H GT1 [UHD Graphics]

Here is the error trace:

  1 : (EE) Backtrace:
  2 : (EE) 0: /nix/store/nl44b4x4bw3l8z1xvm55sjgv81q0gn22-xorg-server-21.1.3/bin/X (OsSigHandler+0x25) [0x5b4015]
  3 : (EE) 1: /nix/store/ybkkrhdwdj227kr20vk8qnzqnmj7a06x-glibc-2.34-115/lib/libc.so.6 (__sigaction+0x40) [0x7f1a7a305100]
  4 : (EE) 2: /nix/store/nl44b4x4bw3l8z1xvm55sjgv81q0gn22-xorg-server-21.1.3/bin/X (InitOutput+0x4e4) [0x4876e4]
  5 : (EE) 3: /nix/store/nl44b4x4bw3l8z1xvm55sjgv81q0gn22-xorg-server-21.1.3/bin/X (dix_main+0x194) [0x448664]
  6 : (EE) 4: /nix/store/ybkkrhdwdj227kr20vk8qnzqnmj7a06x-glibc-2.34-115/lib/libc.so.6 (__libc_start_call_main+0x67) [0x7f1a7a2f11d7]
  7 : (EE) 5: /nix/store/ybkkrhdwdj227kr20vk8qnzqnmj7a06x-glibc-2.34-115/lib/libc.so.6 (__libc_start_main+0x87) [0x7f1a7a2f1297]
  8 : (EE) 6: /nix/store/nl44b4x4bw3l8z1xvm55sjgv81q0gn22-xorg-server-21.1.3/bin/X (_start+0x21) [0x431ca1]
  9 : (EE)
 10 : (EE) Segmentation fault at address 0x71
 11 : (EE)
 12 : Fatal server error:
 13 : (EE) Caught signal 11 (Segmentation fault). Server aborting
 14 : (EE)
 15 : (EE)
 16 : Please consult the The X.Org Foundation support
 17 :          at http://wiki.x.org
 18 :  for help.
 19 : (EE) Please also check the log file at "/dev/null" for additional information.
 20 : (EE)

It looks like what I get when I tried to switch to i3.

Sounds easy, just check the log file at /dev/null :thinking: .

Based on the log output I don’t know what the issue is, but I know hybrid graphics can be a mess. I’d start with disabling the Nvidia card in the BIOS if you can to get that out of the equation for now. Also try disabling the power management stuff for now.

Could also try updating NixOS, using the latest kernel or the opposite, and/or checking nixos-hardware to see if your model of laptop is there.

If still stuck might help to post your hardware-configuration.nix.

That’s probably because it goes to journalctl instead. Excellent wording, though.

What do the logs say when you do successfully login? This segfault seems suspicious indeed, I’d wager that some state was changed imperatively and hasn’t cleaned itself, but perhaps an actual running x server will give a more useful warning.

I’d also be curious about any terminal output from firefox when it black screens.

This recent thread is quite similar, too: Configuring X11 for Gnome.

@austin @TLATER, thank you two, that helped me a lot.

In conclusion, many of my problems (including a battery draining that I didn’t mention before) have been solved using the proprietary driver of nvidia. My laptop is a dell vostro that hasn’t yet an hardware-configuration (I’m working on it). I can’t disable nvidia on it. :expressionless:

Between x11 and wayland and I prefer the second, so I use sway instead of i3 for the moment.

An important thing that really surprised me is that adding sway just solved the problem I had launching gnome. And the brainblowing, is that I couldn’t reproduce my problem after that, even changing back the configuration.

A colleague told me that gnome also use a lot of configs that NixOS don’t manage. So maybe, when I had my problem, adding a new user could have worked too. I’ll never know :smile: you have an opinion?

Now my laptop work well despite the nvidia device.

  services.xserver.videoDrivers = ["nvidia"];
  hardware.nvidia.powerManagement.enable = true;

@TLATER About firefox I tried to look at the logs when a glitch occurred, but I noticed nothing special. :confused:

Very possible, GNOME config is a known weakness of the nixos world. It’s being worked on :slight_smile:

Sadly, yes. Nouveau have been unable to touch the power management for one reason or another, which both means significantly worse performance when more power would be helpful but also significantly worse power usage when less would be helpful.

The recent open sourcing of (large parts of) the nvidia driver might help bridge the gap one day. For the moment, if you’d like a good experience on Linux with a GPU, just stick to AMD or intel.

I’m assuming that’s still happening then? Did you start firefox in a terminal and look at what it outputs or just at journalctl? Either way, sharing those logs can’t hurt.

It does sound like a graphics glitch of some sort, it’d be strange for that to persist after switching to a different driver. Try looking at the output of dmesg too.

Hosted by Flying Circus.