bspwm module: refactor

Changed files
+56 -77
nixos
modules
-1
nixos/modules/module-list.nix
···
./services/x11/window-managers/fluxbox.nix
./services/x11/window-managers/icewm.nix
./services/x11/window-managers/bspwm.nix
-
./services/x11/window-managers/bspwm-unstable.nix
./services/x11/window-managers/metacity.nix
./services/x11/window-managers/none.nix
./services/x11/window-managers/twm.nix
-48
nixos/modules/services/x11/window-managers/bspwm-unstable.nix
···
-
{ config, lib, pkgs, ... }:
-
-
with lib;
-
-
let
-
cfg = config.services.xserver.windowManager.bspwm-unstable;
-
in
-
-
{
-
options = {
-
services.xserver.windowManager.bspwm-unstable = {
-
enable = mkEnableOption "bspwm-unstable";
-
startThroughSession = mkOption {
-
type = with types; bool;
-
default = false;
-
description = "
-
Start the window manager through the script defined in
-
sessionScript. Defaults to the the bspwm-session script
-
provided by bspwm
-
";
-
};
-
sessionScript = mkOption {
-
default = "${pkgs.bspwm-unstable}/bin/bspwm-session";
-
defaultText = "(pkgs.bspwm-unstable)/bin/bspwm-session";
-
description = "
-
The start-session script to use. Defaults to the
-
provided bspwm-session script from the bspwm package.
-
-
Does nothing unless `bspwm.startThroughSession` is enabled
-
";
-
};
-
};
-
};
-
-
config = mkIf cfg.enable {
-
services.xserver.windowManager.session = singleton {
-
name = "bspwm-unstable";
-
start = if cfg.startThroughSession
-
then cfg.sessionScript
-
else ''
-
export _JAVA_AWT_WM_NONREPARENTING=1
-
SXHKD_SHELL=/bin/sh ${pkgs.sxhkd-unstable}/bin/sxhkd -f 100 &
-
${pkgs.bspwm-unstable}/bin/bspwm
-
'';
-
};
-
environment.systemPackages = [ pkgs.bspwm-unstable ];
-
};
-
}
+56 -27
nixos/modules/services/x11/window-managers/bspwm.nix
···
{
options = {
services.xserver.windowManager.bspwm = {
-
enable = mkEnableOption "bspwm";
-
startThroughSession = mkOption {
-
type = with types; bool;
-
default = false;
-
description = "
-
Start the window manager through the script defined in
-
sessionScript. Defaults to the the bspwm-session script
-
provided by bspwm
-
";
+
enable = mkEnableOption "bspwm";
+
+
package = mkOption {
+
type = types.package;
+
default = pkgs.bspwm;
+
defaultText = "pkgs.bspwm";
+
example = "pkgs.bspwm-unstable";
+
description = ''
+
bspwm package to use.
+
'';
+
};
+
configFile = mkOption {
+
type = with types; nullOr path;
+
example = "${pkgs.bspwm}/share/doc/bspwm/examples/bspwmrc";
+
default = null;
+
description = ''
+
Path to the bspwm configuration file.
+
If null, $HOME/.config/bspwm/bspwmrc will be used.
+
'';
+
};
+
+
sxhkd = {
+
package = mkOption {
+
type = types.package;
+
default = pkgs.sxhkd;
+
defaultText = "pkgs.sxhkd";
+
example = "pkgs.sxhkd-unstable";
+
description = ''
+
sxhkd package to use.
+
'';
};
-
sessionScript = mkOption {
-
default = "${pkgs.bspwm}/bin/bspwm-session";
-
defaultText = "(pkgs.bspwm)/bin/bspwm-session";
-
description = "
-
The start-session script to use. Defaults to the
-
provided bspwm-session script from the bspwm package.
-
-
Does nothing unless `bspwm.startThroughSession` is enabled
-
";
+
configFile = mkOption {
+
type = with types; nullOr path;
+
example = "${pkgs.bspwm}/share/doc/bspwm/examples/sxhkdrc";
+
default = null;
+
description = ''
+
Path to the sxhkd configuration file.
+
If null, $HOME/.config/sxhkd/sxhkdrc will be used.
+
'';
};
+
};
};
};
config = mkIf cfg.enable {
services.xserver.windowManager.session = singleton {
-
name = "bspwm";
-
start = if cfg.startThroughSession
-
then cfg.sessionScript
-
else ''
-
export _JAVA_AWT_WM_NONREPARENTING=1
-
SXHKD_SHELL=/bin/sh ${pkgs.sxhkd}/bin/sxhkd -f 100 &
-
${pkgs.bspwm}/bin/bspwm
-
'';
+
name = "bspwm";
+
start = ''
+
export _JAVA_AWT_WM_NONREPARENTING=1
+
SXHKD_SHELL=/bin/sh ${cfg.sxhkd.package}/bin/sxhkd ${optionalString (cfg.sxhkd.configFile != null) "-c \"${cfg.sxhkd.configFile}\""} &
+
${cfg.package}/bin/bspwm ${optionalString (cfg.configFile != null) "-c \"${cfg.configFile}\""}
+
waitPID=$!
+
'';
};
-
environment.systemPackages = [ pkgs.bspwm ];
+
environment.systemPackages = [ cfg.package ];
};
+
+
imports = [
+
(mkRemovedOptionModule [ "services" "xserver" "windowManager" "bspwm-unstable" "enable" ]
+
"Use services.xserver.windowManager.bspwm.enable and set services.xserver.windowManager.bspwm.package to pkgs.bspwm-unstable to use the unstable version of bspwm.")
+
(mkRemovedOptionModule [ "services" "xserver" "windowManager" "bspwm" "startThroughSession" ]
+
"bspwm package does not provide bspwm-session anymore.")
+
(mkRemovedOptionModule [ "services" "xserver" "windowManager" "bspwm" "sessionScript" ]
+
"bspwm package does not provide bspwm-session anymore.")
+
];
}
-1
nixos/modules/services/x11/window-managers/default.nix
···
imports = [
./afterstep.nix
./bspwm.nix
-
./bspwm-unstable.nix
./compiz.nix
./dwm.nix
./exwm.nix