reorganization

This commit is contained in:
Reid 2026-04-22 23:21:23 -07:00
parent 2ad77494b2
commit b6afba390b
Signed by: reidlab
GPG key ID: DAF5EAF6665839FD
24 changed files with 144 additions and 128 deletions

View file

@ -19,34 +19,18 @@ in {
inputs.vicinae.homeManagerModules.default inputs.vicinae.homeManagerModules.default
]; ];
system.stateVersion = "23.11"; # i mostly disagree with state versions, just use the oldest one i have set up
# they seem reasonable at first but are so messy across multiple hosts
# a lot of the time they're used for stuff that isn't even state (looking at you, home-manager)
system.stateVersion = mkDefault "23.11";
system.configurationRevision = with inputs; mkIf (self ? rev) self.rev; system.configurationRevision = with inputs; mkIf (self ? rev) self.rev;
hm.home.stateVersion = config.system.stateVersion; hm.home.stateVersion = config.system.stateVersion;
boot = { boot.kernelPackages = mkDefault pkgs.linuxPackages_latest;
kernelPackages = mkDefault pkgs.linuxPackages_latest;
kernelParams = [ "pcie_aspm.policy=performance" ];
};
# configure keymap in x11
services.xserver.xkb = {
layout = "us";
variant = "qwerty";
};
console = {
useXkbConfig = mkDefault true;
};
services.earlyoom.enable = true;
# TODO: drop geoclue entirely. too lazy 2 to that now
services.automatic-timezoned.enable = mkDefault true; services.automatic-timezoned.enable = mkDefault true;
time.timeZone = mkDefault null; # handled by automatic-timezoned time.timeZone = mkDefault null; # handled by automatic-timezoned
i18n = mkDefault {
defaultLocale = "en_US.UTF-8";
supportedLocales = [ "en_US.UTF-8/UTF-8" ];
};
location.provider = mkDefault "geoclue2"; location.provider = mkDefault "geoclue2";
services.geoclue2 = { services.geoclue2 = {
enable = mkDefault true; enable = mkDefault true;
@ -57,10 +41,6 @@ in {
submissionNick = "geoclue"; submissionNick = "geoclue";
}; };
hardware.enableRedistributableFirmware = true; # git is needed for flakes, yet, isn't in `environment.corePackages`
environment.systemPackages = with pkgs; [ git ];
environment.systemPackages = with pkgs; [
openssh mosh
git
];
} }

View file

@ -33,20 +33,22 @@
boot.kernelPackages = pkgs.cachyosKernels.linuxPackages-cachyos-latest-lto-x86_64-v3; boot.kernelPackages = pkgs.cachyosKernels.linuxPackages-cachyos-latest-lto-x86_64-v3;
modules = { modules = {
security.useDoas = true; core = {
# kernel
kernel.v4l2 = true;
kernel.zswap = true;
# security
security.useDoas = true;
};
hardware = { hardware = {
audio.enable = true;
bluetooth.enable = true; bluetooth.enable = true;
pipewire.enable = true;
print.enable = true; print.enable = true;
pointer.enable = true; pointer.enable = true;
tablet.enable = true; tablet.enable = true;
networking.enable = true; networking.enable = true;
rgb.enable = true; rgb.enable = true;
}; };
dev = {
enable = true;
};
desktop = { desktop = {
# set to `x11` or `wayland`, improves compat # set to `x11` or `wayland`, improves compat
envProto = "wayland"; envProto = "wayland";
@ -57,7 +59,6 @@
# accessories # accessories
hyprlock.enable = true; hyprlock.enable = true;
hypridle.enable = true; hypridle.enable = true;
hypridle.desktop = true;
awww.enable = true; awww.enable = true;
gnome-keyring.enable = true; gnome-keyring.enable = true;
mate-polkit.enable = true; mate-polkit.enable = true;
@ -92,22 +93,20 @@
system.flatpak.enable = true; system.flatpak.enable = true;
system.mpv.enable = true; system.mpv.enable = true;
system.ananicy.enable = true; system.ananicy.enable = true;
system.zswap.enable = true;
system.kdeconnect.enable = true; system.kdeconnect.enable = true;
system.virt-manager.enable = true; system.virt-manager.enable = true;
# editors # editors
editors.micro.enable = true; editors.micro.enable = true;
editors.vscode.enable = true; editors.vscode.enable = true;
# dev
dev.git.enable = true;
# distractions # distractions
distractions.discord.enable = true; distractions.discord.enable = true;
distractions.discord.vesktop = true; distractions.discord.vesktop = true;
distractions.steam.enable = true; distractions.steam.enable = true;
# tools # tools
tools.direnv.enable = true;
tools.git.enable = true;
tools.gpg.enable = true; tools.gpg.enable = true;
tools.rbw.enable = true; tools.rbw.enable = true;
tools.noisetorch.enable = true;
}; };
}; };
} }

