nix-config/home/desktop-xmonad/default.nix

389 lines
11 KiB
Nix

{ config, pkgs, ... }:
let
gruvbox-dark = {
bg = "#282828";
bg1 = "#3c3836";
bg2 = "#504945";
fg = "#ebdbb2";
fg0 = "#fbf1c7";
fg3 = "#bdae93";
red = "#cc241d";
green = "#98971a";
yellow = "#d79921";
blue = "#458588";
purple = "#b16286";
aqua = "#689d6a";
gray = "#a89984";
gray2 = "#928374";
red-light = "#fb4934";
green-light = "#b8bb26";
yellow-light = "#fabd2f";
blue-light = "#83a598";
purple-light = "#d3869b";
aqua-light = "#8ec07c";
};
colors = {
fg = gruvbox-dark.fg;
selFg = gruvbox-dark.fg0;
bg = gruvbox-dark.bg;
sel = gruvbox-dark.blue;
inactive = gruvbox-dark.gray;
inactiveBorder = gruvbox-dark.bg2;
urgent = gruvbox-dark.red;
};
rofiTransparency = "96";
font = {
name = "Inter";
size = "10";
};
monoFont = {
name = "Hack";
size = "9";
};
hmonitors = pkgs.haskellPackages.callPackage ./hmonitors.nix {};
obtoxmd = pkgs.callPackage ./obtoxmd.nix { inherit config pkgs; };
hmonitorsQuery = "${hmonitors}/bin/hmonitors-query";
acpi = "${pkgs.acpi}/bin/acpi";
nmcli = "${pkgs.networkmanager}/bin/nmcli";
pamixer = "${pkgs.pamixer}/bin/pamixer";
in
{
imports = [ ./autorandr.nix ./misc.nix ];
home = {
keyboard = {
layout = "us";
options = ["caps:escape"];
variant = "altgr-intl";
};
packages = [hmonitors obtoxmd pkgs.acpi pkgs.pamixer pkgs.openbox];
file = {
".xinitrc".text = "exec ${config.home.homeDirectory}/.xsession";
".xmonad/icons/3cols.xpm".source = ./icons/3cols.xpm;
".xmonad/icons/float.xpm".source = ./icons/float.xpm;
".xmonad/icons/full.xpm".source = ./icons/full.xpm;
".xmonad/icons/grid.xpm".source = ./icons/grid.xpm;
".xmonad/icons/mtall.xpm".source = ./icons/mtall.xpm;
".xmonad/icons/tabs.xpm".source = ./icons/tabs.xpm;
".xmonad/icons/tall.xpm".source = ./icons/tall.xpm;
};
};
xsession = {
enable = true;
initExtra = ''
xset s off -dpms
${pkgs.autorandr}/bin/autorandr --change --default default
export WINIT_X11_SCALE_FACTOR=1.33
'';
windowManager.xmonad = {
enable = true;
enableContribAndExtras = true;
extraPackages = haskellPackages : [
haskellPackages.monad-logger
haskellPackages.dbus
];
config = ./xmonad/xmonad.hs;
libFiles = {
"Bindings.hs" = ./xmonad/lib/Bindings.hs;
"DefaultConfig.hs" = ./xmonad/lib/DefaultConfig.hs;
"Layouts.hs" = ./xmonad/lib/Layouts.hs;
"ManageHook.hs" = ./xmonad/lib/ManageHook.hs;
"Prompts.hs" = ./xmonad/lib/Prompts.hs;
"Utils.hs" = ./xmonad/lib/Utils.hs;
"Xmobar.hs" = ./xmonad/lib/Xmobar.hs;
"HostConfig.hs" = pkgs.writeText "HostConfig.hs" ''
module HostConfig
( fontConfig
, colorConfig
, FontConfig (FontConfig)
, fontSize
, fontName
, ColorConfig (ColorConfig)
, fgColor
, selFgColor
, bgColor
, selColor
, inactiveColor
, inactiveBorderColor
, urgentColor
) where
fontConfig :: FontConfig
fontConfig = FontConfig
{ fontSize = ${font.size}
, fontName = "${font.name}"
}
colorConfig :: ColorConfig
colorConfig = ColorConfig
{ fgColor = "${colors.fg}"
, selFgColor = "${colors.selFg}"
, bgColor = "${colors.bg}"
, selColor = "${colors.sel}"
, inactiveColor = "${colors.inactive}"
, inactiveBorderColor = "${colors.inactiveBorder}"
, urgentColor = "${colors.urgent}"
}
data FontConfig = FontConfig
{ fontSize :: Int
, fontName :: String
} deriving Show
data ColorConfig = ColorConfig
{ fgColor :: String
, selFgColor :: String
, bgColor :: String
, selColor :: String
, inactiveColor :: String
, inactiveBorderColor :: String
, urgentColor :: String
} deriving Show
'';
};
};
};
programs.xmobar = {
enable = true;
extraConfig = ''
Config
{ font = "xft:${font.name}:style=Regular:size=${font.size}"
, additionalFonts = ["xft:mplus Nerd Font:size=12"]
, bgColor = "${colors.bg}"
, fgColor = "${colors.fg}"
, alignSep = "}{"
, sepChar = "%"
, template = "%StdinReader% }{ %vol%%bat%%net%%date%"
, lowerOnStart = True
, hideOnStart = False
, persistent = True
, allDesktops = True
, position = TopW L 100
, commands =
[ Run Com "${hmonitorsQuery}" ["date" ] "date" 10
, Run Com "${hmonitorsQuery}" ["bat", "${acpi}" ] "bat" 10
, Run Com "${hmonitorsQuery}" ["net", "${nmcli}" ] "net" 20
, Run Com "${hmonitorsQuery}" ["vol", "${pamixer}"] "vol" 5
, Run StdinReader
]
}
'';
};
programs.rofi = {
enable = true;
font = "${font.name} ${font.size}";
extraConfig = {
display-run = " ";
# display-drun = " ";
display-window = " ";
drun-display-format = "{name}";
modi = "window,run,drun,ssh";
show-icons = false;
};
theme = let
inherit (config.lib.formats.rasi) mkLiteral;
in {
"*" = {
background-color = mkLiteral "transparent";
border = 0;
margin = 0;
padding = 0;
spacing = 0;
};
element = {
padding = 2;
orientation = "vertical";
};
"element-text" = {
text-color = mkLiteral colors.fg;
};
"element selected" = {
text-color = mkLiteral colors.selFg;
background-color = mkLiteral "${colors.sel}A0";
};
entry = {
padding = mkLiteral "0 0 6 3";
text-color = mkLiteral colors.fg;
};
inputbar = {
children = map mkLiteral ["prompt" "entry"];
border = mkLiteral "0 0 1 0";
border-color = mkLiteral gruvbox-dark.gray2;
margin = mkLiteral "0 0 5 0";
};
listview = {
columns = 1;
fixed-height = false;
};
mainbox = {
children = map mkLiteral ["inputbar" "listview"];
margin = 6;
};
prompt = {
padding = mkLiteral "0 0 0 6";
text-color = mkLiteral colors.fg;
background-color = mkLiteral "transparent";
};
window = {
transparency = "real";
background-color = mkLiteral "${colors.bg}D0";
y-offset = mkLiteral "-25%";
border = 2;
border-color = mkLiteral colors.sel;
};
};
terminal = "${pkgs.alacritty}/bin/alacritty";
pass = {
enable = true;
extraConfig = ''
URL_field='url'
USERNAME_field='user'
AUTOTYPE_field='autotype'
delay=2
wait=0.2
xdotool_delay=12
EDITOR='gvim -f'
BROWSER='xdg-open'
default_do='typePass' # menu, autotype, copyPass, typeUser, typePass, copyUser, copyUrl, viewEntry, typeMenu, actionMenu, copyMenu, openUrl
auto_enter='false'
notify='false'
default_autotype='user :tab pass'
help_color="${gruvbox-dark.blue-light}"
clip=primary
clip_clear=45
edit_new_pass="true"
default_user=":filename"
autotype="Alt+1"
type_user="Alt+u"
type_pass="Alt+p"
copy_name=""
copy_pass=""
'';
};
};
services.dunst = {
enable = true;
iconTheme = {
name = "Papirus-Dark";
package = pkgs.papirus-icon-theme;
};
settings = {
global = {
font = "${font.name} ${font.size}";
format = ''<b>%s</b>\n%b'';
sort = "yes";
indicate_hidden = "yes";
alignment = "left";
bounce_freq = 0;
show_age_threshold = 60;
word_wrap = "yes";
ignore_newline = "no";
geometry = "300x5-30+20";
shrink = "yes";
transparency = 0;
idle_threshold = 10;
monitor = 0;
follow = "mouse";
sticky_history = "yes";
history_length = 20;
show_indicators = "yes";
line_height = 0;
separator_height = 2;
padding = 8;
horizontal_padding = 8;
separator_color = "frame";
startup_notification = false;
dmenu = "${pkgs.rofi}/bin/rofi -dmenu -p dunst:";
browser = "${pkgs.firefox}/bin/firefox";
icon_position = "left";
frame_width = 0;
frame_color = colors.inactive;
};
shortcuts = {
close = "ctrl+space";
close_all = "ctrl+shift+space";
context = "ctrl+shift+period";
};
urgency_low = {
background = "${colors.bg}${rofiTransparency}";
foreground = colors.fg;
timeout = 10;
};
urgency_normal = {
background = "${colors.sel}${rofiTransparency}";
foreground = colors.selFg;
timeout = 10;
};
urgency_critical = {
background = "${colors.urgent}${rofiTransparency}";
foreground = colors.selFg;
timeout = 10;
};
};
};
services.stalonetray = {
enable = true;
config = {
icon_size = 20;
background = colors.bg;
sticky = true;
geometry = "3x1-350+0";
icon_gravity = "E";
grow_gravity = "E";
};
};
xresources.properties = {
"Sxiv.foreground" = colors.fg;
"Sxiv.background" = colors.bg;
"Sxiv.font" = "${monoFont.name}:size=${monoFont.size}";
};
programs.zathura = {
enable = true;
options = {
font = "${monoFont.name} ${monoFont.size}";
default-bg = colors.bg;
default-fg = gruvbox-dark.bg1;
statusbar-fg = gruvbox-dark.fg3;
statusbar-bg = gruvbox-dark.bg2;
inputbar-bg = colors.bg;
inputbar-fg = colors.sel;
notification-bg = colors.bg;
notification-fg = colors.sel;
notification-error-bg = colors.bg;
notification-error-fg = gruvbox-dark.red-light;
notification-warning-bg = colors.bg;
notification-warning-fg = gruvbox-dark.red-light;
highlight-color = gruvbox-dark.yellow-light;
highlight-active-color = gruvbox-dark.blue-light;
completion-bg = gruvbox-dark.bg1;
completion-fg = gruvbox-dark.blue-light;
completion-highlight-fg = colors.selFg;
completion-highlight-bg = gruvbox-dark.blue-light;
recolor-lightcolor = colors.bg;
recolor-darkcolor = colors.fg;
recolor = false;
recolor-keephue = false;
};
};
programs.zsh.loginExtra = ''
[[ -z "''${DISPLAY}" ]] && [[ "$(tty)" = "/dev/tty1" ]] && \
exec "${pkgs.xorg.xinit}/bin/startx" 1> "${config.home.homeDirectory}/.xsession-errors" 2>&1
'';
}