all/home: separate home-manager config per host

This commit is contained in:
2025-06-08 17:42:54 +02:00
parent 55ab5a06eb
commit 64ba2b7193
12 changed files with 1076 additions and 8 deletions

116
home/common/i3.nix Normal file
View File

@@ -0,0 +1,116 @@
{
lib,
pkgs,
...
}:
let
scratchpad_cmd = "floating enable, resize set 1502 845, move position center, move scratchpad, scratchpad show";
in
{
xsession.windowManager.i3 = {
enable = true;
package = pkgs.i3;
extraConfig = ''
new_window pixel 3
hide_edge_borders smart
'';
config = rec {
modifier = "Mod1";
keybindings = lib.mkOptionDefault {
"${modifier}+Shift+Return" = "exec alacritty";
"${modifier}+m" = "layout toggle splith tabbed";
"${modifier}+t" = "split toggle";
"${modifier}+s" = "layout toggle split";
"${modifier}+1" = "workspace 1";
"${modifier}+2" = "workspace 2";
"${modifier}+3" = "workspace 3";
"${modifier}+4" = "workspace 4";
"${modifier}+5" = "workspace 5";
"${modifier}+6" = "workspace 6";
"${modifier}+7" = "workspace 7";
"${modifier}+8" = "workspace 8";
"${modifier}+9" = "workspace 9";
"${modifier}+0" = "workspace 10";
"${modifier}+Shift+1" = "move container to workspace 1";
"${modifier}+Shift+2" = "move container to workspace 2";
"${modifier}+Shift+3" = "move container to workspace 3";
"${modifier}+Shift+4" = "move container to workspace 4";
"${modifier}+Shift+5" = "move container to workspace 5";
"${modifier}+Shift+6" = "move container to workspace 6";
"${modifier}+Shift+7" = "move container to workspace 7";
"${modifier}+Shift+8" = "move container to workspace 8";
"${modifier}+Shift+9" = "move container to workspace 9";
"${modifier}+Shift+0" = "move container to workspace 10";
"${modifier}+h" = "focus left";
"${modifier}+j" = "focus down";
"${modifier}+k" = "focus up";
"${modifier}+l" = "focus right";
"${modifier}+slash" = "exec ${pkgs.rofi}/bin/rofi -show window";
"${modifier}+Escape" = "workspace back_and_forth";
"${modifier}+p" = "exec ${pkgs.dmenu}/bin/dmenu_run";
"Mod4+l" =
"exec i3-msg [instance=\"python3_scr\"] scratchpad show || exec alacritty --class python3_scr -e python3";
"Mod4+j" = "exec i3-msg [class=\"ViberPC\"] scratchpad show || exec viber";
"Mod4+m" = "exec i3-msg [class=\"Thunderbird\"] scratchpad show || exec thunderbird";
"Mod4+y" =
"exec i3-msg [instance=\"pulsemixer_scr\"] scratchpad show || exec alacritty --class pulsemixer_scr -e pulsemixer";
};
window = {
# border = 4;
commands = [
{
command = scratchpad_cmd;
criteria = {
instance = "pulsemixer_scr|python3_scr";
};
}
{
command = scratchpad_cmd;
criteria = {
class = "Thunderbird";
};
}
{
command = scratchpad_cmd;
criteria = {
class = "ViberPC";
title = "Viber";
};
}
{
command = "focus child, layout tabbed, focus";
criteria = {
class = "qutebrowser";
};
}
];
};
bars = [
{
position = "top";
fonts = {
names = [
"DejaVu Sans Mono"
"FontAwesome5Free"
];
style = "Fixed Bold SemiCondensed";
size = 7.0;
};
statusCommand = "i3status-rs /home/akill/.config/i3status-rust/config-top.toml";
extraConfig = ''
workspace_min_width 30
'';
}
];
};
};
}

View File

