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.
This commit is contained in:
Gabriel Arazas 2024-01-09 10:45:43 +08:00
parent 7b352c9ea4
commit 929d3968ad
No known key found for this signature in database
GPG Key ID: ADE0C41DAB221FCC
2 changed files with 7 additions and 18 deletions

View File

@ -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;
}
);
}

View File

@ -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}
'';
};