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

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;
let
cfg = config.modules.security;
cfg = config.modules.core.security;
in {
options.modules.security = {
options.modules.core.security = {
useDoas = mkEnableOption "use opendoas instead of sudo";
};
@ -64,28 +64,13 @@ in {
# personal computer? no firewall ty :3
networking.firewall.enable = false;
services.usbguard = {
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:*:* }
'';
};
# stay up to date on firmware
services.fwupd.enable = true;
}
(mkIf cfg.useDoas {
security.sudo.enable = false;
security.doas.enable = true;
security.doas.extraRules = [
{ users = [ config.user.name ]; noPass = true; persist = false; keepEnv = true; }
];
security.doas.extraRules = [ { users = [ config.user.name ]; noPass = true; persist = false; keepEnv = true; } ];
environment.systemPackages = with pkgs; [ doas-sudo-shim ];
})
];

View file

@ -11,7 +11,6 @@ in {
default = pkgs.hypridle;
example = "pkgs.hypridle";
};
desktop = mkEnableOption "Extend screen dimming time and disable sleeping";
};
config = mkIf cfg.enable {
@ -30,12 +29,12 @@ in {
listener = [
{
timeout = if !cfg.desktop
timeout = if config.modules.core.laptop
then 60 * 2 # 2 min
else 60 * 35; # 35 min
on-timeout = "${pkgs.systemd}/bin/loginctl lock-session"; # lock computer
}
] ++ optionals (!cfg.desktop) [
] ++ optionals (config.modules.core.laptop) [
{
timeout = 60; # 1 min
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
}
] ++ optional config.modules.desktop.niri.enable {
timeout = if !cfg.desktop
timeout = if config.modules.core.laptop
then 90 # 1.5 min
else 30 * 60; # 30 min
on-timeout = "niri msg action power-off-monitors";

View file

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

View file

@ -222,20 +222,6 @@ in {
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 = {
icon-spacing = 0;
icon-size = 12;
@ -326,6 +312,22 @@ in {
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 {
"custom/wallpaper" = {
format = "";

View file

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

View file

@ -6,11 +6,15 @@ let
in {
options.modules.hardware.bluetooth = {
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 {
hardware.bluetooth.enable = true;
hardware.bluetooth.powerOnBoot = true;
hardware.bluetooth.powerOnBoot = cfg.powerOnBoot;
hardware.bluetooth.settings = {
General = {
Experimental = true;

View file

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

View file

@ -6,7 +6,10 @@ let
in {
options.modules.hardware.networking = {
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 {

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;
let
cfg = config.modules.software.dev.git;
cfg = config.modules.software.tools.git;
in {
options.modules.software.dev.git = {
options.modules.software.tools.git = {
enable = mkEnableOption "Enable git. You know what git is";
package = mkOption {
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;
};
}