diff --git a/modules/nixos/programs/sessiond/default.nix b/modules/nixos/programs/sessiond/default.nix index 076c3a4a..38c51af4 100644 --- a/modules/nixos/programs/sessiond/default.nix +++ b/modules/nixos/programs/sessiond/default.nix @@ -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; diff --git a/modules/nixos/programs/sessiond/submodules/component-type.nix b/modules/nixos/programs/sessiond/submodules/component-type.nix index 4b0330d5..b4285281 100644 --- a/modules/nixos/programs/sessiond/submodules/component-type.nix +++ b/modules/nixos/programs/sessiond/submodules/component-type.nix @@ -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; }; diff --git a/modules/nixos/programs/sessiond/submodules/session-type.nix b/modules/nixos/programs/sessiond/submodules/session-type.nix index 68ecda06..9406c73e 100644 --- a/modules/nixos/programs/sessiond/submodules/session-type.nix +++ b/modules/nixos/programs/sessiond/submodules/session-type.nix @@ -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" ];