Merge pull request #34470 from WilliButz/fix-xautolock

nixos/xautolock: fix default defaults/examples, add assertions

authored by Franz Pletz and committed by GitHub 0dcf5df0 d81e32be

+16 -12
+16 -12
nixos/modules/services/x11/xautolock.nix
··· 26 26 }; 27 27 28 28 locker = mkOption { 29 - default = "xlock"; # default according to `man xautolock` 30 - example = "i3lock -i /path/to/img"; 31 - type = types.string; 29 + default = "${pkgs.xlockmore}/bin/xlock"; # default according to `man xautolock` 30 + example = "${pkgs.i3lock}/bin/i3lock -i /path/to/img"; 31 + type = types.str; 32 32 33 33 description = '' 34 34 The script to use when automatically locking the computer. ··· 37 37 38 38 nowlocker = mkOption { 39 39 default = null; 40 - example = "i3lock -i /path/to/img"; 41 - type = types.nullOr types.string; 40 + example = "${pkgs.i3lock}/bin/i3lock -i /path/to/img"; 41 + type = types.nullOr types.str; 42 42 43 43 description = '' 44 44 The script to use when manually locking the computer with <command>xautolock -locknow</command>. ··· 56 56 57 57 notifier = mkOption { 58 58 default = null; 59 - example = literalExample '' 60 - "${pkgs.libnotify}/bin/notify-send \"Locking in 10 seconds\"" 61 - ''; 62 - type = types.nullOr types.string; 59 + example = "${pkgs.libnotify}/bin/notify-send \"Locking in 10 seconds\""; 60 + type = types.nullOr types.str; 63 61 64 62 description = '' 65 63 Notification script to be used to warn about the pending autolock. ··· 68 66 69 67 killer = mkOption { 70 68 default = null; # default according to `man xautolock` is none 71 - example = "systemctl suspend"; 72 - type = types.nullOr types.string; 69 + example = "${pkgs.systemd}/bin/systemctl suspend"; 70 + type = types.nullOr types.str; 73 71 74 72 description = '' 75 73 The script to use when nothing has happend for as long as <option>killtime</option> ··· 131 129 assertion = cfg.killer != null -> cfg.killtime >= 10; 132 130 message = "killtime has to be at least 10 minutes according to `man xautolock`"; 133 131 } 134 - ]; 132 + ] ++ (lib.flip map [ "locker" "notifier" "nowlocker" "killer" ] 133 + (option: 134 + { 135 + assertion = cfg."${option}" != null -> builtins.substring 0 1 cfg."${option}" == "/"; 136 + message = "Please specify a canonical path for `services.xserver.xautolock.${option}`"; 137 + }) 138 + ); 135 139 }; 136 140 }