97 lines
2.6 KiB
Nix
97 lines
2.6 KiB
Nix
{ config, pkgs, lib, ... }:
|
|
|
|
let
|
|
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}"
|
|
${lib.concatMapStringsSep "\n" mkXmonadProjectSpawnProgram spawnPrograms}
|
|
${lib.concatMapStringsSep "\n" mkXmonadProjectTerminalCommand terminalCommands}
|
|
replicateM_ ${toString windowCount} $ spawn $ terminal workdir
|
|
}
|
|
'';
|
|
|
|
xmonadProjects = lib.concatMapStringsSep " , " mkXmonadProject cfg.projects;
|
|
in
|
|
{
|
|
options.local.window-manager.xmonad = with lib; {
|
|
enable = mkEnableOption "xmonad window manager";
|
|
projects = mkOption {
|
|
type = types.listOf projectType;
|
|
default = [ ];
|
|
};
|
|
};
|
|
|
|
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
|
|
];
|
|
|
|
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 &
|
|
'';
|
|
};
|
|
};
|
|
}
|