system/modules/home-manager/configs/window-manager/xmonad/default.nix

112 lines
2.8 KiB
Nix
Raw Permalink Normal View History

{ config, pkgs, lib, ... }:
2022-10-12 01:41:32 +03:00
let
2024-04-16 02:51:46 +03:00
cfg = config.local.window-manager.xmonad;
themeCfg = config.local.themes."${config.local.theme.name}";
projectType = with lib; types.submodule {
options = {
name = mkOption {
type = types.str;
};
workdir = mkOption {
type = types.str;
};
windowCount = mkOption {
type = types.ints.positive;
default = 1;
};
terminalCommands = mkOption {
type = types.listOf types.str;
default = [ ];
};
spawnPrograms = mkOption {
type = types.listOf types.str;
default = [ ];
};
};
};
mkXmonadProjectSpawnProgram = program:
"spawn \"${program}\"";
mkXmonadProjectTerminalCommand = command:
"spawn $ terminal' workdir $ Just \"${command}\"";
mkXmonadProject = { name, workdir, windowCount, spawnPrograms, terminalCommands }:
''
Project {
projectName = "${name}",
projectStartHook =
do
let workdir = "${workdir}"
2024-04-16 17:59:16 +03:00
${lib.concatMapStringsSep "\n" mkXmonadProjectSpawnProgram spawnPrograms}
${lib.concatMapStringsSep "\n" mkXmonadProjectTerminalCommand terminalCommands}
replicateM_ ${toString windowCount} $ spawn $ terminal workdir
}
'';
2024-04-16 17:59:16 +03:00
xmonadProjects = lib.concatMapStringsSep " , " mkXmonadProject cfg.projects;
in
2022-10-12 01:41:32 +03:00
{
2024-04-16 02:51:46 +03:00
options.local.window-manager.xmonad = with lib; {
enable = mkEnableOption "xmonad window manager";
projects = mkOption {
type = types.listOf projectType;
default = [ ];
};
2024-04-16 02:51:46 +03:00
};
2022-10-12 01:41:32 +03:00
2024-04-16 02:51:46 +03:00
config = lib.mkIf cfg.enable {
home.packages = with pkgs; [
xclip # access x clipboard from a console
dmenu # menu for x window system
nitrogen # wallpaper manager
rofimoji # emoji picker
];
2022-10-12 01:41:32 +03:00
programs.rofi.pass = {
enable = true;
extraConfig = ''
EDITOR='wezterm start -- nvim'
URL_field='url'
USERNAME_field='login'
AUTOTYPE_field='autotype'
default_autotype='user :tab pass'
'';
};
xsession = {
2022-10-12 01:41:32 +03:00
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;
2024-02-19 00:19:37 +03:00
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;
2024-04-24 10:19:30 +03:00
kdbBrightnessScriptPath = "${../scripts/kdb_brightness.sh}";
};
};
2022-10-12 01:41:32 +03:00
initExtra = ''
${pkgs.nitrogen}/bin/nitrogen --restore &
'';
};
2022-10-17 17:43:12 +03:00
};
2022-10-12 01:41:32 +03:00
}