@@ -0,0 +1,108 @@
{ pkgs, ... }:
let
kbd_switch = pkgs.writeShellScriptBin "kbd_switch" ''
declare -A -r KBD_CYCLE_MAP=(
["English (US)"]="de"
["German"]="ba"
)
LAYOUT="$(${pkgs.sway}/bin/swaymsg -t get_inputs -r | ${pkgs.jq}/bin/jq -r 'map(select(.type == "keyboard")).[0].xkb_layout_names.[]')"
swaymsg input "*" xkb_layout ''${KBD_CYCLE_MAP["$LAYOUT"]:-"us"}
'';
in
{
programs.i3status-rust = {
bars.top = {
icons = "awesome5";
theme = "gruvbox-dark";
settings.theme = {
theme = "plain";
overrides = {
separator_fg = "#3287a8";
};
};
blocks = [
{
block = "keyboard_layout";
driver = "sway";
click = [
{
cmd = "${kbd_switch}/bin/kbd_switch";
button = "left";
}
];
}
{
block = "battery";
interval = 10;
format = "$icon $percentage $time";
}
{
block = "disk_space";
path = "/nix";
info_type = "available";
interval = 20;
warning = 20.0;
alert = 10.0;
}
{
block = "disk_space";
path = "/home";
info_type = "available";
interval = 20;
warning = 20.0;
alert = 10.0;
}
{
block = "net";
device = "wlan0";
if_command = "ip link show wlan0";
interval = 2;
}
{
block = "net";
device = "enp5s0";
if_command = "ip link show enp5s0";
interval = 2;
}
{
block = "net";
device = "enp7s0f3u1u1";
if_command = "ip link show enp7s0f3u1u1";
interval = 2;
}
{
block = "net";
device = "enp7s0f4u1u1";
if_command = "ip link show enp7s0f4u1u1";
interval = 2;
}
{
block = "net";
if_command = "ip link show eno1";
device = "eno1";
interval = 2;
}
{
block = "memory";
}
{
block = "cpu";
interval = 1;
format = "$utilization $barchart $frequency";
}
{
block = "temperature";
interval = 3;
}
{
block = "sound";
}
{
block = "time";
interval = 60;
}
];
};
};
}

155
home/common/sway.nix Normal file
View File

