home: wm: use explicit 'enable' options

This is so that I can explicitly enable them if I were to use Wayland
and Sway, given that they should be compatible with both environment.

This also means that putting them in `/home/x/` would a misnomer... Will
revisit this if and when I try out Wayland and sway...
This commit is contained in:
Bruno BELANYI 2021-04-05 21:27:20 +00:00
parent 38a475d35d
commit c56517497a
3 changed files with 22 additions and 5 deletions

View File

@ -1,4 +1,13 @@
{ lib, ... }:
{ config, lib, ... }:
let
mkRelatedOption = description: relatedWMs:
let
isActivatedWm = wm: config.my.home.wm.windowManager == wm;
in
(lib.mkEnableOption description) // {
default = builtins.any isActivatedWm relatedWMs;
};
in
{
imports = [
./i3.nix
@ -13,5 +22,13 @@
example = "i3";
description = "Which window manager to use for home session";
};
i3bar = {
enable = mkRelatedOption "i3bar configuration" [ "i3" ];
};
rofi = {
enable = mkRelatedOption "rofi menu" [ "i3" ];
};
};
}

View File

@ -1,9 +1,9 @@
{ config, lib, pkgs, ... }:
let
isEnabled = config.my.home.wm.windowManager == "i3";
cfg = config.my.home.wm.i3bar;
in
{
config = lib.mkIf isEnabled {
config = lib.mkIf cfg.enable {
home.packages = with pkgs; [
alsaUtils # Used by `sound` block
lm_sensors # Used by `temperature` block

View File

@ -1,9 +1,9 @@
{ config, lib, pkgs, ... }:
let
isEnabled = config.my.home.wm.windowManager == "i3";
cfg = config.my.home.wm.rofi;
in
{
config = lib.mkIf isEnabled {
config = lib.mkIf cfg.enable {
programs.rofi = {
enable = true;