View file

@ -31,18 +31,19 @@
]); ]);
modules = { modules = {
security.useDoas = true; core = {
laptop = true;
# kernel
kernel.zswap = true;
# security
security.useDoas = true;
};
hardware = { hardware = {
audio.enable = true;
bluetooth.enable = true; bluetooth.enable = true;
pipewire.enable = true;
print.enable = true; print.enable = true;
pointer.enable = true; pointer.enable = true;
networking.enable = true; networking.enable = true;
networking.powersave = true;
};
dev = {
enable = true;
}; };
desktop = { desktop = {
# set to `x11` or `wayland`, improves compat # set to `x11` or `wayland`, improves compat
@ -92,16 +93,15 @@
# editors # editors
editors.micro.enable = true; editors.micro.enable = true;
editors.vscode.enable = true; editors.vscode.enable = true;
# dev
dev.git.enable = true;
# distractions # distractions
distractions.discord.enable = true; distractions.discord.enable = true;
distractions.discord.vesktop = true; distractions.discord.vesktop = true;
distractions.steam.enable = true; distractions.steam.enable = true;
# tools # tools
tools.direnv.enable = true;
tools.git.enable = true;
tools.gpg.enable = true; tools.gpg.enable = true;
tools.rbw.enable = true; tools.rbw.enable = true;
tools.noisetorch.enable = true;
}; };
}; };
} }

14
modules/core/default.nix Normal file
View file

@ -0,0 +1,14 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.modules.core;
in {
options.modules.core = {
laptop = mkEnableOption "Enable laptop specific tweaks";
};
config = {
# TODO: add something here loooool
};
}

27
modules/core/kernel.nix Normal file
View file

@ -0,0 +1,27 @@
{ lib, config, pkgs, ... }:
with lib;
let
cfg = config.modules.core.kernel;
in {
options.modules.core.kernel = {
zswap = mkEnableOption "Enable zswap, a compressed RAM cache for swap pages";
v4l2 = mkEnableOption "Enable support for v4l2 loopback devices";
};
config = mkMerge [
(mkIf cfg.zswap {
boot.kernelParams = [
"zswap.enabled=1"
"zswap.shrinker_enabled=1"
"zswap.max_pool_percent=20"
"zswap.compressor=zstd"
"zswap.zpool=zsmalloc"
];
})
(mkIf cfg.v4l2 {
boot.kernelModules = ["v4l2loopback"];
boot.extraModulePackages = with config.boot.kernelPackages; [ v4l2loopback ];
})
];
}

13
modules/core/locale.nix Normal file
View file

@ -0,0 +1,13 @@
{ lib, pkgs, inputs, config, ... }:
with lib;
{
i18n.defaultLocale = mkDefault "en_US.UTF-8";
services.xserver.xkb = {
layout = "us";
variant = "qwerty";
};
console = {
useXkbConfig = mkDefault true;
};
}

View file

