Rework greetd start command config
Command is now listOf str, finalCommand is a shellEscapeArgs processed command with applicable wrapper scripts applied
This commit is contained in:
parent
197b557468
commit
9177f15feb
@ -65,7 +65,7 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
services.greetd.settings.initial_session = {
|
services.greetd.settings.initial_session = {
|
||||||
command = config.nixfiles.programs.greetd.settings.command;
|
command = config.nixfiles.programs.greetd.settings.finalCommand;
|
||||||
user = "nullbite";
|
user = "nullbite";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,16 +1,22 @@
|
|||||||
{ pkgs, config, lib, options, ... }:
|
{ pkgs, config, lib, options, ... }:
|
||||||
let
|
let
|
||||||
cfg = config.nixfiles.programs.greetd;
|
cfg = config.nixfiles.programs.greetd;
|
||||||
inherit (lib.types) bool enum nullOr str path;
|
inherit (lib.types) bool enum nullOr str path listOf;
|
||||||
inherit (builtins) isNull;
|
inherit (builtins) isNull;
|
||||||
inherit (lib) optional optionals;
|
inherit (lib) optional optionals;
|
||||||
optionalsSet = val: optionals (!(isNull val));
|
optionalsSet = val: optionals (!(isNull val));
|
||||||
|
optionalSet = val: optional (!(isNull val));
|
||||||
sessions = config.services.xserver.displayManager.sessionData.desktops;
|
sessions = config.services.xserver.displayManager.sessionData.desktops;
|
||||||
xsessions = "${sessions}/share/xsessions";
|
xsessions = "${sessions}/share/xsessions";
|
||||||
wayland-sessions = "${sessions}/share/wayland-sessions";
|
wayland-sessions = "${sessions}/share/wayland-sessions";
|
||||||
|
|
||||||
|
loginwrap=pkgs.writeShellScriptBin "loginwrap" ''
|
||||||
|
exec "$SHELL" -lc 'exec "$@"' "login-wrapper" "$@"
|
||||||
|
'';
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
config = lib.mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
|
environment.systemPackages = [ loginwrap ];
|
||||||
services.greetd = {
|
services.greetd = {
|
||||||
enable = true;
|
enable = true;
|
||||||
settings = {
|
settings = {
|
||||||
@ -24,8 +30,11 @@ in
|
|||||||
"--sessions" "${xsessions}:${wayland-sessions}" ]
|
"--sessions" "${xsessions}:${wayland-sessions}" ]
|
||||||
++ optionalsSet st.greeting [ "--greeting" st.greeting ]
|
++ optionalsSet st.greeting [ "--greeting" st.greeting ]
|
||||||
++ optional st.time "--time"
|
++ optional st.time "--time"
|
||||||
++ optionalsSet st.command [ "--cmd" (lib.escapeShellArg st.command) ];
|
++ optionalsSet st.command [ "--cmd" st.finalCommand ]
|
||||||
in lib.escapeShellArgs args;
|
# i think tuigreet might be outdated on nix. disable this because it's not a valid option
|
||||||
|
# ++ optionalsSet st.loginShell [ "--session-wrapper" "loginwrap" ]
|
||||||
|
;
|
||||||
|
in lib.escapeShellArgs args;
|
||||||
})
|
})
|
||||||
|
|
||||||
];
|
];
|
||||||
@ -50,11 +59,29 @@ in
|
|||||||
default = "log in pwease!! uwu";
|
default = "log in pwease!! uwu";
|
||||||
example = "something boring";
|
example = "something boring";
|
||||||
};
|
};
|
||||||
|
finalCommand = lib.mkOption {
|
||||||
|
description = "Final version of command";
|
||||||
|
type = nullOr str;
|
||||||
|
default = let
|
||||||
|
st = cfg.settings;
|
||||||
|
prevcmd = st.command;
|
||||||
|
command-login-wrapped = [ "loginwrap" ] ++ prevcmd;
|
||||||
|
cmd = if (builtins.isNull prevcmd) then null else
|
||||||
|
(if st.loginShell then command-login-wrapped else prevcmd);
|
||||||
|
in lib.escapeShellArgs cmd;
|
||||||
|
readOnly = true;
|
||||||
|
};
|
||||||
command = lib.mkOption {
|
command = lib.mkOption {
|
||||||
description = "Command to run following successful authentication";
|
description = "Command to run following successful authentication";
|
||||||
type = nullOr str;
|
type = nullOr (listOf str);
|
||||||
default = null;
|
default = null;
|
||||||
example = "Hyprland";
|
example = [ "Hyprland" ];
|
||||||
|
};
|
||||||
|
loginShell = lib.mkOption {
|
||||||
|
description = "Wrap in login shell to source .profile/.zshenv/etc. (if configurable).";
|
||||||
|
type = bool;
|
||||||
|
default = true;
|
||||||
|
example = false;
|
||||||
};
|
};
|
||||||
time = lib.mkOption {
|
time = lib.mkOption {
|
||||||
description = "Whether to show the current time (if configurable)";
|
description = "Whether to show the current time (if configurable)";
|
||||||
|
@ -27,7 +27,7 @@ in
|
|||||||
nixfiles.programs.greetd = {
|
nixfiles.programs.greetd = {
|
||||||
enable = true;
|
enable = true;
|
||||||
settings = {
|
settings = {
|
||||||
command = "${pkgs.hyprland}/bin/Hyprland";
|
command = [ "${pkgs.hyprland}/bin/Hyprland" ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user