summary refs log tree commit diff
path: root/nixos/modules/services/x11
diff options
context:
space:
mode:
authorWilliButz <wbutz@cyberfnord.de>2018-01-31 21:25:28 +0100
committerWilliButz <wbutz@cyberfnord.de>2018-01-31 21:43:23 +0100
commitc2fa5f172922c001bdf7e8213bcdd46e2b1cc49b (patch)
treed267ab75c3659b7e9ac1c7cb2257e7efc2c7ddbb /nixos/modules/services/x11
parent0307a1acf60e9f14debb8c5cbe82e104f153153e (diff)
downloadnixlib-c2fa5f172922c001bdf7e8213bcdd46e2b1cc49b.tar
nixlib-c2fa5f172922c001bdf7e8213bcdd46e2b1cc49b.tar.gz
nixlib-c2fa5f172922c001bdf7e8213bcdd46e2b1cc49b.tar.bz2
nixlib-c2fa5f172922c001bdf7e8213bcdd46e2b1cc49b.tar.lz
nixlib-c2fa5f172922c001bdf7e8213bcdd46e2b1cc49b.tar.xz
nixlib-c2fa5f172922c001bdf7e8213bcdd46e2b1cc49b.tar.zst
nixlib-c2fa5f172922c001bdf7e8213bcdd46e2b1cc49b.zip
nixos/xautolock: fix default defaults/examples, add assertions
see issue #34371
Diffstat (limited to 'nixos/modules/services/x11')
-rw-r--r--nixos/modules/services/x11/xautolock.nix28
1 files changed, 16 insertions, 12 deletions
diff --git a/nixos/modules/services/x11/xautolock.nix b/nixos/modules/services/x11/xautolock.nix
index 28fc92024bcb..a614559970e9 100644
--- a/nixos/modules/services/x11/xautolock.nix
+++ b/nixos/modules/services/x11/xautolock.nix
@@ -26,9 +26,9 @@ in
         };
 
         locker = mkOption {
-          default = "xlock"; # default according to `man xautolock`
-          example = "i3lock -i /path/to/img";
-          type = types.string;
+          default = "${pkgs.xlockmore}/bin/xlock"; # default according to `man xautolock`
+          example = "${pkgs.i3lock}/bin/i3lock -i /path/to/img";
+          type = types.str;
 
           description = ''
             The script to use when automatically locking the computer.
@@ -37,8 +37,8 @@ in
 
         nowlocker = mkOption {
           default = null;
-          example = "i3lock -i /path/to/img";
-          type = types.nullOr types.string;
+          example = "${pkgs.i3lock}/bin/i3lock -i /path/to/img";
+          type = types.nullOr types.str;
 
           description = ''
             The script to use when manually locking the computer with <command>xautolock -locknow</command>.
@@ -56,10 +56,8 @@ in
 
         notifier = mkOption {
           default = null;
-          example = literalExample ''
-            "${pkgs.libnotify}/bin/notify-send \"Locking in 10 seconds\""
-          '';
-          type = types.nullOr types.string;
+          example = "${pkgs.libnotify}/bin/notify-send \"Locking in 10 seconds\"";
+          type = types.nullOr types.str;
 
           description = ''
             Notification script to be used to warn about the pending autolock.
@@ -68,8 +66,8 @@ in
 
         killer = mkOption {
           default = null; # default according to `man xautolock` is none
-          example = "systemctl suspend";
-          type = types.nullOr types.string;
+          example = "${pkgs.systemd}/bin/systemctl suspend";
+          type = types.nullOr types.str;
 
           description = ''
             The script to use when nothing has happend for as long as <option>killtime</option>
@@ -131,6 +129,12 @@ in
           assertion = cfg.killer != null -> cfg.killtime >= 10;
           message = "killtime has to be at least 10 minutes according to `man xautolock`";
         }
-      ];
+      ] ++ (lib.flip map [ "locker" "notifier" "nowlocker" "killer" ]
+        (option:
+        {
+          assertion = cfg."${option}" != null -> builtins.substring 0 1 cfg."${option}" == "/";
+          message = "Please specify a canonical path for `services.xserver.xautolock.${option}`";
+        })
+      );
     };
   }