diff options
author | rnhmjoj <rnhmjoj@inventati.org> | 2017-10-16 23:52:42 +0200 |
---|---|---|
committer | rnhmjoj <rnhmjoj@inventati.org> | 2017-10-17 00:50:34 +0200 |
commit | 36bbc3cfda6ca2fa4e9dee29cda925c966cda03b (patch) | |
tree | 4e3fba420e6a089b73a472441296f7de87274277 /nixos | |
parent | 2a036ca1a5eafdaed11be14d14a91c3b24508379 (diff) | |
download | nixlib-36bbc3cfda6ca2fa4e9dee29cda925c966cda03b.tar nixlib-36bbc3cfda6ca2fa4e9dee29cda925c966cda03b.tar.gz nixlib-36bbc3cfda6ca2fa4e9dee29cda925c966cda03b.tar.bz2 nixlib-36bbc3cfda6ca2fa4e9dee29cda925c966cda03b.tar.lz nixlib-36bbc3cfda6ca2fa4e9dee29cda925c966cda03b.tar.xz nixlib-36bbc3cfda6ca2fa4e9dee29cda925c966cda03b.tar.zst nixlib-36bbc3cfda6ca2fa4e9dee29cda925c966cda03b.zip |
nixos/compton: improve options type-checking
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/modules/services/x11/compton.nix | 69 |
1 files changed, 41 insertions, 28 deletions
diff --git a/nixos/modules/services/x11/compton.nix b/nixos/modules/services/x11/compton.nix index 42ceeb819806..fcccf98c9cff 100644 --- a/nixos/modules/services/x11/compton.nix +++ b/nixos/modules/services/x11/compton.nix @@ -7,12 +7,15 @@ let cfg = config.services.compton; - configFile = let - opacityRules = optionalString (length cfg.opacityRules != 0) - (concatStringsSep "\n" - (map (a: "opacity-rule = [ \"${a}\" ];") cfg.opacityRules) - ); - in pkgs.writeText "compton.conf" + floatBetween = a: b: with lib; with types; + addCheck str (x: versionAtLeast x a && versionOlder x b); + + pairOf = x: with types; addCheck (listOf x) (y: lib.length y == 2); + + opacityRules = optionalString (length cfg.opacityRules != 0) + (concatMapStringsSep ",\n" (rule: ''"${rule}"'') cfg.opacityRules); + + configFile = pkgs.writeText "compton.conf" (optionalString cfg.fade '' # fading fading = true; @@ -36,7 +39,9 @@ let inactive-opacity = ${cfg.inactiveOpacity}; menu-opacity = ${cfg.menuOpacity}; - ${opacityRules} + opacity-rule = [ + ${opacityRules} + ]; # other options backend = ${toJSON cfg.backend}; @@ -64,7 +69,7 @@ in { }; fadeDelta = mkOption { - type = types.int; + type = types.addCheck types.int (x: x > 0); default = 10; example = 5; description = '' @@ -73,11 +78,12 @@ in { }; fadeSteps = mkOption { - type = types.listOf types.str; + type = pairOf (floatBetween "0.01" "1.01"); default = [ "0.028" "0.03" ]; example = [ "0.04" "0.04" ]; description = '' Opacity change between fade steps (in and out). + (numbers in range 0.01 - 1.0) ''; }; @@ -104,7 +110,7 @@ in { }; shadowOffsets = mkOption { - type = types.listOf types.int; + type = pairOf types.int; default = [ (-15) (-15) ]; example = [ (-10) (-15) ]; description = '' @@ -113,11 +119,11 @@ in { }; shadowOpacity = mkOption { - type = types.str; + type = floatBetween "0.0" "1.01"; default = "0.75"; example = "0.8"; description = '' - Window shadows opacity (number in range 0 - 1). + Window shadows opacity (number in range 0.0 - 1.0). ''; }; @@ -136,42 +142,46 @@ in { }; activeOpacity = mkOption { - type = types.str; + type = floatBetween "0.0" "1.01"; default = "1.0"; example = "0.8"; description = '' - Opacity of active windows. + Opacity of active windows (number in range 0.0 - 1.0). ''; }; inactiveOpacity = mkOption { - type = types.str; + type = floatBetween "0.1" "1.01"; default = "1.0"; example = "0.8"; description = '' - Opacity of inactive windows. + Opacity of inactive windows (number in range 0.1 - 1.0). ''; }; menuOpacity = mkOption { - type = types.str; + type = floatBetween "0.0" "1.01"; default = "1.0"; example = "0.8"; description = '' - Opacity of dropdown and popup menu. + Opacity of dropdown and popup menu (number in range 0.0 - 1.0). ''; }; opacityRules = mkOption { type = types.listOf types.str; default = []; + example = [ + "95:class_g = 'URxvt' && !_NET_WM_STATE@:32a" + "0:_NET_WM_STATE@:32a *= '_NET_WM_STATE_HIDDEN'" + ]; description = '' - Opacity rules to be handled by compton. + Rules that control the opacity of windows, in format PERCENT:PATTERN. ''; }; backend = mkOption { - type = types.str; + type = types.enum [ "glx" "xrender" ]; default = "glx"; description = '' Backend to use: <literal>glx</literal> or <literal>xrender</literal>. @@ -179,17 +189,20 @@ in { }; vSync = mkOption { - type = types.str; - default = "none"; - example = "opengl-swc"; - description = '' - Enable vertical synchronization using the specified method. - See <literal>compton(1)</literal> man page available methods. - ''; + type = types.enum [ + "none" "drm" "opengl" + "opengl-oml" "opengl-swc" "opengl-mswc" + ]; + default = "none"; + example = "opengl-swc"; + description = '' + Enable vertical synchronization using the specified method. + See <literal>compton(1)</literal> man page an explanation. + ''; }; refreshRate = mkOption { - type = types.int; + type = types.addCheck types.int (x: x >= 0); default = 0; example = 60; description = '' |