1{ config, pkgs, lib, ... }: 2 3with lib; 4 5let 6 cfg = config.services.xserver.windowManager.qtile; 7 pyEnv = pkgs.python3.withPackages (p: [ (cfg.package.unwrapped or cfg.package) ] ++ (cfg.extraPackages p)); 8in 9 10{ 11 options.services.xserver.windowManager.qtile = { 12 enable = mkEnableOption (lib.mdDoc "qtile"); 13 14 package = mkPackageOptionMD pkgs "qtile-unwrapped" { }; 15 16 configFile = mkOption { 17 type = with types; nullOr path; 18 default = null; 19 example = literalExpression "./your_config.py"; 20 description = lib.mdDoc '' 21 Path to the qtile configuration file. 22 If null, $XDG_CONFIG_HOME/qtile/config.py will be used. 23 ''; 24 }; 25 26 backend = mkOption { 27 type = types.enum [ "x11" "wayland" ]; 28 default = "x11"; 29 description = lib.mdDoc '' 30 Backend to use in qtile: `x11` or `wayland`. 31 ''; 32 }; 33 34 extraPackages = mkOption { 35 type = types.functionTo (types.listOf types.package); 36 default = _: []; 37 defaultText = literalExpression '' 38 python3Packages: with python3Packages; []; 39 ''; 40 description = lib.mdDoc '' 41 Extra Python packages available to Qtile. 42 An example would be to include `python3Packages.qtile-extras` 43 for additional unofficial widgets. 44 ''; 45 example = literalExpression '' 46 python3Packages: with python3Packages; [ 47 qtile-extras 48 ]; 49 ''; 50 }; 51 }; 52 53 config = mkIf cfg.enable { 54 services.xserver.windowManager.session = [{ 55 name = "qtile"; 56 start = '' 57 ${pyEnv}/bin/qtile start -b ${cfg.backend} \ 58 ${optionalString (cfg.configFile != null) 59 "--config \"${cfg.configFile}\""} & 60 waitPID=$! 61 ''; 62 }]; 63 64 environment.systemPackages = [ 65 # pkgs.qtile is currently a buildenv of qtile and its dependencies. 66 # For userland commands, we want the underlying package so that 67 # packages such as python don't bleed into userland and overwrite intended behavior. 68 (cfg.package.unwrapped or cfg.package) 69 ]; 70 }; 71}