From 68f5c3247e3ccf378d6d1efd7c7982f0f859248f Mon Sep 17 00:00:00 2001 From: NullBite Date: Wed, 20 Mar 2024 20:51:55 -0400 Subject: [PATCH] Modularize greetd configuration --- hosts/nullbox/configuration.nix | 5 ++- hosts/slab/configuration.nix | 12 ++---- system/programs/default.nix | 1 + system/programs/greetd.nix | 73 +++++++++++++++++++++++++++++++++ 4 files changed, 82 insertions(+), 9 deletions(-) create mode 100644 system/programs/greetd.nix diff --git a/hosts/nullbox/configuration.nix b/hosts/nullbox/configuration.nix index eb72225..78c901d 100644 --- a/hosts/nullbox/configuration.nix +++ b/hosts/nullbox/configuration.nix @@ -51,6 +51,10 @@ nixfiles = { profile.pc.enable = true; programs.adb.enable = true; + programs.greetd = { + enable = true; + preset = "tuigreet"; + }; programs.unbound.enable = true; common.remoteAccess.enable = true; sessions.plasma.enable = lib.mkDefault false; @@ -61,7 +65,6 @@ }; services.xserver.displayManager.sddm.enable = false; - services.xserver.displayManager.startx.enable = true; # bootloader setup boot.loader = { diff --git a/hosts/slab/configuration.nix b/hosts/slab/configuration.nix index ebf6b5e..356b31d 100644 --- a/hosts/slab/configuration.nix +++ b/hosts/slab/configuration.nix @@ -44,14 +44,6 @@ # who needs a display manager? services.xserver.displayManager.sddm.enable = false; - services.xserver.displayManager.startx.enable = true; - - services.greetd = { - enable = true; - settings = { - default_session.command = "${pkgs.greetd.tuigreet}/bin/tuigreet --time --cmd Hyprland --asterisks"; - }; - }; nixfiles = { profile.pc.enable = true; @@ -67,6 +59,10 @@ programs = { adb.enable = true; unbound.enable = true; + greetd = { + enable = true; + preset = "tuigreet"; + }; }; }; diff --git a/system/programs/default.nix b/system/programs/default.nix index 37d66aa..43b619b 100644 --- a/system/programs/default.nix +++ b/system/programs/default.nix @@ -4,5 +4,6 @@ ./syncthing.nix ./android.nix ./unbound.nix + ./greetd.nix ]; } diff --git a/system/programs/greetd.nix b/system/programs/greetd.nix new file mode 100644 index 0000000..5c29b4e --- /dev/null +++ b/system/programs/greetd.nix @@ -0,0 +1,73 @@ +{ pkgs, config, lib, options, ... }: +let + cfg = config.nixfiles.programs.greetd; + inherit (lib.types) bool enum nullOr str path; + inherit (builtins) isNull; + inherit (lib) optional optionals; + optionalsSet = val: optionals (!(isNull val)); +in +{ + config = lib.mkIf cfg.enable { + services.greetd = { + enable = true; + settings = { + default_session = lib.mkMerge [ + + # tuigreet configuration + (lib.mkIf cfg.presets.tuigreet.enable { + command = let + st = cfg.settings; + args = [ "${pkgs.greetd.tuigreet}/bin/tuigreet" "--asterisks" "--remember" "--remember-session" ] + ++ optionalsSet st.greeting [ "--greeting" st.greeting ] + ++ optional st.time "--time" ; + in lib.escapeShellArgs args; + }) + + ]; + }; + }; + nixfiles.programs.greetd.presets.${cfg.preset}.enable = true; + }; + + options.nixfiles.programs.greetd = { + enable = lib.mkEnableOption "greetd configuration"; + + preset = lib.mkOption { + description = "greetd configuration to enable (shorthand for presets..enable)"; + type = enum (lib.mapAttrsToList (name: value: name) options.nixfiles.programs.greetd.presets); + default = "tuigreet"; + }; + + settings = { + greeting = lib.mkOption { + description = "Greeting to show on the chosen greeter (if configurable)"; + type = nullOr str; + default = "log in pwease!! uwu"; + example = "something boring"; + }; + command = lib.mkOption { + description = "Command to run following successful authentication"; + type = nullOr str; + default = null; + example = "Hyprland"; + }; + time = lib.mkOption { + description = "Whether to show the current time (if configurable)"; + type = bool; + default = true; + example = false; + }; + wallpaper = lib.mkOption { + description = "Path to custom wallpaper (if configurable)"; + type = nullOr path; + default = "${pkgs.nixfiles-assets}/share/wallpapers/nixfiles-static/Djayjesse-finding_life.png"; + example = "femboy-bee.png"; + }; + }; + presets.tuigreet.enable = lib.mkOption { + description = "tuigreet greetd configuration"; + type = bool; + default = false; + }; + }; +}