1{
2 config,
3 lib,
4 pkgs,
5 ...
6}:
7let
8 cfg = config.services.displayManager.lemurs;
9 settingsFormat = pkgs.formats.toml { };
10in
11{
12 imports = [
13 (lib.mkRemovedOptionModule [
14 "services"
15 "displayManager"
16 "lemurs"
17 "vt"
18 ] "The VT is now fixed to VT1.")
19 ];
20
21 options.services.displayManager.lemurs = {
22 enable = lib.mkEnableOption "" // {
23 description = ''
24 Whether to enable lemurs, a customizable TUI display/login manager.
25
26 ::: {.note}
27 For Wayland compositors, your user must be in the "seat" group.
28 :::
29 '';
30 };
31
32 package = lib.mkPackageOption pkgs "lemurs" { };
33
34 settings = lib.mkOption {
35 type = settingsFormat.type;
36 default = { };
37 example = lib.literalExpression ''
38 {
39 do_log = true;
40 }
41 '';
42 description = ''
43 Configuration for lemurs, provided as a Nix attribute set and automatically
44 serialized to TOML.
45 See [lemurs configuration documentation](https://github.com/coastalwhite/lemurs/blob/main/extra/config.toml) for available options.
46 '';
47 };
48 };
49 config = lib.mkIf cfg.enable {
50 assertions = [
51 {
52 assertion = !config.services.displayManager.autoLogin.enable;
53 message = ''
54 lemurs doesn't support auto login.
55 '';
56 }
57 ];
58
59 security.pam.services.lemurs = {
60 unixAuth = true;
61 startSession = true;
62 # See https://github.com/coastalwhite/lemurs/issues/166
63 setLoginUid = false;
64 enableGnomeKeyring = lib.mkDefault config.services.gnome.gnome-keyring.enable;
65 };
66
67 environment.systemPackages = [ cfg.package ];
68
69 services = {
70 dbus.packages = [ cfg.package ];
71 # Required for wayland with setLoginUid = false;
72 seatd.enable = true;
73 xserver = {
74 # To enable user switching, allow lemurs to allocate displays dynamically.
75 display = null;
76 };
77 displayManager = {
78 enable = true;
79 execCmd = "exec ${lib.getExe cfg.package} --config ${settingsFormat.generate "config.toml" cfg.settings}";
80 # set default settings
81 lemurs.settings =
82 let
83 desktops = config.services.displayManager.sessionData.desktops;
84 in
85 {
86 tty = 1;
87 system_shell = lib.mkDefault "${pkgs.bash}/bin/bash";
88 initial_path = lib.mkDefault "/run/current-system/sw/bin";
89 x11 = {
90 xauth_path = lib.mkDefault "${pkgs.xorg.xauth}/bin/xauth";
91 xserver_path = lib.mkDefault "${pkgs.xorg.xorgserver}/bin/X";
92 xsessions_path = lib.mkDefault "${desktops}/share/xsessions";
93 xsetup_path = lib.mkDefault config.services.displayManager.sessionData.wrapper;
94 };
95 wayland.wayland_sessions_path = lib.mkDefault "${desktops}/share/wayland-sessions";
96 };
97 };
98 };
99
100 systemd.services.display-manager = {
101 unitConfig = {
102 Wants = [ "systemd-user-sessions.service" ];
103 After = [
104 "systemd-user-sessions.service"
105 "plymouth-quit-wait.service"
106 ];
107 };
108 serviceConfig = {
109 Type = "idle";
110 # Defaults from lemurs upstream configuration
111 StandardInput = "tty";
112 TTYPath = "/dev/tty1";
113 TTYReset = "yes";
114 TTYVHangup = "yes";
115 # Clear the console before starting
116 TTYVTDisallocate = true;
117 };
118 # Don't kill a user session when using nixos-rebuild
119 restartIfChanged = false;
120 };
121 };
122
123 meta.maintainers = with lib.maintainers; [
124 nullcube
125 stunkymonkey
126 ];
127}