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 ${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 ${optionalString (cfg.defaultUser != null) ("default_user " + cfg.defaultUser)} 21 ${optionalString (cfg.defaultUser != null) ("focus_password yes")} 22 ${optionalString cfg.autoLogin "auto_login yes"} 23 ${cfg.extraConfig} 24 ''; 25 26 # Unpack the SLiM theme, or use the default. 27 slimThemesDir = 28 let 29 unpackedTheme = pkgs.stdenv.mkDerivation { 30 name = "slim-theme"; 31 buildCommand = '' 32 mkdir -p $out 33 cd $out 34 unpackFile ${cfg.theme} 35 ln -s * default 36 ''; 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 }; 111 112 }; 113 114 115 ###### implementation 116 117 config = mkIf cfg.enable { 118 119 services.xserver.displayManager.job = 120 { preStart = 121 '' 122 rm -f /var/log/slim.log 123 ''; 124 environment = 125 { SLIM_CFGFILE = slimConfig; 126 SLIM_THEMESDIR = slimThemesDir; 127 }; 128 execCmd = "exec ${pkgs.slim}/bin/slim"; 129 }; 130 131 services.xserver.displayManager.sessionCommands = 132 '' 133 # Export the config/themes for slimlock. 134 export SLIM_THEMESDIR=${slimThemesDir} 135 ''; 136 137 # Allow null passwords so that the user can login as root on the 138 # installation CD. 139 security.pam.services.slim = { allowNullPassword = true; startSession = true; }; 140 141 # Allow slimlock to work. 142 security.pam.services.slimlock = {}; 143 144 environment.systemPackages = [ pkgs.slim ]; 145 146 }; 147 148}