Created
September 28, 2025 04:52
-
-
Save DJ-Laser/e45a4497773db8e5ae3e8a1d8951b39c to your computer and use it in GitHub Desktop.
Replaces all getty/login instances with greetd+agreety
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| config, | |
| pkgs, | |
| lib, | |
| ... | |
| }: let | |
| inherit | |
| (lib) | |
| mkIf | |
| mkOption | |
| types | |
| ; | |
| cfg = config.custom.services.greetd; | |
| settingsFormat = pkgs.formats.toml {}; | |
| defaultConfigFile = settingsFormat.generate "greetd.toml" { | |
| terminal.vt = 1; # gets overriden but if not present greetd exits with an error | |
| terminal.switch = false; | |
| default_session.command = "${pkgs.greetd}/bin/agreety -c '$SHELL'"; | |
| }; | |
| runScript = pkgs.writeShellScript "greetd_ttyN" '' | |
| ${pkgs.greetd}/bin/greetd --vt $(echo $1 | sed s/tty//) --config ${defaultConfigFile} | |
| ''; | |
| in { | |
| options.custom.services.greetd = { | |
| enable = mkOption { | |
| type = types.bool; | |
| default = true; | |
| description = '' | |
| Use greetd + agreety as the virtual console instead of gettys. | |
| ''; | |
| }; | |
| greeterManagesPlymouth = lib.mkOption { | |
| type = lib.types.bool; | |
| default = false; | |
| description = '' | |
| Don't configure the greetd service to wait for Plymouth to exit. | |
| Enable this if the greeter you're using can manage Plymouth itself to provide a smoother handoff. | |
| ''; | |
| }; | |
| }; | |
| config = mkIf cfg.enable { | |
| security.pam.services.greetd = { | |
| allowNullPassword = true; | |
| startSession = true; | |
| enableGnomeKeyring = lib.mkDefault config.services.gnome.gnome-keyring.enable; | |
| }; | |
| systemd.services."greetdvt@" = { | |
| after = | |
| [ | |
| "systemd-user-sessions.service" | |
| ] | |
| ++ lib.optionals (!cfg.greeterManagesPlymouth) [ | |
| "plymouth-quit-wait.service" | |
| ]; | |
| serviceConfig = { | |
| ExecStart = "${runScript} %I"; | |
| Restart = "always"; | |
| # Defaults from greetd upstream configuration | |
| IgnoreSIGPIPE = false; | |
| SendSIGHUP = true; | |
| TimeoutStopSec = "30s"; | |
| KeyringMode = "shared"; | |
| Type = "idle"; | |
| }; | |
| # Don't kill a user session when using nixos-rebuild | |
| restartIfChanged = false; | |
| aliases = ["autovt@.service"]; | |
| }; | |
| systemd.suppressedSystemUnits = ["autovt@.service"]; | |
| systemd.defaultUnit = "graphical.target"; | |
| # Create directories potentially required by supported greeters | |
| # See https://github.com/NixOS/nixpkgs/issues/248323 | |
| systemd.tmpfiles.rules = [ | |
| "d '/var/cache/tuigreet' - greeter greeter - -" | |
| ]; | |
| users.users.greeter = { | |
| isSystemUser = true; | |
| group = "greeter"; | |
| }; | |
| users.groups.greeter = {}; | |
| }; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment