From 929d3968adfa0e1184dd691ba20e89090c4efd1b Mon Sep 17 00:00:00 2001 From: Gabriel Arazas Date: Tue, 9 Jan 2024 10:45:43 +0800 Subject: [PATCH] programs/gnome-session: set session systemd user units as part of NixOS While it is nice to have it as part of the desktop session package, we're missing features which requires reimplementing parts of the systemd-lib anyways. We can always have this later once this is upstreamed into nixpkgs where one could modify systemd-lib to split the unit generation step. Right now, not willing to do that. --- .../nixos/programs/gnome-session/default.nix | 8 +++++++- .../nixos/programs/gnome-session/submodules.nix | 17 ----------------- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/modules/nixos/programs/gnome-session/default.nix b/modules/nixos/programs/gnome-session/default.nix index 58c169ae..dbce644e 100644 --- a/modules/nixos/programs/gnome-session/default.nix +++ b/modules/nixos/programs/gnome-session/default.nix @@ -159,6 +159,11 @@ in (_: session: session.sessionPackage) cfg.sessions; + + sessionSystemdUnits = lib.mapAttrsToList + (_: session: + session.systemdUserUnits) + cfg.sessions; in { # Install all of the desktop session files. @@ -169,7 +174,8 @@ in environment.pathsToLink = [ "/share/gnome-session" ]; # Import those systemd units from gnome-session as well. - systemd.packages = [ cfg.package ] ++ sessionPackages; + systemd.packages = [ cfg.package ]; + systemd.user.units = lib.mkMerge sessionSystemdUnits; } ); } diff --git a/modules/nixos/programs/gnome-session/submodules.nix b/modules/nixos/programs/gnome-session/submodules.nix index 0b7dd00e..47aa1b1b 100644 --- a/modules/nixos/programs/gnome-session/submodules.nix +++ b/modules/nixos/programs/gnome-session/submodules.nix @@ -529,7 +529,6 @@ rec { * gnome-session `.session` file. * The gnome-session systemd target drop-in file. * The components `.desktop` file. - * The components' systemd unit files. ''; readOnly = true; }; @@ -645,19 +644,6 @@ rec { displayScripts.${display}) config.display; - installSystemdUserUnits = lib.mapAttrsToList - (n: v: - if (v ? overrideStrategy && v.overrideStrategy == "asDropin") then '' - ( - unit="${v.unit}/${n}" - unit_filename=$(basename "$unit") - install -Dm0644 "$unit" "$out/share/systemd/user/''${unit_filename}.d/session.conf" - ) - '' else '' - install -Dm0644 "${v.unit}/${n}" -t "$out/share/systemd/user" - '') - config.systemdUserUnits; - installDesktops = lib.mapAttrsToList (_: p: '' install -Dm0644 ${p.desktopPackage}/share/applications/*.desktop -t $out/share/applications @@ -684,9 +670,6 @@ rec { ${lib.concatStringsSep "\n" installDesktopSessions} - ${lib.concatStringsSep "\n" installSystemdUserUnits} - mkdir -p "$out/lib/systemd" && ln -sfn "$out/share/systemd/user" "$out/lib/systemd/user" - ${lib.concatStringsSep "\n" installDesktops} ''; };