mirror of
https://github.com/foo-dogsquared/nixos-config.git
synced 2025-02-07 06:19:00 +00:00
nixos/programs/sessiond: add name option for session and components
Also similar change to the gnome-session one, blah blah blah...
This commit is contained in:
parent
ce9506a2bc
commit
93de33e028
@ -4,13 +4,13 @@ let
|
||||
cfg = config.programs.sessiond;
|
||||
|
||||
sessionPackages = lib.mapAttrsToList
|
||||
(name: session:
|
||||
(_: session:
|
||||
let
|
||||
displaySession = ''
|
||||
[Desktop Entry]
|
||||
Name=${session.fullName}
|
||||
Comment=${session.description}
|
||||
Exec="@out@/libexec/${name}-session"
|
||||
Exec="@out@/libexec/${session.name}-session"
|
||||
Type=Application
|
||||
DesktopNames=${lib.concatStringsSep ";" session.desktopNames};
|
||||
'';
|
||||
@ -18,21 +18,21 @@ let
|
||||
sessionScript = ''
|
||||
#!${pkgs.runtimeShell}
|
||||
|
||||
${lib.getExe' cfg.package "sessionctl"} run "${name}.target"
|
||||
${lib.getExe' cfg.package "sessionctl"} run "${session.name}.target"
|
||||
'';
|
||||
in
|
||||
pkgs.runCommandLocal "${name}-desktop-session-files"
|
||||
pkgs.runCommandLocal "${session.name}-desktop-session-files"
|
||||
{
|
||||
inherit displaySession sessionScript;
|
||||
passAsFile = [ "displaySession" "sessionScript" ];
|
||||
passthru.providedSessions = [ name ];
|
||||
passthru.providedSessions = [ session.name ];
|
||||
}
|
||||
''
|
||||
SESSION_SCRIPT="$out/libexec/${name}-session"
|
||||
SESSION_SCRIPT="$out/libexec/${session.name}-session"
|
||||
install -Dm0755 "$sessionScriptPath" "$SESSION_SCRIPT"
|
||||
substituteAllInPlace "$SESSION_SCRIPT"
|
||||
|
||||
DISPLAY_SESSION_FILE="$out/share/xsessions/${name}.desktop"
|
||||
DISPLAY_SESSION_FILE="$out/share/xsessions/${session.name}.desktop"
|
||||
install -Dm0644 "$displaySessionPath" "$DISPLAY_SESSION_FILE"
|
||||
substituteAllInPlace "$DISPLAY_SESSION_FILE"
|
||||
''
|
||||
@ -46,22 +46,22 @@ let
|
||||
pathToUnit serviceToUnit targetToUnit timerToUnit socketToUnit;
|
||||
|
||||
mkSystemdUnits = name: component: {
|
||||
"${component.id}.service" = serviceToUnit component.id component.serviceUnit;
|
||||
"${component.id}.target" = targetToUnit component.id component.targetUnit;
|
||||
"${component.id}.service" = serviceToUnit component.serviceUnit;
|
||||
"${component.id}.target" = targetToUnit component.targetUnit;
|
||||
} // lib.optionalAttrs (component.socketUnit != null) {
|
||||
"${component.id}.socket" = socketToUnit component.id component.socketUnit;
|
||||
"${component.id}.socket" = socketToUnit component.socketUnit;
|
||||
} // lib.optionalAttrs (component.timerUnit != null) {
|
||||
"${component.id}.timer" = timerToUnit component.id component.timerUnit;
|
||||
"${component.id}.timer" = timerToUnit component.timerUnit;
|
||||
} // lib.optionalAttrs (component.pathUnit != null) {
|
||||
"${component.id}.path" = pathToUnit component.id component.pathUnit;
|
||||
"${component.id}.path" = pathToUnit component.pathUnit;
|
||||
};
|
||||
|
||||
sessionComponents =
|
||||
lib.concatMapAttrs mkSystemdUnits session.components;
|
||||
in
|
||||
sessionComponents // {
|
||||
"${name}.service" = serviceToUnit name session.serviceUnit;
|
||||
"${name}.target" = targetToUnit name session.targetUnit;
|
||||
"${session.name}.service" = serviceToUnit session.serviceUnit;
|
||||
"${session.name}.target" = targetToUnit session.targetUnit;
|
||||
}
|
||||
)
|
||||
cfg.sessions;
|
||||
|
@ -18,6 +18,13 @@ let
|
||||
in
|
||||
{
|
||||
options = {
|
||||
name = lib.mkOption {
|
||||
type = lib.types.nonEmptyStr;
|
||||
description = "The identifier of the component.";
|
||||
default = name;
|
||||
example = "desktop-widgets";
|
||||
};
|
||||
|
||||
description = lib.mkOption {
|
||||
type = lib.types.nonEmptyStr;
|
||||
description = "One-sentence description of the component.";
|
||||
@ -124,7 +131,7 @@ in
|
||||
The identifier of the component used in generating filenames for its
|
||||
`.desktop` files and as part of systemd unit names.
|
||||
'';
|
||||
default = "${session.name}.${name}";
|
||||
default = "${session.name}.${config.name}";
|
||||
defaultText = "\${session-name}.\${name}";
|
||||
readOnly = true;
|
||||
};
|
||||
|
@ -29,10 +29,25 @@ let
|
||||
# This is used both as the configuration format for sessiond.conf and its
|
||||
# hooks.
|
||||
settingsFormat = pkgs.formats.toml { };
|
||||
sessionSettingsFile = settingsFormat.generate "sessiond-conf-${name}" config.settings;
|
||||
sessionSettingsFile = settingsFormat.generate "sessiond-conf-${config.name}" config.settings;
|
||||
in
|
||||
{
|
||||
options = {
|
||||
name = lib.mkOption {
|
||||
type = lib.types.nonEmptyStr;
|
||||
description = ''
|
||||
The identifier for the desktop environment.
|
||||
|
||||
::: {.note}
|
||||
While there is no formal standard for naming these, it is recommended
|
||||
to make the name in kebab-case (for example, "mosey-branch" for "Mosey
|
||||
branch").
|
||||
:::
|
||||
'';
|
||||
default = name;
|
||||
example = "mosey-branch";
|
||||
};
|
||||
|
||||
fullName = lib.mkOption {
|
||||
type = lib.types.nonEmptyStr;
|
||||
description = "The display name of the desktop environment.";
|
||||
@ -202,7 +217,7 @@ in
|
||||
|
||||
targetUnit = {
|
||||
description = config.description;
|
||||
requires = [ "${name}.service" ];
|
||||
requires = [ "${config.name}.service" ];
|
||||
wants =
|
||||
let
|
||||
componentTargetUnits =
|
||||
@ -213,9 +228,9 @@ in
|
||||
|
||||
serviceUnit = {
|
||||
description = config.description;
|
||||
partOf = [ "${name}.target" ];
|
||||
before = [ "${name}.target" ];
|
||||
requisite = [ "${name}.target" ];
|
||||
partOf = [ "${config.name}.target" ];
|
||||
before = [ "${config.name}.target" ];
|
||||
requisite = [ "${config.name}.target" ];
|
||||
requires = [ "dbus.socket" ];
|
||||
after = [ "dbus.socket" ];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user