NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.87k stars 13.93k forks source link

XDG_RUNTIME_DIR is not set #46826

Closed mkaito closed 6 years ago

mkaito commented 6 years ago

Issue description

After bumping my system from 6993f19098f121bb6ba2199896e5b9bcffd3cb9a to ad755cc59d4af394f35c0245d370a8a915696f65 this morning, several issues cropped up. This is one of them.

XDG_RUNTIME_DIR is unset, which causes systemctl --user to not function (and probably other things, but I haven't noticed any more yet).

❯ systemctl --user status
Failed to read server status: Process org.freedesktop.systemd1 exited with status 1

Steps to reproduce

Rebuild your system on ad755cc59d4af394f35c0245d370a8a915696f65, reboot, then systemctl --user.

Technical details

❯ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 4.18.7, NixOS, 19.03.git.ad755cc (Koi)`
 - multi-user?: `yes`
 - sandbox: `no`
 - version: `nix-env (Nix) 2.1.1`
 - channels(root): `"nixos"`
 - channels(chris): `""`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
urkud commented 6 years ago

After a git pull, I have no revision ad755cc59d4af394f35c0245d370a8a915696f65.

xeji commented 6 years ago

I cannot find any commit ad755cc59d4af394f35c0245d370a8a915696f65 (or anything starting ad755cc) in our repository (and neither can github, or the commits would be linked here). Please verify.

mkaito commented 6 years ago

I'm a derp, that's the merge commit rev of my own fork. I'm so embarrassed now.

Last commit from nixpkgs is 218ce4de508.

xeji commented 6 years ago

Can you reproduce the issue on that nixpkgs commit? We need to rule out that it is caused by something in your fork. (This applies to the other 2 issues as well, I won't copy-paste it again).

xeji commented 6 years ago

I just upgraded my system to 218ce4de508 (including a reboot) and cannot reproduce this.

$ echo $XDG_RUNTIME_DIR
/run/user/1000
mkaito commented 6 years ago

The only difference between 218ce4d and my fork is #38767. Seems odd to me that this would have such profound effects. Let me try.

mkaito commented 6 years ago

Rebuilt, rebooted, all the problems still present. Let me do some bisecting of my config.

mkaito commented 6 years ago

Cleaned out my config, rebuilt to 218ce4d and still have all those issues.

mkaito commented 6 years ago

My entire configuration.nix:

{ config, pkgs, lib, ... }:

{
  imports =
    [ # Include the results of the hardware scan.
      ./hardware-configuration.nix
    ];

  hardware.cpu.amd.updateMicrocode = true;

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

  # Latest kernel
  boot.kernelPackages = pkgs.linuxPackages_latest;

  # Tmpfs stuff
  boot.tmpOnTmpfs = true;

  # Basic networking
  networking.hostName = "cryptbreaker";
  networking.interfaces.enp3s0.ipv4.addresses = [{
    address = "192.168.1.2"; prefixLength = 24;
  }];

  networking.defaultGateway = "192.168.1.1";
  networking.nameservers = [ "1.0.0.1" "8.8.8.8" "8.8.4.4" ];

  # Select internationalisation properties.
  i18n = {
    consoleFont = "Lat2-Terminus16";
    consoleKeyMap = "us";
    defaultLocale = "en_US.UTF-8";
  };

  # Set your time zone.
  time.timeZone = "Atlantic/Canary";

  # List packages installed in system profile. To search by name, run:
  environment.systemPackages = with pkgs; [
    vim pmount ntfs3g libelf
  ];

  security.wrappers = {
    pmount.source = "${pkgs.pmount}/bin/pmount";
    pumount.source = "${pkgs.pmount}/bin/pumount";
  };

  # Some programs need SUID wrappers, can be configured further or are
  # started in user sessions.
  programs.bash.enableCompletion = true;
  programs.gnupg.agent = { enable = true; enableSSHSupport = true; };

  # List services that you want to enable:

  # Enable parallel builds
  nix.buildCores = 0;

  # Disable build sandboxing
  nix.useSandbox = false;

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

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

  services.xserver.dpi = 163;

  # Keyboard config
  services.xserver.layout = "us,es";
  services.xserver.xkbVariant = "basic,basic";
  services.xserver.xkbOptions = "compose:sclk,grp:lctrl_lwin_toggle";

  # Pointer devices
  services.xserver.inputClassSections = [
    ''
      Identifier "ZA11"
      MatchProduct "Kingsis Peripherals ZOWIE Gaming mouse"
      MatchIsPointer "on"
      Option "AccelSpeed" "-0.25"
      Option "AccelProfile" "flat"
    ''

    ''
      Identifier "HUGE"
      MatchProduct "ELECOM TrackBall Mouse HUGE TrackBall"
      MatchIsPointer "on"
      Option "AccelSpeed" "0.2"
      Option "AccelProfile" "flat"
    ''
  ];

  services.xserver.videoDrivers = [ "amdgpu" "modesetting" ];
  services.xserver.libinput.enable = true;
  services.xserver.windowManager.default = "i3";
  services.xserver.displayManager.sddm.enable = true;
  services.xserver.displayManager.sddm.autoLogin.enable = true;
  services.xserver.displayManager.sddm.autoLogin.relogin = false;
  services.xserver.displayManager.sddm.autoLogin.user = "chris";
  services.xserver.desktopManager.xterm.enable = false;
  services.xserver.desktopManager.default = "none";
  services.xserver.windowManager.i3.enable = true;
  services.xserver.windowManager.openbox.enable = true;

  services.xserver.desktopManager.wallpaper = {
    combineScreens = true;
    mode = "fill";
  };

  services.xserver.windowManager.i3.extraSessionCommands = ''
    ## Stop the sreen from turning itself off
    xset -dpms
    xset s off

    ## Set up cut buffer/clipboard sync
    ${pkgs.autocutsel}/bin/autocutsel -selection PRIMARY   -fork &!
    ${pkgs.autocutsel}/bin/autocutsel -selection CLIPBOARD -fork &!

    ## My eyes hurt!
    ${pkgs.redshift}/bin/redshift -l 28:-13 -t 5600:3400 -b 1.00:0.92 -m randr &!

    ## Numlock on
    ${pkgs.numlockx}/bin/numlockx on
  '';

  # Steam
  hardware.opengl.driSupport32Bit = true;
  hardware.pulseaudio.support32Bit = true;

  # Steam Link
  networking.firewall.allowedTCPPorts = [ 27036 27036 ];
  networking.firewall.allowedUDPPorts = [ 27031 27036 ];

  services.udev.packages = [ pkgs.android-udev-rules ];
  services.udev.extraRules = ''
    # Teensy stuff for Ergodox EZ flashing
    ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04[789B]?", ENV{ID_MM_DEVICE_IGNORE}="1"
    ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04[789A]?", ENV{MTP_NO_PROBE}="1"
    SUBSYSTEMS=="usb", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04[789ABCD]?", MODE:="0666"
    KERNEL=="ttyACM*", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04[789B]?", MODE:="0666"

    # Steam Controller
    SUBSYSTEM=="usb", ATTRS{idVendor}=="28de", MODE="0666"
    KERNEL=="uinput", MODE="0660", GROUP="users", OPTIONS+="static_node=uinput"
    KERNEL=="hidraw*", ATTRS{idVendor}=="28de", MODE="0666"
    KERNEL=="hidraw*", KERNELS=="*28DE:*", MODE="0666"
    KERNEL=="hidraw*", ATTRS{idVendor}=="054c", ATTRS{idProduct}=="05c4", MODE="0666"
    KERNEL=="hidraw*", ATTRS{idVendor}=="054c", ATTRS{idProduct}=="0ba0", MODE="0666"
    KERNEL=="hidraw*", ATTRS{idVendor}=="054c", ATTRS{idProduct}=="09cc", MODE="0666"
    KERNEL=="hidraw*", KERNELS=="*054C:05C4*", MODE="0666"
    KERNEL=="hidraw*", KERNELS=="*054C:09CC*", MODE="0666"
    KERNEL=="hidraw*", ATTRS{idVendor}=="057e", ATTRS{idProduct}=="2009", MODE="0666"
    KERNEL=="hidraw*", KERNELS=="*057E:2009*", MODE="0666"
  '';

  # Misc
  services.bitlbee = {
    enable = true;
    plugins = [ pkgs.bitlbee-discord ];
  };

  services.plex = {
    enable = true;
    openFirewall = true;
  };
  users.users.plex.extraGroups = [ "users" ];

  hardware.u2f.enable = true;     # Yubikey hardware access
  services.emacs.enable = true;
  services.haveged.enable = true; # Entropy daemon
  services.pcscd.enable = true;   # Yubikey smartcard interface
  services.urxvtd.enable = true;

  # Profile sync daemon
  services.psd = {
    enable = true;
    users = [ "chris" ];
  };

  # Resilio Sync
  services.resilio = {
    deviceName = "Hydra";
    enable = true;
    enableWebUI = true;
    httpListenAddr = "127.0.0.1";
    useUpnp = true;
  };
  users.extraUsers.rslsync.extraGroups = [ "users" ];

  # Pulseaudio
  hardware.pulseaudio.enable = true;

  ## Fonts
  fonts.fonts = with pkgs; [
    iosevka # Apparently, Iosevka Term is broken
    terminus_font
    fira-code
    fira-code-symbols

    ## Fonts for symbols/emoji/kana/etc
    symbola
    noto-fonts-emoji
    ipafont
  ];

  # Allow unfree packages
  nixpkgs.config.allowUnfree = true;

  users.mutableUsers = false;
  users.extraUsers.chris =
  {
    isNormalUser = true;
    extraGroups = [ "wheel" "networkmanager" "rslsync" "libvirtd" "sway" ];
    hashedPassword = "$6$p4f9brmRq1bmf9U$DC3sUJdRFBzJyL5ZN7zPccsw7nGQlQILykJrNw1tUwWNeBWNL5qxqurfp4bmKuLO.NNDA2Hr8.PfkH3pxDE1H0";
    shell = pkgs.zsh;
    packages = with pkgs; [
      ## Basics
      atool
      bashInteractive
      entr
      ethtool
      fasd
      fd
      file
      fzf
      git
      git-crypt
      gitAndTools.hub
      google-cloud-sdk
      gparted
      hdparm
      htop
      i7z
      inotify-tools
      iperf
      lm_sensors
      neovim
      p7zip
      parted
      pwgen
      ripgrep
      sshfs
      # tarsnap
      tmux
      tree
      unzip
      wget
      xclip
      zip

      # Crypto
      cryptsetup
      gnupg
      gopass
      openssl
      pass
      yubikey-manager
      yubioath-desktop

      ## Desktop
      anki
      conky
      dunst
      galculator
      libnotify
      libreoffice-still
      pinentry
      ranger
      rofi
      rofi-pass
      xdotool
      xorg.xdpyinfo
      xorg.xev
      xorg.xkill
      xorg.xwininfo

      # Performance
      stress-ng
      cpufrequtils
      watch

      ## Web
      deluge
      firefox-beta-bin

      ## Media
      beets
      calibre
      feh
      ffmpeg-full
      gimp
      llpp
      moc
      mpv
      obs-studio
      pandoc
      pavucontrol
      playerctl
      pngquant
      ponymix
      pulsemixer
      scrot
      spotify
      sxiv
      texlive.combined.scheme-full
      youtube-dl

      ## Games
      wineStaging
      (winetricks.override { wine = wineStaging; })

      # (dwarf-fortress.override { enableDFHack = true; })
      (factorio.override { username = "foo"; password = "bar"; })

      # For steam tenfoot session
      steam
      steam-run-native
      tint2

      ## Chat/IM
      weechat
      slack
      discord
      oysttyer

      ## Spelling
      aspell
      aspellDicts.es
      aspellDicts.en

      ## Email
      afew
      alot
      isync
      msmtp
      notmuch
      notmuch-addrlookup
      w3m

      ## Development
      erlang
      tealdeer
      androidsdk
      bind
      clang
      direnv
      elixir
      gist
      gnumake
      jq
      jre
      mkpasswd
      mosh
      ncurses.dev # incocmp/tic/etc
      nmap
      shellcheck
      teensy-loader-cli
      vault

      ## Nix tools
      nix-index
      nix-prefetch-scripts
      nixops
      patchelf
    ];
  };

  # This value determines the NixOS release with which your system is to be
  # compatible, in order to avoid breaking some software such as database
  # servers. You should change this only after NixOS release notes say you
  # should.
  system.stateVersion = "18.03"; # Did you read the comment?

}
xeji commented 6 years ago

The symptoms seem to indicate that something goes wrong during login and session setup. Now this is really just a guess, but can you disable autologin and see if anything changes when you log in manually?

mkaito commented 6 years ago

Yep, that seems to have solved all 3 of my issues. Do you think this is an issue with sddm?

xeji commented 6 years ago

Either that or something in the logind / pam setup that breaks with autologin. Now can you please replace your 3 issues by a single new one that describes all your symptoms in one place and explains what we have found out? Having all information in one place will help us a lot.