From c56517497aade457c83426c890262c9cb9b42e7e Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Mon, 5 Apr 2021 21:27:20 +0000 Subject: [PATCH] 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... --- home/wm/default.nix | 19 ++++++++++++++++++- home/wm/i3bar.nix | 4 ++-- home/wm/rofi.nix | 4 ++-- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/home/wm/default.nix b/home/wm/default.nix index 55669eb..2421a50 100644 --- a/home/wm/default.nix +++ b/home/wm/default.nix @@ -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" ]; + }; }; } diff --git a/home/wm/i3bar.nix b/home/wm/i3bar.nix index 186a863..b1358b9 100644 --- a/home/wm/i3bar.nix +++ b/home/wm/i3bar.nix @@ -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 diff --git a/home/wm/rofi.nix b/home/wm/rofi.nix index b2fb32f..87f167a 100644 --- a/home/wm/rofi.nix +++ b/home/wm/rofi.nix @@ -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;