@ -2,9 +2,9 @@
with lib; with lib;
let let
cfg = config.modules.security; cfg = config.modules.core.security;
in { in {
options.modules.security = { options.modules.core.security = {
useDoas = mkEnableOption "use opendoas instead of sudo"; useDoas = mkEnableOption "use opendoas instead of sudo";
}; };
@ -64,28 +64,13 @@ in {
# personal computer? no firewall ty :3 # personal computer? no firewall ty :3
networking.firewall.enable = false; networking.firewall.enable = false;
services.usbguard = { # stay up to date on firmware
IPCAllowedUsers = [ "root" "${env.mainUser}" ];
presentDevicePolicy = "allow";
rules = ''
allow with-interface equals { 08:*:* }
# reject devices with suspicious combination of interfaces (ex. mass storage + keyboard)
reject with-interface all-of { 08:*:* 03:00:* }
reject with-interface all-of { 08:*:* 03:01:* }
reject with-interface all-of { 08:*:* e0:*:* }
reject with-interface all-of { 08:*:* 02:*:* }
'';
};
services.fwupd.enable = true; services.fwupd.enable = true;
} }
(mkIf cfg.useDoas { (mkIf cfg.useDoas {
security.sudo.enable = false; security.sudo.enable = false;
security.doas.enable = true; security.doas.enable = true;
security.doas.extraRules = [ security.doas.extraRules = [ { users = [ config.user.name ]; noPass = true; persist = false; keepEnv = true; } ];
{ users = [ config.user.name ]; noPass = true; persist = false; keepEnv = true; }
];
environment.systemPackages = with pkgs; [ doas-sudo-shim ]; environment.systemPackages = with pkgs; [ doas-sudo-shim ];
}) })
]; ];

View file

