From d00dcf035543badeb69aac4466897b870afcd63a Mon Sep 17 00:00:00 2001 From: Youwen Wu Date: Sun, 22 Dec 2024 23:38:14 -0800 Subject: [PATCH] refactor: modularize greeter --- hosts/callisto/configuration.nix | 1 + modules/linux/greeter/default.nix | 65 ++++++++++++++++++++++--------- 2 files changed, 47 insertions(+), 19 deletions(-) diff --git a/hosts/callisto/configuration.nix b/hosts/callisto/configuration.nix index 4894167..ac1f300 100755 --- a/hosts/callisto/configuration.nix +++ b/hosts/callisto/configuration.nix @@ -27,6 +27,7 @@ theming = { enable = true; }; + desktop.greeter.enable = true; }; boot = { diff --git a/modules/linux/greeter/default.nix b/modules/linux/greeter/default.nix index 556002c..79aa9f7 100644 --- a/modules/linux/greeter/default.nix +++ b/modules/linux/greeter/default.nix @@ -1,25 +1,52 @@ -{ pkgs, ... }: { - services.greetd = { - enable = true; - settings = { - default_session = { - command = '' - ${pkgs.greetd.tuigreet}/bin/tuigreet --time --cmd Hyprland --remember --greeting "Welcome, generation $(readlink /nix/var/nix/profiles/system | grep -o '[0-9]*'). Access is restricted to authorized personnel only." - ''; - user = "greeter"; - }; + pkgs, + lib, + config, + ... +}: +let + cfg = config.liminalOS.desktop.greeter; +in +{ + options.liminalOS.desktop.greeter = { + enable = lib.mkOption { + type = lib.types.bool; + default = config.liminalOS.desktop.enable; + description = '' + Whether to enable and set up tui-greet, the default greeter for liminalOS. + ''; + }; + command = lib.mkOption { + type = lib.types.str; + default = if config.liminalOS.desktop.enable then "Hyprland" else ""; + description = '' + Command for the greeter to execute to launch the desktop. If the liminalOS Hyprland Desktop is enabled, defaults to `Hyprland`. + ''; }; }; - systemd.services.greetd.serviceConfig = { - Type = "idle"; - StandardInput = "tty"; - StandardOutput = "tty"; - StandardError = "journal"; # Without this errors will spam on screen - # Without these bootlogs will spam on screen - TTYReset = true; - TTYVHangup = true; - TTYVTDisallocate = true; + config = lib.mkIf cfg.enable { + services.greetd = { + enable = true; + settings = { + default_session = { + command = '' + ${pkgs.greetd.tuigreet}/bin/tuigreet --time --cmd Hyprland --remember --greeting "Welcome, generation $(readlink /nix/var/nix/profiles/system | grep -o '[0-9]*'). Access is restricted to authorized personnel only." + ''; + user = "greeter"; + }; + }; + }; + + systemd.services.greetd.serviceConfig = { + Type = "idle"; + StandardInput = "tty"; + StandardOutput = "tty"; + StandardError = "journal"; # Without this errors will spam on screen + # Without these bootlogs will spam on screen + TTYReset = true; + TTYVHangup = true; + TTYVTDisallocate = true; + }; }; }