From 660882d8830153422a79d6cbea45f2dbe272cf21 Mon Sep 17 00:00:00 2001 From: Even Brenden Date: Fri, 24 Jul 2020 13:41:24 +0200 Subject: nixos/displayManager: add XDG_SESSION_ID to systemd user environment xss-lock needs XDG_SESSION_ID to respond to loginctl lock-session(s) (and possibly other session operations such as idle hint management). This change adds XDG_SESSION_ID to the list of imported environment variables when starting systemctl. Inspired by home-manager, add importVariables configuration. Set session to XDG_SESSION_ID when running xss-lock as a service. Co-authored-by: misuzu --- .../services/x11/display-managers/default.nix | 31 +++++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) (limited to 'nixos/modules/services/x11/display-managers/default.nix') diff --git a/nixos/modules/services/x11/display-managers/default.nix b/nixos/modules/services/x11/display-managers/default.nix index aa6a5ec42be..2fda88a8d97 100644 --- a/nixos/modules/services/x11/display-managers/default.nix +++ b/nixos/modules/services/x11/display-managers/default.nix @@ -55,13 +55,6 @@ let exec &> >(tee ~/.xsession-errors) ''} - # Tell systemd about our $DISPLAY and $XAUTHORITY. - # This is needed by the ssh-agent unit. - # - # Also tell systemd about the dbus session bus address. - # This is required by user units using the session bus. - /run/current-system/systemd/bin/systemctl --user import-environment DISPLAY XAUTHORITY DBUS_SESSION_BUS_ADDRESS - # Load X defaults. This should probably be safe on wayland too. ${xorg.xrdb}/bin/xrdb -merge ${xresourcesXft} if test -e ~/.Xresources; then @@ -70,6 +63,12 @@ let ${xorg.xrdb}/bin/xrdb -merge ~/.Xdefaults fi + # Import environment variables into the systemd user environment. + ${optionalString (cfg.displayManager.importedVariables != []) ( + "/run/current-system/systemd/bin/systemctl --user import-environment " + + toString (unique cfg.displayManager.importedVariables) + )} + # Speed up application start by 50-150ms according to # http://kdemonkey.blogspot.nl/2008/04/magic-trick.html rm -rf "$HOME/.compose-cache" @@ -289,6 +288,14 @@ in ''; }; + importedVariables = mkOption { + type = types.listOf (types.strMatching "[a-zA-Z_][a-zA-Z0-9_]*"); + visible = false; + description = '' + Environment variables to import into the systemd user environment. + ''; + }; + job = { preStart = mkOption { @@ -360,6 +367,16 @@ in services.xserver.displayManager.xserverBin = "${xorg.xorgserver.out}/bin/X"; + services.xserver.displayManager.importedVariables = [ + # This is required by user units using the session bus. + "DBUS_SESSION_BUS_ADDRESS" + # These are needed by the ssh-agent unit. + "DISPLAY" + "XAUTHORITY" + # This is required to specify session within user units (e.g. loginctl lock-session). + "XDG_SESSION_ID" + ]; + systemd.user.targets.graphical-session = { unitConfig = { RefuseManualStart = false; -- cgit 1.4.1 From f292a27f442d10de4827800d064a3a8c64d05cee Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 6 Sep 2020 22:57:54 +0200 Subject: nixos/dbus: always use socket activates user session This removes the `services.dbus.socketActivated` and `services.xserver.startDbusSession` options. Instead the user D-Bus session is always socket activated. --- nixos/doc/manual/release-notes/rl-2103.xml | 10 +++++++++- nixos/modules/services/system/dbus.nix | 16 +++++++--------- nixos/modules/services/x11/display-managers/default.nix | 7 ------- nixos/modules/services/x11/xserver.nix | 11 +++-------- 4 files changed, 19 insertions(+), 25 deletions(-) (limited to 'nixos/modules/services/x11/display-managers/default.nix') diff --git a/nixos/doc/manual/release-notes/rl-2103.xml b/nixos/doc/manual/release-notes/rl-2103.xml index eccf2b69dad..c05d74ee728 100644 --- a/nixos/doc/manual/release-notes/rl-2103.xml +++ b/nixos/doc/manual/release-notes/rl-2103.xml @@ -59,7 +59,15 @@ - + + If the services.dbus module is enabled, then + the user D-Bus session is now always socket activated. The + associated options services.dbus.socketActivated + and services.xserver.startDbusSession have + therefore been removed and you will receive a warning if + they are present in your configuration. This change makes the + user D-Bus session available also for non-graphical logins. + diff --git a/nixos/modules/services/system/dbus.nix b/nixos/modules/services/system/dbus.nix index 4a60fec1ca8..d9dd26f0f18 100644 --- a/nixos/modules/services/system/dbus.nix +++ b/nixos/modules/services/system/dbus.nix @@ -19,6 +19,12 @@ in { + imports = [ + (mkRemovedOptionModule + [ "services" "dbus" "socketActivated" ] + "The user D-Bus session is now always socket activated and this option can safely be removed.") + ]; + ###### interface options = { @@ -51,14 +57,6 @@ in pkg/share/dbus-1/services ''; }; - - socketActivated = mkOption { - type = types.bool; - default = false; - description = '' - Make the user instance socket activated. - ''; - }; }; }; @@ -108,7 +106,7 @@ in reloadIfChanged = true; restartTriggers = [ configDir ]; }; - sockets.dbus.wantedBy = mkIf cfg.socketActivated [ "sockets.target" ]; + sockets.dbus.wantedBy = [ "sockets.target" ]; }; environment.pathsToLink = [ "/etc/dbus-1" "/share/dbus-1" ]; diff --git a/nixos/modules/services/x11/display-managers/default.nix b/nixos/modules/services/x11/display-managers/default.nix index 08ce8edd661..568aeaceef7 100644 --- a/nixos/modules/services/x11/display-managers/default.nix +++ b/nixos/modules/services/x11/display-managers/default.nix @@ -37,13 +37,6 @@ let . /etc/profile cd "$HOME" - ${optionalString cfg.startDbusSession '' - if test -z "$DBUS_SESSION_BUS_ADDRESS"; then - /run/current-system/systemd/bin/systemctl --user start dbus.socket - export `/run/current-system/systemd/bin/systemctl --user show-environment | grep '^DBUS_SESSION_BUS_ADDRESS'` - fi - ''} - ${optionalString cfg.displayManager.job.logToJournal '' if [ -z "$_DID_SYSTEMD_CAT" ]; then export _DID_SYSTEMD_CAT=1 diff --git a/nixos/modules/services/x11/xserver.nix b/nixos/modules/services/x11/xserver.nix index 400173745d3..914063842c9 100644 --- a/nixos/modules/services/x11/xserver.nix +++ b/nixos/modules/services/x11/xserver.nix @@ -151,6 +151,9 @@ in ./desktop-managers/default.nix (mkRemovedOptionModule [ "services" "xserver" "startGnuPGAgent" ] "See the 16.09 release notes for more information.") + (mkRemovedOptionModule + [ "services" "xserver" "startDbusSession" ] + "The user D-Bus session is now always socket activated and this option can safely be removed.") ]; @@ -296,14 +299,6 @@ in description = "DPI resolution to use for X server."; }; - startDbusSession = mkOption { - type = types.bool; - default = true; - description = '' - Whether to start a new DBus session when you log in with dbus-launch. - ''; - }; - updateDbusEnvironment = mkOption { type = types.bool; default = false; -- cgit 1.4.1 From 3cd2b59b8c261e927977b99c382a2c3067449883 Mon Sep 17 00:00:00 2001 From: WORLDofPEACE Date: Fri, 9 Oct 2020 18:38:16 -0400 Subject: nixos/display-managers: install sessionData.desktops Fixes https://github.com/NixOS/nixpkgs/issues/100108 --- nixos/modules/services/x11/display-managers/default.nix | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'nixos/modules/services/x11/display-managers/default.nix') diff --git a/nixos/modules/services/x11/display-managers/default.nix b/nixos/modules/services/x11/display-managers/default.nix index 08ce8edd661..8ac7a9e66c6 100644 --- a/nixos/modules/services/x11/display-managers/default.nix +++ b/nixos/modules/services/x11/display-managers/default.nix @@ -481,6 +481,13 @@ in ) [dms wms] ); + + # Make xsessions and wayland sessions installed at + # /run/current-system/sw/share as some programs + # have behavior that depends on them being installed + environment.systemPackages = [ + cfg.displayManager.sessionData.desktops + ]; }; imports = [ -- cgit 1.4.1 From 2a4607f44222a92b8a44e6e1dac715e7eca04239 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Thu, 15 Oct 2020 07:28:10 +0200 Subject: Revert "nixos/display-managers: install sessionData.desktops" This reverts commit 3cd2b59b8c261e927977b99c382a2c3067449883. It created infinite recursion when using LXQt, since lxqt module uses `config.system.path` in `services.xserver.desktopManager.session`. `config.system.path` is a `buildEnv` that depends on `environment.systemPackages`. --- nixos/modules/services/x11/display-managers/default.nix | 7 ------- 1 file changed, 7 deletions(-) (limited to 'nixos/modules/services/x11/display-managers/default.nix') diff --git a/nixos/modules/services/x11/display-managers/default.nix b/nixos/modules/services/x11/display-managers/default.nix index ed9c652fc4c..568aeaceef7 100644 --- a/nixos/modules/services/x11/display-managers/default.nix +++ b/nixos/modules/services/x11/display-managers/default.nix @@ -474,13 +474,6 @@ in ) [dms wms] ); - - # Make xsessions and wayland sessions installed at - # /run/current-system/sw/share as some programs - # have behavior that depends on them being installed - environment.systemPackages = [ - cfg.displayManager.sessionData.desktops - ]; }; imports = [ -- cgit 1.4.1 From 755ba171c7ed60031481d1c30b1daf0389a68317 Mon Sep 17 00:00:00 2001 From: WORLDofPEACE Date: Wed, 21 Oct 2020 14:38:37 -0400 Subject: nixos/display-managers: add sessionData.desktops to XDG_DATA_DIRS Fixes #100108 Alternative to https://github.com/NixOS/nixpkgs/pull/100112 which doesn't break stuff. --- nixos/modules/services/x11/display-managers/default.nix | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'nixos/modules/services/x11/display-managers/default.nix') diff --git a/nixos/modules/services/x11/display-managers/default.nix b/nixos/modules/services/x11/display-managers/default.nix index 568aeaceef7..6945a241f92 100644 --- a/nixos/modules/services/x11/display-managers/default.nix +++ b/nixos/modules/services/x11/display-managers/default.nix @@ -474,6 +474,12 @@ in ) [dms wms] ); + + # Make xsessions and wayland sessions available in XDG_DATA_DIRS + # as some programs have behavior that depends on them being present + environment.sessionVariables.XDG_DATA_DIRS = [ + "${cfg.displayManager.sessionData.desktops}/share" + ]; }; imports = [ -- cgit 1.4.1 From 001ba3934e329a457d26c4f45e666b2091c7dd80 Mon Sep 17 00:00:00 2001 From: Jacek Galowicz Date: Thu, 28 Jan 2021 23:03:02 +0100 Subject: Use lib.cartesianProducOfSets where lib.crossLists was used --- nixos/modules/services/x11/display-managers/default.nix | 6 +++--- nixos/tests/predictable-interface-names.nix | 8 ++++++-- pkgs/os-specific/solo5/default.nix | 9 +++++---- 3 files changed, 14 insertions(+), 9 deletions(-) (limited to 'nixos/modules/services/x11/display-managers/default.nix') diff --git a/nixos/modules/services/x11/display-managers/default.nix b/nixos/modules/services/x11/display-managers/default.nix index 6945a241f92..9fdbe753dad 100644 --- a/nixos/modules/services/x11/display-managers/default.nix +++ b/nixos/modules/services/x11/display-managers/default.nix @@ -444,8 +444,8 @@ in in # We will generate every possible pair of WM and DM. concatLists ( - crossLists - (dm: wm: let + builtins.map + ({dm, wm}: let sessionName = "${dm.name}${optionalString (wm.name != "none") ("+" + wm.name)}"; script = xsession dm wm; desktopNames = if dm ? desktopNames @@ -472,7 +472,7 @@ in providedSessions = [ sessionName ]; }) ) - [dms wms] + (cartesianProductOfSets { dm = dms; wm = wms; }) ); # Make xsessions and wayland sessions available in XDG_DATA_DIRS diff --git a/nixos/tests/predictable-interface-names.nix b/nixos/tests/predictable-interface-names.nix index bab091d57ac..c0b472638a1 100644 --- a/nixos/tests/predictable-interface-names.nix +++ b/nixos/tests/predictable-interface-names.nix @@ -5,7 +5,11 @@ let inherit (import ../lib/testing-python.nix { inherit system pkgs; }) makeTest; -in pkgs.lib.listToAttrs (pkgs.lib.crossLists (predictable: withNetworkd: { + testCombinations = pkgs.lib.cartesianProductOfSets { + predictable = [true false]; + withNetworkd = [true false]; + }; +in pkgs.lib.listToAttrs (builtins.map ({ predictable, withNetworkd }: { name = pkgs.lib.optionalString (!predictable) "un" + "predictable" + pkgs.lib.optionalString withNetworkd "Networkd"; value = makeTest { @@ -30,4 +34,4 @@ in pkgs.lib.listToAttrs (pkgs.lib.crossLists (predictable: withNetworkd: { machine.${if predictable then "fail" else "succeed"}("ip link show eth0") ''; }; -}) [[true false] [true false]]) +}) testCombinations) diff --git a/pkgs/os-specific/solo5/default.nix b/pkgs/os-specific/solo5/default.nix index 2dbeca98051..19d1aa3b5eb 100644 --- a/pkgs/os-specific/solo5/default.nix +++ b/pkgs/os-specific/solo5/default.nix @@ -50,10 +50,11 @@ in stdenv.mkDerivation { homepage = "https://github.com/solo5/solo5"; license = licenses.isc; maintainers = [ maintainers.ehmry ]; - platforms = lib.crossLists (arch: os: "${arch}-${os}") [ - [ "aarch64" "x86_64" ] - [ "freebsd" "genode" "linux" "openbsd" ] - ]; + platforms = builtins.map ({arch, os}: "${arch}-${os}") + (cartesianProductOfSets { + arch = [ "aarch64" "x86_64" ]; + os = [ "freebsd" "genode" "linux" "openbsd" ]; + }); }; } -- cgit 1.4.1 From 37460768e229cbaf388b1523b17379b7d397a2f8 Mon Sep 17 00:00:00 2001 From: Stefan Frijters Date: Sun, 9 Aug 2020 23:16:37 +0200 Subject: nixos/x11: Source .xprofile earlier in xsession-wrapper This allows users to set e.g. XCOMPOSECACHE before it's used. --- nixos/modules/services/x11/display-managers/default.nix | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'nixos/modules/services/x11/display-managers/default.nix') diff --git a/nixos/modules/services/x11/display-managers/default.nix b/nixos/modules/services/x11/display-managers/default.nix index 9fdbe753dad..c75dc64d61c 100644 --- a/nixos/modules/services/x11/display-managers/default.nix +++ b/nixos/modules/services/x11/display-managers/default.nix @@ -37,6 +37,11 @@ let . /etc/profile cd "$HOME" + # Allow the user to execute commands at the beginning of the X session. + if test -f ~/.xprofile; then + source ~/.xprofile + fi + ${optionalString cfg.displayManager.job.logToJournal '' if [ -z "$_DID_SYSTEMD_CAT" ]; then export _DID_SYSTEMD_CAT=1 @@ -75,11 +80,6 @@ let ${cfg.displayManager.sessionCommands} - # Allow the user to execute commands at the beginning of the X session. - if test -f ~/.xprofile; then - source ~/.xprofile - fi - # Start systemd user services for graphical sessions /run/current-system/systemd/bin/systemctl --user start graphical-session.target -- cgit 1.4.1 From ee713d36bccc0a98b7c46fc4830ab48bc808c421 Mon Sep 17 00:00:00 2001 From: Stefan Frijters Date: Sun, 9 Aug 2020 23:17:09 +0200 Subject: nixos/x11: Respect XCOMPOSECACHE/XDG_DATA_HOME if set --- nixos/modules/services/x11/display-managers/default.nix | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'nixos/modules/services/x11/display-managers/default.nix') diff --git a/nixos/modules/services/x11/display-managers/default.nix b/nixos/modules/services/x11/display-managers/default.nix index c75dc64d61c..a70a7b6e9b5 100644 --- a/nixos/modules/services/x11/display-managers/default.nix +++ b/nixos/modules/services/x11/display-managers/default.nix @@ -69,12 +69,14 @@ let # Speed up application start by 50-150ms according to # http://kdemonkey.blogspot.nl/2008/04/magic-trick.html - rm -rf "$HOME/.compose-cache" - mkdir "$HOME/.compose-cache" + compose_cache="''${XCOMPOSECACHE:-$HOME/.compose-cache}" + rm -rf "$compose_cache" + mkdir -p "$compose_cache" + unset compose_cache # Work around KDE errors when a user first logs in and # .local/share doesn't exist yet. - mkdir -p "$HOME/.local/share" + mkdir -p "''${XDG_DATA_HOME:-$HOME/.local/share}" unset _DID_SYSTEMD_CAT -- cgit 1.4.1 From 580cf02c1967c6338058862fbe3724b57a559a39 Mon Sep 17 00:00:00 2001 From: Stefan Frijters Date: Thu, 1 Oct 2020 13:13:44 +0200 Subject: nixos/x11: Be more defensive when removing XCOMPOSECACHE --- nixos/modules/services/x11/display-managers/default.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'nixos/modules/services/x11/display-managers/default.nix') diff --git a/nixos/modules/services/x11/display-managers/default.nix b/nixos/modules/services/x11/display-managers/default.nix index a70a7b6e9b5..e04fcdaf414 100644 --- a/nixos/modules/services/x11/display-managers/default.nix +++ b/nixos/modules/services/x11/display-managers/default.nix @@ -70,8 +70,12 @@ let # Speed up application start by 50-150ms according to # http://kdemonkey.blogspot.nl/2008/04/magic-trick.html compose_cache="''${XCOMPOSECACHE:-$HOME/.compose-cache}" - rm -rf "$compose_cache" mkdir -p "$compose_cache" + # To avoid accidentally deleting a wrongly set up XCOMPOSECACHE directory, + # defensively try to delete cache *files* only, following the file format specified in + # https://gitlab.freedesktop.org/xorg/lib/libx11/-/blob/master/modules/im/ximcp/imLcIm.c#L353-358 + # sprintf (*res, "%s/%c%d_%03x_%08x_%08x", dir, _XimGetMyEndian(), XIM_CACHE_VERSION, (unsigned int)sizeof (DefTree), hash, hash2); + ${pkgs.findutils}/bin/find "$compose_cache" -maxdepth 1 -regextype posix-extended -regex '.*/[Bl][0-9]+_[0-9a-f]{3}_[0-9a-f]{8}_[0-9a-f]{8}' -delete unset compose_cache # Work around KDE errors when a user first logs in and -- cgit 1.4.1