@ -11,7 +11,6 @@ in {
default = pkgs.hypridle; default = pkgs.hypridle;
example = "pkgs.hypridle"; example = "pkgs.hypridle";
}; };
desktop = mkEnableOption "Extend screen dimming time and disable sleeping";
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
@ -30,12 +29,12 @@ in {
listener = [ listener = [
{ {
timeout = if !cfg.desktop timeout = if config.modules.core.laptop
then 60 * 2 # 2 min then 60 * 2 # 2 min
else 60 * 35; # 35 min else 60 * 35; # 35 min
on-timeout = "${pkgs.systemd}/bin/loginctl lock-session"; # lock computer on-timeout = "${pkgs.systemd}/bin/loginctl lock-session"; # lock computer
} }
] ++ optionals (!cfg.desktop) [ ] ++ optionals (config.modules.core.laptop) [
{ {
timeout = 60; # 1 min timeout = 60; # 1 min
on-timeout = "${lib.getExe pkgs.brightnessctl} -c backlight -s set 20"; # dim screen, save brightness state on-timeout = "${lib.getExe pkgs.brightnessctl} -c backlight -s set 20"; # dim screen, save brightness state
@ -51,7 +50,7 @@ in {
on-timeout = "${pkgs.systemd}/bin/systemctl suspend"; # sleep/suspend on-timeout = "${pkgs.systemd}/bin/systemctl suspend"; # sleep/suspend
} }
] ++ optional config.modules.desktop.niri.enable { ] ++ optional config.modules.desktop.niri.enable {
timeout = if !cfg.desktop timeout = if config.modules.core.laptop
then 90 # 1.5 min then 90 # 1.5 min
else 30 * 60; # 30 min else 30 * 60; # 30 min
on-timeout = "niri msg action power-off-monitors"; on-timeout = "niri msg action power-off-monitors";

View file

@ -74,6 +74,7 @@ in {
font_family = config.modules.desktop.fonts.fonts.sansSerif.family; font_family = config.modules.desktop.fonts.fonts.sansSerif.family;
halign = "center"; valign = "center"; halign = "center"; valign = "center";
} }
] ++ optionals config.modules.core.laptop [
{ {
position = "-15, -11"; position = "-15, -11";
halign = "right"; valign = "top"; halign = "right"; valign = "top";

View file

@ -222,20 +222,6 @@ in {
power-saver = " save"; power-saver = " save";
}; };
}; };
battery = {
interval = 30;
states = {
warning = 20;
critical = 10;
};
design-capacity = false;
format = "{icon} {capacity}%";
format-icons = ["" "" "" "" ""];
format-critical = " {capacity}%";
format-charging = " {capacity}%";
tooltip = true;
tooltip-format = "{timeTo} ({power}W)";
};
privacy = { privacy = {
icon-spacing = 0; icon-spacing = 0;
icon-size = 12; icon-size = 12;
@ -326,6 +312,22 @@ in {
return-type = "json"; return-type = "json";
}; };
} }
(mkIf config.modules.core.laptop {
battery = {
interval = 30;
states = {
warning = 20;
critical = 10;
};
design-capacity = false;
format = "{icon} {capacity}%";
format-icons = ["" "" "" "" ""];
format-critical = " {capacity}%";
format-charging = " {capacity}%";
tooltip = true;
tooltip-format = "{timeTo} ({power}W)";
};
})
(mkIf config.modules.desktop.awww.enable { (mkIf config.modules.desktop.awww.enable {
"custom/wallpaper" = { "custom/wallpaper" = {
format = ""; format = "";

View file

@ -2,10 +2,10 @@
with lib; with lib;
let let
cfg = config.modules.hardware.pipewire; cfg = config.modules.hardware.audio;
in { in {
options.modules.hardware.pipewire = { options.modules.hardware.audio = {
enable = mkEnableOption "Enable pipewire, a modern audio server"; enable = mkEnableOption "Enable audio through pipewire, a modern audio server";
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {

View file

@ -6,11 +6,15 @@ let
in { in {
options.modules.hardware.bluetooth = { options.modules.hardware.bluetooth = {
enable = mkEnableOption "Enable bluetooth, a short-range communication technology"; enable = mkEnableOption "Enable bluetooth, a short-range communication technology";
powerOnBoot = mkEnableOption {
default = !config.modules.core.laptop;
description = "Power up bluetooth devices on boot";
};
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
hardware.bluetooth.enable = true; hardware.bluetooth.enable = true;
hardware.bluetooth.powerOnBoot = true; hardware.bluetooth.powerOnBoot = cfg.powerOnBoot;
hardware.bluetooth.settings = { hardware.bluetooth.settings = {
General = { General = {
Experimental = true; Experimental = true;

View file

@ -0,0 +1,6 @@
{ pkgs, ... }:
{
config = {
hardware.enableRedistributableFirmware = true;
};
}

View file

@ -6,7 +6,10 @@ let
in { in {
options.modules.hardware.networking = { options.modules.hardware.networking = {
enable = mkEnableOption "Enable NetworkManager, a daemon for configuring network interfaces"; enable = mkEnableOption "Enable NetworkManager, a daemon for configuring network interfaces";
powersave = mkEnableOption "Enable power saving options over Wi-Fi"; powersave = mkEnableOption {
default = config.modules.core.laptop;
description = "Enable power saving options over Wi-Fi";
};
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {

View file

@ -1,21 +0,0 @@
{ lib, config, pkgs, ... }:
with lib;
let
# TODO: move this dawg
cfg = config.modules.software.system.zswap;
in {
options.modules.software.system.zswap = {
enable = mkEnableOption "Enable zswap, a compressed RAM cache for swap pages";
};
config = mkIf cfg.enable {
boot.kernelParams = [
"zswap.enabled=1"
"zswap.shrinker_enabled=1" # high mem: shrink zswap, mv to swap
"zswap.max_pool_percent=20" # TODO: tune this (keep in mind shrinker is enabled)
"zswap.compressor=zstd"
"zswap.zpool=zsmalloc"
];
};
}

View file

@ -0,0 +1,18 @@
{ lib, config, ... }:
with lib;
let
cfg = config.modules.software.tools.direnv;
in {
options.modules.software.tools.direnv = {
enable = mkEnableOption "Enable direnv, a shell extension that manages your environment";
};
config = mkIf cfg.enable {
programs.direnv = {
enable = true;
silent = true;
nix-direnv.enable = true;
};
};
}

View file

@ -2,9 +2,9 @@
with lib; with lib;
let let
cfg = config.modules.software.dev.git; cfg = config.modules.software.tools.git;
in { in {
options.modules.software.dev.git = { options.modules.software.tools.git = {
enable = mkEnableOption "Enable git. You know what git is"; enable = mkEnableOption "Enable git. You know what git is";
package = mkOption { package = mkOption {
type = types.package; type = types.package;

View file

@ -1,14 +0,0 @@
{ config, lib, ... }:
with lib;
let
cfg = config.modules.software.tools.noisetorch;
in {
options.modules.software.tools.noisetorch = {
enable = mkEnableOption "Enable noisetorch, a microphone noise supression tool";
};
config = mkIf cfg.enable {
programs.noisetorch.enable = true;
};
}