From f0f9961626cb5155c3849133531b13b97b847595 Mon Sep 17 00:00:00 2001 From: Dmitriy Pleshevskiy Date: Sun, 18 Feb 2024 23:06:36 +0300 Subject: [PATCH] refac: configure xmonad projects via host --- home/modules/terminal/wezterm.nix | 2 +- home/modules/window_manager/xmonad.nix | 116 ++++++++++++------ home/modules/window_manager/xmonad_config.hs | 24 +--- .../asus-gl553vd/xmonad_projects.secret.nix | Bin 0 -> 949 bytes nixos/hosts/default.nix | 10 +- nixos/hosts/home/xmonad_projects.secret.nix | Bin 0 -> 777 bytes 6 files changed, 85 insertions(+), 67 deletions(-) create mode 100644 nixos/hosts/asus-gl553vd/xmonad_projects.secret.nix create mode 100644 nixos/hosts/home/xmonad_projects.secret.nix diff --git a/home/modules/terminal/wezterm.nix b/home/modules/terminal/wezterm.nix index 86fb257..b782cec 100644 --- a/home/modules/terminal/wezterm.nix +++ b/home/modules/terminal/wezterm.nix @@ -1,4 +1,4 @@ -{ lib, config, pkgs, ... }: +{ lib, config, ... }: let cfg = config.local.wezterm; diff --git a/home/modules/window_manager/xmonad.nix b/home/modules/window_manager/xmonad.nix index 9c8518b..80a440f 100644 --- a/home/modules/window_manager/xmonad.nix +++ b/home/modules/window_manager/xmonad.nix @@ -1,51 +1,87 @@ -{ config, lib, pkgs, ... }: +{ config, pkgs, lib, ... }: -let themeCfg = config.local.theme; in -{ - home.packages = with pkgs; [ - xclip # access x clipboard from a console - dmenu # menu for x window system - nitrogen # wallpaper manager - ]; +let + cfg = config.local.xmonad; + themeCfg = config.local.theme; - xsession = { - enable = true; - - windowManager.xmonad = { - enable = true; - enableContribAndExtras = true; - - haskellPackages = pkgs.unstable.haskellPackages; - extraPackages = (hp: [ - hp.dbus - hp.monad-logger - ]); - - config = pkgs.substituteAll { - src = ./xmonad_config.hs; - inherit (themeCfg.bar) background mainText inactiveText; - inherit (themeCfg.window) activeBorder inactiveBorder; - inherit (themeCfg.highlights) critical warning success; - inherit (themeCfg.syntax) mark1 mark2 mark3; - kdbBrightnessScriptPath = "${./scripts/kdb_brightness.sh}"; + projectType = with lib; types.submodule { + options = { + name = mkOption { + type = types.str; + }; + startHook = mkOption { + type = types.lines; }; }; - initExtra = '' - ${pkgs.nitrogen}/bin/nitrogen --restore & - ''; }; - services.flameshot = { - enable = true; + mkXmonadProject = { name, startHook }: + '' + Project { + projectName = "${name}", + projectStartHook = ${lib.removeSuffix startHook} + } + ''; - # See: https://github.com/flameshot-org/flameshot/blob/master/flameshot.example.ini - settings = { - General = { - disabledTrayIcon = true; - savePathFixed = true; - showDesktopNotification = false; - showSidePanelButton = true; + xmonadProjects = lib.concatStringsSep ",\n" (map mkXmonadProject cfg.projects); +in +{ + options.local.xmonad = with lib; + { + projects = mkOption { + type = types.listOf projectType; + default = [ ]; + }; + }; + + config = { + home.packages = with pkgs; [ + xclip # access x clipboard from a console + dmenu # menu for x window system + nitrogen # wallpaper manager + ]; + + xsession = { + enable = true; + + windowManager.xmonad = { + enable = true; + enableContribAndExtras = true; + + haskellPackages = pkgs.unstable.haskellPackages; + extraPackages = (hp: [ + hp.dbus + hp.monad-logger + ]); + + config = pkgs.substituteAll { + src = ./xmonad_config.hs; + projects = "\n" + xmonadProjects; + inherit (themeCfg.bar) background mainText inactiveText; + inherit (themeCfg.window) activeBorder inactiveBorder; + inherit (themeCfg.highlights) critical warning success; + inherit (themeCfg.syntax) mark1 mark2 mark3; + kdbBrightnessScriptPath = "${./scripts/kdb_brightness.sh}"; + }; + }; + + initExtra = '' + ${pkgs.nitrogen}/bin/nitrogen --restore & + ''; + }; + + services.flameshot = { + enable = true; + + # See: https://github.com/flameshot-org/flameshot/blob/master/flameshot.example.ini + settings = { + General = { + disabledTrayIcon = true; + savePathFixed = true; + showDesktopNotification = false; + showSidePanelButton = true; + }; }; }; }; diff --git a/home/modules/window_manager/xmonad_config.hs b/home/modules/window_manager/xmonad_config.hs index c711bed..550cb5b 100644 --- a/home/modules/window_manager/xmonad_config.hs +++ b/home/modules/window_manager/xmonad_config.hs @@ -383,29 +383,7 @@ myMouseBindings (XConfig {XMonad.modMask = modm}) = myProjects :: [Project] myProjects = - [ -- my work - Project - { projectName = "bm-back", - projectStartHook = do - let workdir = "~/projects/binarymanagement/bm-back" - spawn $ terminal' workdir $ Just "docker-compose -f docker-compose.dev.yml up -d" - replicateM_ 3 $ spawn $ terminal workdir - }, - Project - { projectName = "bm-front", - projectStartHook = do - let workdir = "~/projects/binarymanagement/bm-front" - replicateM_ 3 $ spawn $ terminal workdir - }, - -- personal - Project - { projectName = "system", - projectStartHook = replicateM_ 2 $ spawn $ terminal "~/repos/mynix/system" - }, - Project - { projectName = "neovim", - projectStartHook = replicateM_ 2 $ spawn $ terminal "~/repos/mynix/neovim" - } + [ -- @projects@ ] where terminal :: String -> String diff --git a/nixos/hosts/asus-gl553vd/xmonad_projects.secret.nix b/nixos/hosts/asus-gl553vd/xmonad_projects.secret.nix new file mode 100644 index 0000000000000000000000000000000000000000..fe978adfd6e80945a17774ab30f23ae42f29f37f GIT binary patch literal 949 zcmV;m14{e=M@dveQdv+`034$0JBK$#=*aIofB5VOS`qdbn2>S|?x&B9kCb%!NF0~iU#4rR!U`U6L(`Z{ zP~%n$3efI<4WqD=<2<400Qc5NF|a2lQC#*{aRC3Mq0*32%>GUZ8;X8xCv3vjOSl2P ztsEPQgPl;F{X;@V^5eihFcz9-J|adFi^TgH%8(e5H1F+r7|)J{Ms_(a>r!f}6!pM; zi4y~;Y=61hy8&Ncz$Qt9)BdAF{J}i6_z+Ggc;;oJwfozvpXqWk2O2$TzH__P8HsGF z93G8e{K|h_3kvK&SI&&;(UNX3YKYOTPGJOjFKZuGHuK2Y(hzE7AIY%dL`ktie}#hX z(|Aiqep8#NzhVk8O@tSSH8d{A+LdQ+^&qF3u>o!E+D*OSHq0asyT-$G_r-eFsYI*j znWs%v*z?$vBNbh`mHEZPQ{6uQTlq1OT0OiA>c zD7;+gysDCd<(G}J;!7+otlDsi+`fjedi7+MR5WkaJI512Vu10N+Xs0E7>3h)+T%R~ z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