1{ config, lib, pkgs, ... }: 2 3with lib; 4 5let 6 7 dmcfg = config.services.xserver.displayManager; 8 9 cfg = dmcfg.slim; 10 11 slimConfig = pkgs.writeText "slim.cfg" 12 '' 13 xauth_path ${dmcfg.xauthBin} 14 default_xserver ${dmcfg.xserverBin} 15 xserver_arguments ${toString dmcfg.xserverArgs} 16 sessiondir ${dmcfg.session.desktops} 17 login_cmd exec ${pkgs.stdenv.shell} ${dmcfg.session.script} "%session" 18 halt_cmd ${config.systemd.package}/sbin/shutdown -h now 19 reboot_cmd ${config.systemd.package}/sbin/shutdown -r now 20 logfile /dev/stderr 21 ${optionalString (cfg.defaultUser != null) ("default_user " + cfg.defaultUser)} 22 ${optionalString (cfg.defaultUser != null) ("focus_password yes")} 23 ${optionalString cfg.autoLogin "auto_login yes"} 24 ${optionalString (cfg.consoleCmd != null) "console_cmd ${cfg.consoleCmd}"} 25 ${cfg.extraConfig} 26 ''; 27 28 # Unpack the SLiM theme, or use the default. 29 slimThemesDir = 30 let 31 unpackedTheme = pkgs.runCommand "slim-theme" {} 32 '' 33 mkdir -p $out 34 cd $out 35 unpackFile ${cfg.theme} 36 ln -s * default 37 ''; 38 in if cfg.theme == null then "${pkgs.slim}/share/slim/themes" else unpackedTheme; 39 40in 41 42{ 43 44 ###### interface 45 46 options = { 47 48 services.xserver.displayManager.slim = { 49 50 enable = mkOption { 51 type = types.bool; 52 default = config.services.xserver.enable; 53 description = '' 54 Whether to enable SLiM as the display manager. 55 ''; 56 }; 57 58 theme = mkOption { 59 type = types.nullOr types.path; 60 default = pkgs.fetchurl { 61 url = "https://github.com/jagajaga/nixos-slim-theme/archive/2.0.tar.gz"; 62 sha256 = "0lldizhigx7bjhxkipii87y432hlf5wdvamnfxrryf9z7zkfypc8"; 63 }; 64 defaultText = ''pkgs.fetchurl { 65 url = "https://github.com/jagajaga/nixos-slim-theme/archive/2.0.tar.gz"; 66 sha256 = "0lldizhigx7bjhxkipii87y432hlf5wdvamnfxrryf9z7zkfypc8"; 67 }''; 68 example = literalExample '' 69 pkgs.fetchurl { 70 url = "mirror://sourceforge/slim.berlios/slim-wave.tar.gz"; 71 sha256 = "0ndr419i5myzcylvxb89m9grl2xyq6fbnyc3lkd711mzlmnnfxdy"; 72 } 73 ''; 74 description = '' 75 The theme for the SLiM login manager. If not specified, SLiM's 76 default theme is used. See <link 77 xlink:href='http://slim.berlios.de/themes01.php'/> for a 78 collection of themes. TODO: berlios shut down. 79 ''; 80 }; 81 82 defaultUser = mkOption { 83 type = types.nullOr types.str; 84 default = null; 85 example = "login"; 86 description = '' 87 The default user to load. If you put a username here you 88 get it automatically loaded into the username field, and 89 the focus is placed on the password. 90 ''; 91 }; 92 93 autoLogin = mkOption { 94 type = types.bool; 95 default = false; 96 description = '' 97 Automatically log in as the default user. 98 ''; 99 }; 100 101 extraConfig = mkOption { 102 type = types.lines; 103 default = ""; 104 description = '' 105 Extra configuration options for SLiM login manager. Do not 106 add options that can be configured directly. 107 ''; 108 }; 109 110 consoleCmd = mkOption { 111 type = types.nullOr types.str; 112 default = '' 113 ${pkgs.xterm}/bin/xterm -C -fg white -bg black +sb -T "Console login" -e ${pkgs.shadow}/bin/login 114 ''; 115 defaultText = '' 116 ''${pkgs.xterm}/bin/xterm -C -fg white -bg black +sb -T "Console login" -e ''${pkgs.shadow}/bin/login 117 ''; 118 description = '' 119 The command to run when "console" is given as the username. 120 ''; 121 }; 122 }; 123 124 }; 125 126 127 ###### implementation 128 129 config = mkIf cfg.enable { 130 131 services.xserver.displayManager.job = 132 { environment = 133 { SLIM_CFGFILE = slimConfig; 134 SLIM_THEMESDIR = slimThemesDir; 135 }; 136 execCmd = "exec ${pkgs.slim}/bin/slim"; 137 }; 138 139 services.xserver.displayManager.sessionCommands = 140 '' 141 # Export the config/themes for slimlock. 142 export SLIM_THEMESDIR=${slimThemesDir} 143 ''; 144 145 # Allow null passwords so that the user can login as root on the 146 # installation CD. 147 security.pam.services.slim = { allowNullPassword = true; startSession = true; }; 148 149 # Allow slimlock to work. 150 security.pam.services.slimlock = {}; 151 152 environment.systemPackages = [ pkgs.slim ]; 153 154 }; 155 156}