1{ config, lib, pkgs, ... }: 2 3with lib; 4 5let 6 7 # Remove packages of ys from xs, based on their names 8 removePackagesByName = xs: ys: 9 let 10 pkgName = drv: (builtins.parseDrvName drv.name).name; 11 ysNames = map pkgName ys; 12 in 13 filter (x: !(builtins.elem (pkgName x) ysNames)) xs; 14 15 xcfg = config.services.xserver; 16 cfg = xcfg.desktopManager.lxqt; 17 18in 19 20{ 21 options = { 22 23 services.xserver.desktopManager.lxqt.enable = mkOption { 24 type = types.bool; 25 default = false; 26 description = "Enable the LXQt desktop manager"; 27 }; 28 29 environment.lxqt.excludePackages = mkOption { 30 default = []; 31 example = literalExample "[ pkgs.lxqt.qterminal ]"; 32 type = types.listOf types.package; 33 description = "Which LXQt packages to exclude from the default environment"; 34 }; 35 36 }; 37 38 config = mkIf (xcfg.enable && cfg.enable) { 39 40 services.xserver.desktopManager.session = singleton { 41 name = "lxqt"; 42 bgSupport = true; 43 start = '' 44 # Upstream installs default configuration files in 45 # $prefix/share/lxqt instead of $prefix/etc/xdg, (arguably) 46 # giving distributors freedom to ship custom default 47 # configuration files more easily. In order to let the session 48 # manager find them the share subdirectory is added to the 49 # XDG_CONFIG_DIRS environment variable. 50 # 51 # For an explanation see 52 # https://github.com/lxqt/lxqt/issues/1521#issuecomment-405097453 53 # 54 export XDG_CONFIG_DIRS=$XDG_CONFIG_DIRS''${XDG_CONFIG_DIRS:+:}${config.system.path}/share 55 56 exec ${pkgs.lxqt.lxqt-session}/bin/startlxqt 57 ''; 58 }; 59 60 environment.systemPackages = 61 pkgs.lxqt.preRequisitePackages ++ 62 pkgs.lxqt.corePackages ++ 63 (removePackagesByName 64 pkgs.lxqt.optionalPackages 65 config.environment.lxqt.excludePackages); 66 67 # Link some extra directories in /run/current-system/software/share 68 environment.pathsToLink = [ "/share" ]; 69 70 environment.variables.GIO_EXTRA_MODULES = [ "${pkgs.gvfs}/lib/gio/modules" ]; 71 72 services.upower.enable = config.powerManagement.enable; 73 }; 74 75}