From afe3852b9a852f7bfab9ad0d0df1fb5afef9ed2e Mon Sep 17 00:00:00 2001 From: cnst Date: Tue, 24 Sep 2024 17:45:28 +0200 Subject: [PATCH] greetd optionals --- hosts/cnix/modules.nix | 7 ++- hosts/cnixpad/modules.nix | 5 ++ hosts/toothpc/modules.nix | 5 ++ system/modules/sysd/system/greetd/default.nix | 56 ++++++++++++++----- 4 files changed, 58 insertions(+), 15 deletions(-) diff --git a/hosts/cnix/modules.nix b/hosts/cnix/modules.nix index ca40ec78..86d39e82 100644 --- a/hosts/cnix/modules.nix +++ b/hosts/cnix/modules.nix @@ -105,7 +105,7 @@ }; }; gnome-keyring = { - enable = true; + enable = false; }; }; session = { @@ -132,6 +132,11 @@ }; greetd = { enable = true; + gnomeKeyring.enable = false; + autologin = { + enable = false; + user = "cnst"; + }; }; gvfs = { enable = true; diff --git a/hosts/cnixpad/modules.nix b/hosts/cnixpad/modules.nix index d88e44e0..49d4cede 100644 --- a/hosts/cnixpad/modules.nix +++ b/hosts/cnixpad/modules.nix @@ -127,6 +127,11 @@ }; greetd = { enable = true; + gnomeKeyring.enable = false; + autologin = { + enable = false; + user = "cnst"; + }; }; gvfs = { enable = true; diff --git a/hosts/toothpc/modules.nix b/hosts/toothpc/modules.nix index 8a96cf66..415a82c5 100644 --- a/hosts/toothpc/modules.nix +++ b/hosts/toothpc/modules.nix @@ -128,6 +128,11 @@ }; greetd = { enable = true; + gnomeKeyring.enable = false; + autologin = { + enable = false; + user = "toothpick"; + }; }; gvfs = { enable = true; diff --git a/system/modules/sysd/system/greetd/default.nix b/system/modules/sysd/system/greetd/default.nix index 92a910bf..ed949055 100644 --- a/system/modules/sysd/system/greetd/default.nix +++ b/system/modules/sysd/system/greetd/default.nix @@ -4,27 +4,55 @@ lib, ... }: let - inherit (lib) mkIf mkEnableOption; + inherit (lib) mkIf mkEnableOption mkMerge mkOption types; cfg = config.modules.sysd.system.greetd; in { options = { - modules.sysd.system.greetd.enable = mkEnableOption "Enables greetd"; + modules.sysd.system.greetd = { + enable = mkEnableOption { + type = types.bool; + default = false; + description = "Enables the greetd service."; + }; + gnomeKeyring.enable = mkEnableOption { + type = types.bool; + default = false; + description = "Enables GnomeKeyring PAM service for greetd."; + }; + autologin.enable = mkEnableOption { + type = types.bool; + default = false; + description = "Enables autologin for a specified user."; + }; + autologin.user = mkOption { + type = types.str; + default = "cnst"; + description = "The username to auto-login when autologin is enabled."; + }; + }; }; + config = mkIf cfg.enable { services.greetd = { enable = true; - settings = { - # AUTOLOGIN - # initial_session = { - # command = "${pkgs.hyprland}/bin/Hyprland"; - # user = "cnst"; # <- select which user to auto-login - # }; - default_session = { - command = "${pkgs.greetd.tuigreet}/bin/tuigreet -r --remember-session --asterisks"; - user = "greeter"; - }; - }; + settings = mkMerge [ + # Conditionally include initial_session if autologin is enabled + (mkIf cfg.autologin.enable { + initial_session = { + command = "${pkgs.hyprland}/bin/Hyprland"; + user = cfg.autologin.user; + }; + }) + { + default_session = { + command = "${pkgs.greetd.tuigreet}/bin/tuigreet -r --remember-session --asterisks"; + user = "greeter"; + }; + } + ]; }; - security.pam.services.greetd.enableGnomeKeyring = true; + + # Apply GnomeKeyring PAM Service based on user configuration + security.pam.services.greetd.enableGnomeKeyring = cfg.gnomeKeyring.enable; }; }