@@ -0,0 +1,155 @@
{
pkgs,
inputs,
system,
lib,
...
}:
let
cliphist_sway = pkgs.writeShellScriptBin "cliphist_sway" ''
${lib.getExe pkgs.cliphist} list | \
${lib.getExe pkgs.wofi} --dmenu --insensitive | \
${lib.getExe pkgs.cliphist} decode | \
${pkgs.wl-clipboard}/bin/wl-copy
'';
screenshot_clip = pkgs.writeShellScriptBin "screenshot_clip" ''
GEOM="$(${lib.getExe pkgs.slurp} -d)"
${lib.getExe pkgs.grim} -g "$GEOM" - | ${pkgs.wl-clipboard}/bin/wl-copy
'';
swaysw = inputs.swaysw.packages.${system}.swaysw;
term = "${pkgs.foot}/bin/footclient";
in
{
wayland.windowManager.sway = {
enable = true;
extraSessionCommands = "";
extraConfigEarly = '''';
config = {
fonts = {
names = [ "JetBrainsMono" ];
style = "Bold Semi-Condensed";
size = 11.0;
};
window.commands = [
{
command = "move scratchpad, resize set 1152 648";
criteria = {
app_id = "pulsemixer|python3|com.rtosta.zapzap|whatsapp-for-linux|com.viber";
};
}
{
command = "move scratchpad, resize set 1502 845";
criteria = {
app_id = "com.viber";
};
}
{
command = "floating enable";
criteria = {
app_id = "sws_cli";
};
}
];
modifier = "Mod4";
output = {
eDP-1 = {
/*
bg = "~/pic/wallpaper stretch";
scale = "1.4";
*/
};
HDMI-A-4 = {
res = "1920x1080";
};
};
input = {
"type:keyboard" = {
repeat_delay = "150";
};
"type:keyboard" = {
repeat_rate = "70";
};
"type:touchpad" = {
tap = "enabled";
};
};
bars = [
{
position = "top";
fonts = {
names = [
"Iosevka"
"FontAwesome"
];
style = "Bold Semi-Condensed";
size = 12.0;
};
statusCommand = "${lib.getExe pkgs.i3status-rust} ~/.config/i3status-rust/config-top.toml";
}
];
keybindings = {
"Alt+Shift+q" = "kill";
"Alt+Shift+Return" = "exec ${term}";
"Alt+p" = "exec ${pkgs.bemenu}/bin/bemenu-run";
"Alt+c" = "exec ${pkgs.moreutils}/bin/lckdo cliphist_sway ${cliphist_sway}/bin/cliphist_sway";
"Print" = "exec ${pkgs.moreutils}/bin/lckdo screenshot_clip ${screenshot_clip}/bin/screenshot_clip";
"Alt+Shift+space" = "floating toggle";
"Alt+space" = "focus mode_toggle";
"Alt+m" = "layout toggle splith tabbed";
"Alt+t" = "split toggle";
"Alt+s" = "layout toggle split";
"Alt+1" = "workspace 1";
"Alt+2" = "workspace 2";
"Alt+3" = "workspace 3";
"Alt+4" = "workspace 4";
"Alt+5" = "workspace 5";
"Alt+6" = "workspace 6";
"Alt+7" = "workspace 7";
"Alt+8" = "workspace 8";
"Alt+9" = "workspace 9";
"Alt+0" = "workspace 10";
"Alt+Shift+1" = "move container to workspace 1";
"Alt+Shift+2" = "move container to workspace 2";
"Alt+Shift+3" = "move container to workspace 3";
"Alt+Shift+4" = "move container to workspace 4";
"Alt+Shift+5" = "move container to workspace 5";
"Alt+Shift+6" = "move container to workspace 6";
"Alt+Shift+7" = "move container to workspace 7";
"Alt+Shift+8" = "move container to workspace 8";
"Alt+Shift+9" = "move container to workspace 9";
"Alt+Shift+0" = "move container to workspace 10";
"Alt+h" = "focus left";
"Alt+j" = "focus down";
"Alt+k" = "focus up";
"Alt+l" = "focus right";
"Alt+slash" = "exec ${pkgs.moreutils}/bin/lckdo swaysw ${swaysw}/bin/swaysw";
"Alt+Escape" = "workspace back_and_forth";
"Alt+f" = "fullscreen enable";
"Alt+bracketright" = "focus output right";
"Alt+bracketleft" = "focus output left";
"Mod4+l" =
''exec ${pkgs.sway}/bin/swaymsg [app_id="python3"] scratchpad show || exec ${term} -a python3 ${lib.getExe pkgs.python3}'';
"Mod4+j" =
"exec ${pkgs.sway}/bin/swaymsg [app_id=com.rtosta.zapzap] scratchpad show || exec ${lib.getExe pkgs.zapzap}";
"Mod4+h" =
"exec ${pkgs.sway}/bin/swaymsg [app_id=com.viber] scratchpad show || exec ${pkgs.viber}/bin/viber";
"Mod4+y" =
''exec ${pkgs.sway}/bin/swaymsg [app_id="pulsemixer"] scratchpad show || exec ${term} -a pulsemixer ${lib.getExe pkgs.pulsemixer}'';
"Mod4+p" = "exec ${lib.getExe pkgs.tessen} -a copy";
};
};
};
}

View File

@@ -0,0 +1,31 @@
{ lib, ... }:
with lib;
{
xdg.configFile."whatsapp-for-linux/settings.conf".source = builtins.toFile "settings.conf" (
generators.toINI { } {
General = {
zoom_level = 1;
close_to_tray = false;
};
Network = {
allow_permissions = true;
};
web = {
allow-permissions = true;
hw-accel = 1;
};
general = {
notification-sounds = true;
close-to-tray = true;
start-in-tray = false;
};
appearance = {
prefer-dark-theme = true;
};
}
);
}

120
home/common/zsh.nix Normal file
View File

@@ -0,0 +1,120 @@
{ pkgs, lib, ... }:
{
programs.z-lua = {
enableAliases = true;
enableZshIntegration = true;
};
programs.zsh = {
autocd = true;
enableCompletion = false;
defaultKeymap = "viins";
shellAliases = {
cfind = "${pkgs.cscope}/bin/cscope -C -R -L1";
chmod = "chmod -v";
chown = "chown -v";
cp = "cp -v";
rm = "rm -v";
ip = "ip --color=auto";
f = "''$(${lib.getExe pkgs.pay-respects} zsh)";
};
history = {
expireDuplicatesFirst = true;
extended = true;
save = 100000;
size = 100000;
};
plugins = [
{
name = "nix_shell";
src = pkgs.zsh-nix-shell;
file = "share/zsh-nix-shell/nix-shell.plugin.zsh";
}
{
name = "nix_completion";
src = pkgs.nix-zsh-completions;
file = "share/zsh/plugins/nix/nix-zsh-completions.plugin.zsh";
}
{
name = "pure_prompt";
src = pkgs.fetchFromGitHub {
owner = "sindresorhus";
repo = "pure";
rev = "92b8e9057988566b37ff695e70e2e9bbeb7196c8";
hash = "sha256-TbOrnhLHgOvcfsgmL0l3bWY33yLIhG1KSi4ITIPq1+A=";
};
file = "pure.plugin.zsh";
}
{
name = "fzf";
src = pkgs.fzf-zsh;
file = "share/zsh/plugins/fzf-zsh/fzf-zsh.plugin.zsh";
}
{
name = "zsh-sudo";
src = pkgs.fetchFromGitHub {
owner = "hcgraf";
repo = "zsh-sudo";
rev = "d8084def6bb1bde2482e7aa636743f40c69d9b32";
sha256 = "1dpm51w3wjxil8sxqw4qxim5kmf6afmkwz1yfhldpdlqm7rfwpi3";
};
file = "sudo.plugin.zsh";
}
{
name = "zsh-fast-syntax-highlighting";
src = pkgs.zsh-fast-syntax-highlighting;
file = "share/zsh/site-functions/fast-syntax-highlighting.plugin.zsh";
}
];
envExtra = '''';
initContent = ''
# binds
bindkey '^K' fzf-file-widget
# options
setopt nobeep
setopt nopromptcr
setopt c_bases
setopt completeinword
setopt completealiases
setopt notify
#
RPS1=""
#
function chpwd() {
ls;
}
function osc7-pwd() {
emulate -L zsh # also sets localoptions for us
setopt extendedglob
local LC_ALL=C
printf '\e]7;file://%s%s\e\' $HOST ''${PWD//(#m)([^@-Za-z&-;_~])/%''${(l:2::0:)''$(([##16]#MATCH))}}
}
function chpwd-osc7-pwd() {
(( ZSH_SUBSHELL )) || osc7-pwd
}
add-zsh-hook -Uz chpwd chpwd-osc7-pwd
eval "$(direnv hook zsh)"
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'
if [[ -n "$PS1" ]] && [[ -z "$TMUX" ]] && [[ -n "$SSH_CONNECTION" ]]; then
TMUX_EXE="${lib.getExe pkgs.tmux}"
systemd-run --scope --user $TMUX_EXE attach-session -t $USER || systemd-run --scope --user $TMUX_EXE new-session -s $USER
fi
if [[ -n "$BUBBLEWRAP_DIR" ]]; then
RPS1="{{$BUBBLEWRAP_DIR}}"
fi
'';
};
}