mirror of
https://github.com/foo-dogsquared/nixos-config.git
synced 2025-01-31 04:58:01 +00:00
nixos/programs/gnome-session: add sessions.<name>.settings
This will allow for some flexibility for REALLY OBSCURE custom desktop sessions but we'll still keep the `requiredComponents` option since it is so common and most likely what the user will modify anyways.
This commit is contained in:
parent
a808b01f42
commit
90476b0774
@ -8,15 +8,22 @@
|
|||||||
let
|
let
|
||||||
cfg = config.programs.gnome-session;
|
cfg = config.programs.gnome-session;
|
||||||
|
|
||||||
|
glibKeyfileFormat = pkgs.formats.ini {
|
||||||
|
listsAsDuplicateKeys = false;
|
||||||
|
mkKeyValue =
|
||||||
|
let
|
||||||
|
mkValueString = lib.generators.mkKeyValueDefault { };
|
||||||
|
in
|
||||||
|
k: v:
|
||||||
|
if lib.isList v then lib.concatStringsSep ";" v
|
||||||
|
else "${k}=${mkValueString v}";
|
||||||
|
};
|
||||||
|
|
||||||
# The bulk of the work. Pretty much the main purpose of this module.
|
# The bulk of the work. Pretty much the main purpose of this module.
|
||||||
sessionPackages = lib.mapAttrsToList
|
sessionPackages = lib.mapAttrsToList
|
||||||
(_: session:
|
(_: session:
|
||||||
let
|
let
|
||||||
gnomeSession = ''
|
gnomeSession = glibKeyfileFormat.generate "session-${session.name}" session.settings;
|
||||||
[GNOME Session]
|
|
||||||
Name=${session.fullName} session
|
|
||||||
RequiredComponents=${lib.concatStringsSep ";" session.requiredComponents};
|
|
||||||
'';
|
|
||||||
|
|
||||||
displaySession = ''
|
displaySession = ''
|
||||||
[Desktop Entry]
|
[Desktop Entry]
|
||||||
@ -50,13 +57,13 @@ let
|
|||||||
'')
|
'')
|
||||||
session.components;
|
session.components;
|
||||||
in
|
in
|
||||||
pkgs.runCommandLocal "${session.name}-desktop-session-files"
|
pkgs.runCommand "${session.name}-desktop-session-files"
|
||||||
{
|
{
|
||||||
env = {
|
env = {
|
||||||
inherit (session) fullName;
|
inherit (session) fullName;
|
||||||
};
|
};
|
||||||
inherit displaySession gnomeSession sessionScript;
|
inherit displaySession gnomeSession sessionScript;
|
||||||
passAsFile = [ "displaySession" "gnomeSession" "sessionScript" ];
|
passAsFile = [ "displaySession" "sessionScript" ];
|
||||||
passthru.providedSessions = [ session.name ];
|
passthru.providedSessions = [ session.name ];
|
||||||
}
|
}
|
||||||
''
|
''
|
||||||
@ -65,8 +72,7 @@ let
|
|||||||
substituteAllInPlace "$SESSION_SCRIPT"
|
substituteAllInPlace "$SESSION_SCRIPT"
|
||||||
|
|
||||||
GNOME_SESSION_FILE="$out/share/gnome-session/sessions/${session.name}.session"
|
GNOME_SESSION_FILE="$out/share/gnome-session/sessions/${session.name}.session"
|
||||||
install -Dm0644 "$gnomeSessionPath" "$GNOME_SESSION_FILE"
|
install -Dm0644 "$gnomeSession" "$GNOME_SESSION_FILE"
|
||||||
substituteAllInPlace "$GNOME_SESSION_FILE"
|
|
||||||
|
|
||||||
DISPLAY_SESSION_FILE="$out/share/wayland-sessions/${session.name}.desktop"
|
DISPLAY_SESSION_FILE="$out/share/wayland-sessions/${session.name}.desktop"
|
||||||
install -Dm0644 "$displaySessionPath" "$DISPLAY_SESSION_FILE"
|
install -Dm0644 "$displaySessionPath" "$DISPLAY_SESSION_FILE"
|
||||||
@ -116,7 +122,7 @@ in
|
|||||||
|
|
||||||
sessions = lib.mkOption {
|
sessions = lib.mkOption {
|
||||||
type = with lib.types; attrsOf (submoduleWith {
|
type = with lib.types; attrsOf (submoduleWith {
|
||||||
specialArgs = { inherit utils; };
|
specialArgs = { inherit utils glibKeyfileFormat; };
|
||||||
modules = [ ./submodules/session-type.nix ];
|
modules = [ ./submodules/session-type.nix ];
|
||||||
});
|
});
|
||||||
description = ''
|
description = ''
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
{ name, config, lib, utils, ... }:
|
{ name, config, lib, utils, glibKeyfileFormat, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
# For an updated list, see `menu/menu-spec.xml` from
|
# For an updated list, see `menu/menu-spec.xml` from
|
||||||
# https://gitlab.freedesktop.org/xdg/xdg-specs.
|
# https://gitlab.freedesktop.org/xdg/xdg-specs.
|
||||||
validDesktopNames = [
|
validDesktopNames = [
|
||||||
@ -136,6 +137,25 @@ in
|
|||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
settings = lib.mkOption {
|
||||||
|
type = glibKeyfileFormat.type;
|
||||||
|
description = ''
|
||||||
|
Settings to be included to the gnome-session keyfile of the session.
|
||||||
|
|
||||||
|
Generally, you won't need to set this since the module will set the
|
||||||
|
common settings such as the `RequiredComponents=` key.
|
||||||
|
'';
|
||||||
|
example = lib.literalExpression ''
|
||||||
|
{
|
||||||
|
# A helper script to check if the session is runnable.
|
||||||
|
IsRunnableHelper = "''${lib.getExe' pkgs.niri "niri"} --validate config";
|
||||||
|
|
||||||
|
# A fallback session in case it failed.
|
||||||
|
FallbackSession = "gnome";
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
requiredComponents = lib.mkOption {
|
requiredComponents = lib.mkOption {
|
||||||
type = with lib.types; listOf str;
|
type = with lib.types; listOf str;
|
||||||
description = ''
|
description = ''
|
||||||
@ -205,5 +225,10 @@ in
|
|||||||
overrideStrategy = lib.mkForce "asDropin";
|
overrideStrategy = lib.mkForce "asDropin";
|
||||||
wants = lib.mkDefault (builtins.map (c: "${c}.target") config.requiredComponents);
|
wants = lib.mkDefault (builtins.map (c: "${c}.target") config.requiredComponents);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
settings."GNOME Session" = {
|
||||||
|
Name = "${config.fullName} session";
|
||||||
|
RequiredComponents = config.requiredComponents;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user