more modularize home

This commit is contained in:
alisceon 2026-03-10 21:05:35 +01:00
parent 9434b24685
commit a52cd4d35c
18 changed files with 181 additions and 249 deletions

6
home/alisceon/base.nix Normal file
View file

@ -0,0 +1,6 @@
{ ... }:
{
imports = [
./default.nix
];
} # end file

View file

@ -1,5 +1,11 @@
{ pkgs, config, hostName, lib, ... }:
{
imports = [
./modules/programs/direnv.nix
./modules/programs/git.nix
./modules/programs/ssh.nix
];
home.username = "alisceon";
home.homeDirectory = "/home/alisceon";
home.stateVersion = "24.05";

View file

@ -0,0 +1,28 @@
{ pkgs, config, hostName, lib, ... }:
{
imports = [
../modules/services/swayidle.nix
];
wayland.windowManager.sway.config = {
output = {
eDP-1 = {
mode = "1920x1200@59.950Hz";
position = "0 0";
};
DP-2 = {
mode = "1280x720@60.000Hz";
position = "0 1200";
};
};
workspaceOutputAssign = [];
input."*" = {
xkb_layout = "se,us";
xkb_options = "grp:win_space_toggle";
};
};
services.espanso.configs.default.keyboard_layout.layout = "se";
} # end file

View file

@ -0,0 +1,39 @@
{ pkgs, config, hostName, lib, ... }:
{
wayland.windowManager.sway.config = {
output = {
DP-1 = {
mode = "1920x1080@143.981Hz";
transform = "90";
position = "0 0";
};
DP-2 = {
mode = "3440x1440@99.982Hz";
position = "1080 250";
};
DP-3 = {
mode = "1920x1080@143.981Hz";
position = "4520 250";
};
};
workspaceOutputAssign = [
{ output = "DP-2"; workspace = "1"; }
{ output = "DP-2"; workspace = "2"; }
{ output = "DP-2"; workspace = "3"; }
{ output = "DP-3"; workspace = "4"; }
{ output = "DP-3"; workspace = "5"; }
{ output = "DP-3"; workspace = "6"; }
{ output = "DP-1"; workspace = "7"; }
{ output = "DP-1"; workspace = "8"; }
{ output = "DP-1"; workspace = "9"; }
];
input."*" = {
xkb_layout = "us,se";
xkb_options = "grp:win_space_toggle";
};
};
services.espanso.configs.default.keyboard_layout.layout = "us";
} # end file

View file

@ -0,0 +1,17 @@
{ pkgs }:
let
swaymsg = "${pkgs.sway}/bin/swaymsg";
in
{
uwsm = "${pkgs.uwsm}/bin/uwsm-app --";
inherit swaymsg;
lock = "${pkgs.swaylock}/bin/swaylock --daemonize";
term = "${pkgs.foot}/bin/footclient";
notify = "${pkgs.libnotify}/bin/notify-send";
nag = "${pkgs.sway}/bin/swaynag --edge bottom";
dmenu = "${pkgs.rofi-unwrapped}/bin/rofi";
espanso = "${pkgs.espanso-wayland}/bin/espanso cmd";
display = status: "${swaymsg} 'output * power ${status}'";
} # end file

View file

@ -1,4 +1,8 @@
{ pkgs, config, hostName, lib, ... }:
let
commands = import ../../lib/commands.nix { inherit pkgs; };
inherit (commands) term;
in
{
programs.rofi = {
enable = true;

View file

@ -1,4 +1,8 @@
{ pkgs, config, hostName, lib, ... }:
let
commands = import ../../lib/commands.nix { inherit pkgs; };
inherit (commands) uwsm term;
in
{
programs.waybar = {
enable = true;

View file

@ -8,7 +8,7 @@
toggle_key = "OFF";
preserve_clipboard = true;
show_notifications = true;
keyboard_layout = { layout="${hostnameInput1}"; };
keyboard_layout = { layout = "se"; };
};
};
matches = {

View file

@ -1,13 +1,11 @@
{ pkgs, config, hostName, lib, ... }:
{
services = {
gnome-keyring = {
enable = true;
components = [
"ssh"
"pkcs11"
"secrets"
];
};
} // hostnameServices; # end services
services.gnome-keyring = {
enable = true;
components = [
"ssh"
"pkcs11"
"secrets"
];
};
} # end file

View file

@ -1,4 +1,8 @@
{ pkgs, config, hostName, lib, ... }:
let
commands = import ../../lib/commands.nix { inherit pkgs; };
inherit (commands) notify lock display;
in
{
services.swayidle = {
enable = true;

View file

@ -1,2 +1,5 @@
{ pkgs, config, hostName, lib, ... }: {
imports = [
"./dconf.nix"
]
} # end file

View file

@ -1,14 +1,8 @@
{ pkgs, config, hostName, lib, ... }:
let
# execs
uwsm = "${pkgs.uwsm}/bin/uwsm-app --";
swaymsg = "${pkgs.sway}/bin/swaymsg";
lock = "${pkgs.swaylock}/bin/swaylock --daemonize";
term = "${pkgs.foot}/bin/footclient";
notify = "${pkgs.libnotify}/bin/notify-send";
nag = "${pkgs.sway}/bin/swaynag --edge bottom";
dmenu = "${pkgs.rofi-unwrapped}/bin/rofi";
espanso = "${pkgs.espanso-wayland}/bin/espanso cmd";
# shared command aliases
commands = import ../../../lib/commands.nix { inherit pkgs; };
inherit (commands) uwsm lock term notify nag dmenu espanso;
# keybinds
key_mod = "Mod4";
@ -18,106 +12,20 @@
key_up = "Up";
key_down = "Down";
# other
display = status: "${swaymsg} 'output * power ${status}'";
hostnameOutput =
if hostName == "tower" then {
# Left monitor
DP-1 = {
mode = "1920x1080@143.981Hz";
transform = "90";
position = "0 0";
};
# Main monitor
DP-2 = {
mode = "3440x1440@99.982Hz";
position = "1080 250";
};
# Right monitor
DP-3 = {
mode = "1920x1080@143.981Hz";
position = "4520 250";
};
}
else if hostName == "electra" then {
eDP-1 = {
mode = "1920x1200@59.950Hz";
position = "0 0";
};
DP-2 = {
mode = "1280x720@60.000Hz";
position = "0 1200";
};
}
else {};
hostnameWorkspaceAssign =
if hostName == "tower" then [
{ output = "DP-2"; workspace = "1"; }
{ output = "DP-2"; workspace = "2"; }
{ output = "DP-2"; workspace = "3"; }
{ output = "DP-3"; workspace = "4"; }
{ output = "DP-3"; workspace = "5"; }
{ output = "DP-3"; workspace = "6"; }
{ output = "DP-1"; workspace = "7"; }
{ output = "DP-1"; workspace = "8"; }
{ output = "DP-1"; workspace = "9"; }
]
else if hostName == "electra" then []
else [];
hostnameServices =
if hostName == "tower" then {}
else if hostName == "electra" then {
swayidle = {
enable = true;
timeouts = [
{
timeout = 120;
command = "${notify} 'Locking in 5 seconds' -t 5000";
}
{
timeout = 125;
command = lock;
}
{
timeout = 125;
command = display "off";
resumeCommand = display "on";
}
{
timeout = 600;
command = "${pkgs.systemd}/bin/systemctl suspend";
}
]; # end timeouts
events = [
{
event = "before-sleep";
command = "display off; systemctl --user stop libinput-gestures; ${lock}";
}
{
event = "after-resume";
command = "display on; systemctl --user start libinput-gestures";
}
{
event = "lock";
command = (display "off") + "; " + lock;
}
{
event = "unlock";
command = display "on";
}
]; # end events
}; # end swayidle
}
else {};
hostnameInput1 =
if hostName == "tower" then "us"
else "se";
hostnameInput2 =
if hostName == "tower" then "se"
else "us";
in
{
imports = [
"./gtk.nix"
"./xdg.nix"
"../../modules/programs/foot.nix"
"../../modules/programs/rofi.nix"
"../../modules/programs/swaylock.nix"
"../../modules/programs/waybar.nix"
"../../modules/services/espanso.nix"
"../../modules/services/gnome-keyring.nix"
"../../modules/services/mako.nix"
"../../modules/services/swayidle.nix"
];
wayland.windowManager.sway = {
enable = true;
wrapperFeatures.gtk = true;
@ -147,7 +55,7 @@
pointer_accel = "0.5";
};
"*" = {
xkb_layout = "${hostnameInput1},${hostnameInput2}";
xkb_layout = "se,us";
xkb_options = "grp:win_space_toggle";
};
}; # end input
@ -269,8 +177,6 @@
"8" = [{app_id = "discord";}];
"9" = [{app_id = "signal";}];
};
output = {} // hostnameOutput;
workspaceOutputAssign = hostnameWorkspaceAssign;
}; # end config
}; # end wayland.windowManager.sway
} # end file

View file

@ -1,122 +1,8 @@
{ pkgs, config, hostName, lib, ... }:
let
# execs
uwsm = "${pkgs.uwsm}/bin/uwsm-app --";
swaymsg = "${pkgs.sway}/bin/swaymsg";
lock = "${pkgs.swaylock}/bin/swaylock --daemonize";
term = "${pkgs.foot}/bin/footclient";
notify = "${pkgs.libnotify}/bin/notify-send";
nag = "${pkgs.sway}/bin/swaynag --edge bottom";
dmenu = "${pkgs.rofi-unwrapped}/bin/rofi";
espanso = "${pkgs.espanso-wayland}/bin/espanso cmd";
# keybinds
key_mod = "Mod4";
key_mod_misc = "Alt";
key_left = "Left";
key_right = "Right";
key_up = "Up";
key_down = "Down";
# other
display = status: "${swaymsg} 'output * power ${status}'";
hostnameOutput =
if hostName == "tower" then {
# Left monitor
DP-1 = {
mode = "1920x1080@143.981Hz";
transform = "90";
position = "0 0";
};
# Main monitor
DP-2 = {
mode = "3440x1440@99.982Hz";
position = "1080 250";
};
# Right monitor
DP-3 = {
mode = "1920x1080@143.981Hz";
position = "4520 250";
};
}
else if hostName == "electra" then {
eDP-1 = {
mode = "1920x1200@59.950Hz";
position = "0 0";
};
DP-2 = {
mode = "1280x720@60.000Hz";
position = "0 1200";
};
}
else {};
hostnameWorkspaceAssign =
if hostName == "tower" then [
{ output = "DP-2"; workspace = "1"; }
{ output = "DP-2"; workspace = "2"; }
{ output = "DP-2"; workspace = "3"; }
{ output = "DP-3"; workspace = "4"; }
{ output = "DP-3"; workspace = "5"; }
{ output = "DP-3"; workspace = "6"; }
{ output = "DP-1"; workspace = "7"; }
{ output = "DP-1"; workspace = "8"; }
{ output = "DP-1"; workspace = "9"; }
]
else if hostName == "electra" then []
else [];
hostnameServices =
if hostName == "tower" then {}
else if hostName == "electra" then {
swayidle = {
enable = true;
timeouts = [
{
timeout = 120;
command = "${notify} 'Locking in 5 seconds' -t 5000";
}
{
timeout = 125;
command = lock;
}
{
timeout = 125;
command = display "off";
resumeCommand = display "on";
}
{
timeout = 600;
command = "${pkgs.systemd}/bin/systemctl suspend";
}
]; # end timeouts
events = [
{
event = "before-sleep";
command = "display off; systemctl --user stop libinput-gestures; ${lock}";
}
{
event = "after-resume";
command = "display on; systemctl --user start libinput-gestures";
}
{
event = "lock";
command = (display "off") + "; " + lock;
}
{
event = "unlock";
command = display "on";
}
]; # end events
}; # end swayidle
}
else {};
hostnameInput1 =
if hostName == "tower" then "us"
else "se";
hostnameInput2 =
if hostName == "tower" then "se"
else "us";
in
let
commands = import ../../../lib/commands.nix { inherit pkgs; };
inherit (commands) swaymsg lock;
in
{
xdg = {
configFile."libinput-gestures.conf".text = ''
@ -144,32 +30,27 @@
pkgs.nautilus
pkgs.chromium
];
defaultApplications = { # mostly redundant but the additional granularity is good for reducing friction
# Text
defaultApplications = {
"text/*" = [ "${pkgs.gnome-text-editor}/share/applications/org.gnome.TextEditor.desktop" ];
"application/xml" = [ "${pkgs.gnome-text-editor}/share/applications/org.gnome.TextEditor.desktop" ];
"application/json" = [ "${pkgs.gnome-text-editor}/share/applications/org.gnome.TextEditor.desktop" ];
"application/pdf" = [ "${pkgs.evince}/share/applications/org.gnome.Evince.desktop" ];
# Media
"video/*" = [ "${pkgs.vlc}/share/applications/vlc.desktop" ];
"audio/*" = [ "${pkgs.vlc}/share/applications/vlc.desktop" ];
# Browser
"text/html" = [ "${pkgs.chromium}/share/applications/chromium.desktop" ];
"application/xhtml+xml" = [ "${pkgs.chromium}/share/applications/chromium.desktop" ];
"application/x-web-app-manifest+json" = [ "${pkgs.chromium}/share/applications/chromium.desktop" ];
"application/xml-dtd" = [ "${pkgs.chromium}/share/applications/chromium.desktop" ];
# Images
"image/*" = [ "${pkgs.loupe}/share/applications/org.gnome.Loupe.desktop.desktop" ];
};
};
};
systemd.user.sessionVariables = {
# this right here offends me https://source.chromium.org/chromium/chromium/src/+/main:base/nix/xdg_util.cc;l=179-180
# setting GNOME_DESKTOP_SESSION_ID will fool some legacy systems into thinking we're running gnome
# this is an issue for xdg-open which can be circumvented by adding glib to the system which lets xdg-open fallback to gio-open
GNOME_DESKTOP_SESSION_ID = "999";
SHELL_THICCNESS = "LOW"; # instructs xonsh to default to a slim environment
SHELL_THICCNESS = "LOW";
};
} # end file

3
home/alisceon/server.nix Normal file
View file

@ -0,0 +1,3 @@
{ ... }:
{
} # end file

View file

@ -1,4 +1,11 @@
{ pkgs, config, hostName, lib, ... }: {
imports = [
./modules/programs/chromium.nix
./modules/programs/discord.nix
./modules/programs/vscode.nix
./modules/services/syncthing.nix
];
stylix.enableReleaseChecks = false;
# obsidian special case
# programs.obsidian.enable = true;

6
home/root/base.nix Normal file
View file

@ -0,0 +1,6 @@
{ ... }:
{
imports = [
./default.nix
];
} # end file

18
home/wm/sway.nix Normal file
View file

@ -0,0 +1,18 @@
{ ... }:
{
imports = [
../alisceon/modules/wm/sway/default.nix
../alisceon/modules/wm/sway/gtk.nix
../alisceon/modules/wm/sway/xdg.nix
../alisceon/modules/programs/foot.nix
../alisceon/modules/programs/kitty.nix
../alisceon/modules/programs/rofi.nix
../alisceon/modules/programs/swaylock.nix
../alisceon/modules/programs/waybar.nix
../alisceon/modules/services/espanso.nix
../alisceon/modules/services/gnome-keyring.nix
../alisceon/modules/services/mako.nix
];
} # end file