nixos/x11/display-managers: don't touch graphical-session.target in xsession-wrapper#233981
Conversation
|
Looks like this should fix #225605. |
|
Yes, it should. |
|
Pinging everyone who touched all the other DE/WM modules recently for testing: @FedericoSchonborn for Budgie If anyone else knows anyone who's actively using the more obscure sessions, please ping them so they can test too. |
test by:# nix run -v -L
{
inputs.nixpkgs.url = "github:K900/nixpkgs/dont-touch-graphical-session-target";
#inputs.nixpkgs.url = "path:/home/rewine/nur/nixpkgs";
outputs = inputs@{ self, nixpkgs }: let
system = "x86_64-linux";
pkgs = import nixpkgs { inherit system; };
in {
nixosConfigurations.vm = nixpkgs.lib.nixosSystem {
inherit system;
modules = [
{
imports = [ "${nixpkgs}/nixos/modules/virtualisation/qemu-vm.nix" ];
services.xserver = {
enable = true;
displayManager = {
lightdm.enable = true;
autoLogin = {
enable = false;
user = "test";
};
};
desktopManager.deepin.enable = true;
};
users.users.test = {
isNormalUser = true;
uid = 1000;
extraGroups = [ "wheel" "networkmanager" ];
password = "test";
createHome = true;
};
virtualisation = {
qemu.options = [ "-device intel-hda -device hda-duplex" ];
cores = 8;
memorySize = 8192;
diskSize = 16384;
resolution = { x = 1024; y = 768; };
};
system.stateVersion = "23.05";
}];
};
packages.${system}.default = self.nixosConfigurations.vm.config.system.build.vm;
apps.${system}.default = {
type = "app";
program = "${self.packages.${system}.default}/bin/run-nixos-vm";
};
};
} |
|
@OPNA2608 You can test whether this modification affects |
|
FWIW I can personally vouch for this working fine on Plasma, but Plasma is the odd one out here, as it actually uses systemd correctly. |
Lomiri seems to still work fine after this. |
|
well, i tested bspwm and dk (via sddm), both started fine, but auto start via systemd user services is broken, cuz graphical-session.target is not started/reached i don't get purpose of this pr, from my point of view it just breaks things (i just applied this pr as patch to f292b49 commit) |
|
The purpose of this PR is to stop breaking things that actually rely on a graphical session being fully started. Right now every autostart application is basically racing the session setup to determine whether it gets the right environment set up. |
|
We will figure the correct workaround in the future. |
AndersonTorres
left a comment
There was a problem hiding this comment.
Reword the commit as:
Modifying the state of graphical-session.target breaks things that try to run before the target is fully reached. This is wrong behavior and should not happen.
This change affect users of window managers, that will need some sort of a manual workaround.
|
I'd rather just not merge this until a workaround is in place. |
Seeing |
|
The tests do pass, but this may have unexpected side effects that are not caught by the test. |
99cdb3e to
0bc03c7
Compare
|
Updated with a hack to retain the old behavior for non-compliant WMs. Thanks to @hrnz on Matrix for coming up with the XDG_CURRENT_DESKTOP idea. |
|
Tested locally with Plasma and i3 and things work mostly as expected. |
…session-wrapper if the desktop knows how to handle it This is not correct and will in fact break things because they try to run before the target is reached. Ideally we'd get rid of it entirely, but WM users rely on this behavior, so allowlist some desktops to get the sane behavior, and fake the session for the rest until upstreams/NixOS modules catch up.
0bc03c7 to
d26393d
Compare
|
Also added a magic value |
|
@3JlOy-PYCCKUi can you retest if the current workaround works for your setup? |
|
So I just went through and checked the session configs for the most common WMs, and I'm pretty sure we're fine here. |
|
Looks like for GNOME-based DEs, Tested GNOME Shell and the $ systemctl status --user graphical-session.target
● graphical-session.target - Current graphical user session
Loaded: loaded (/etc/systemd/user/graphical-session.target; static)
Active: active since Sat 2023-07-08 14:25:58 UTC; 25s ago
Docs: man:systemd.special(7)
Jul 08 14:25:58 nixos systemd[1340]: Reached target Current graphical user session.However, in GNOME Flashback ( $ systemctl status --user graphical-session.target
○ graphical-session.target - Current graphical user session
Loaded: loaded (/etc/systemd/user/graphical-session.target; static)
Active: inactive (dead)
Docs: man:systemd.special(7)cc @chpatrick VM configuration{ pkgs, lib, config, ... }:
{
environment.systemPackages = with pkgs; [
gdb
];
environment.enableDebugInfo = true;
services.xserver = {
enable = true;
displayManager.defaultSession = "gnome-flashback-metacity";
displayManager.gdm = {
enable = true;
};
desktopManager.gnome = {
flashback.enableMetacity = true;
};
};
services.openssh.enable = true;
systemd.coredump.extraConfig = ''
Storage=external
'';
users.extraUsers.jtojnar = {
isNormalUser = true;
uid = 1000;
extraGroups = [ "wheel" "networkmanager" ];
password = "";
openssh.authorizedKeys.keys = [ "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDYbOlZydfRRCGCT08wdtPcpfSrgxMc6weDx3NcWrnMpVgxnMs3HozzkaS/hbcZUocn7XbCOyaxEd1O8Fuaw4JXpUBcMetpPXkQC+bZHQ3YsZZyzVgCXFPRF88QQj0nR7YVE1AeAifjk3TCODstTxit868V1639/TVIi5y5fC0/VbYG2Lt4AadNH67bRv8YiO3iTsHQoZPKD1nxA7yANHCuw38bGTHRhsxeVD+72ThbsYSZeA9dBrzACpEdnwyXclaoyIOnKdN224tu4+4ytgH/vH/uoUfL8SmzzIDvwZ4Ba2yHhZHs5iwsVjTvLe7jjE6I1u8qY7X8ofnanfNcsmz/ jtojnar@kaiser" ];
};
imports = [ <nixpkgs/nixos/modules/virtualisation/qemu-vm.nix> ];
virtualisation.memorySize = 3 * 2048;
virtualisation.diskSize = 28048;
virtualisation.qemu.options = [ "-device intel-hda" "-device hda-duplex" ];
virtualisation.forwardPorts = [
# forward local port 2222 -> 22, to ssh into the VM
{ from = "host"; host.port = 2222; guest.port = 22; }
];
systemd.user.services.test-g-s-t = {
description = "test-g-s-t";
wantedBy = [ "graphical-session.target" ];
partOf = [ "graphical-session.target" ];
serviceConfig.ExecStart = "${pkgs.bash}/bin/sh -c 'while true; do echo running in graphical-session; sleep 5; done'";
};
}I would also expect it to work in Pantheon if I add it to the list but it does not appear to. --- a/nixos/modules/services/x11/display-managers/default.nix
+++ b/nixos/modules/services/x11/display-managers/default.nix
@@ -40,7 +40,7 @@ let
IFS=:
for i in $XDG_CURRENT_DESKTOP; do
case $i in
- KDE|GNOME|X-NIXOS-SYSTEMD-AWARE) echo "1"; exit; ;;
+ KDE|GNOME|Pantheon|X-NIXOS-SYSTEMD-AWARE) echo "1"; exit; ;;
*) ;;
esac
done |
|
I thought Pantheon used gnome-session? |
|
Oh, we do not actually use systemd code path for Budgie, Pantheon and GNOME Flashback yet, only for GNOME Shell: #228946 |
| fakeSession = action: '' | ||
| session_is_systemd_aware=$( | ||
| IFS=: | ||
| for i in $XDG_CURRENT_DESKTOP; do | ||
| case $i in | ||
| KDE|GNOME|X-NIXOS-SYSTEMD-AWARE) echo "1"; exit; ;; | ||
| *) ;; | ||
| esac | ||
| done | ||
| ) | ||
|
|
||
| if [ -z "$session_is_systemd_aware" ]; then | ||
| /run/current-system/systemd/bin/systemctl --user ${action} nixos-fake-graphical-session.target | ||
| fi | ||
| ''; |
There was a problem hiding this comment.
Wouldn't it be more nixos like if this was an option and sessions know to support it turn it off?
There was a problem hiding this comment.
We can't really do that because the same wrapper is used for all sessions, so we have to resort to runtime dispatch.
It looks like nixosTests.gnome-flashback is now failing 👀 |
|
I think this might be #228946 ? |
|
Ah yeah, I was confused why the Pantheon test passed while not systemd managed but later found it does not have So I think the budgie test should be failing with same reason, which has Edit: #246743 |
|
I'm not sure if still needed, but I tested stumpwm like this: In one terminal: In another terminal: And it started. |
|
Cute :3 |

This is not correct and will in fact break things because they try to run before the target is reached.
WMs users may need some sort of a manual workaround for this...
Description of changes
Things done
sandbox = trueset innix.conf? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)