From b6afba390bd301034cfb8b2f06a0536e32c399af Mon Sep 17 00:00:00 2001 From: reidlab Date: Wed, 22 Apr 2026 23:21:23 -0700 Subject: [PATCH] reorganization --- default.nix | 36 +++++--------------- hosts/flubber-machine/default.nix | 21 ++++++------ hosts/goopnet-interface/default.nix | 20 +++++------ modules/core/default.nix | 14 ++++++++ modules/{ => core}/fs/fstrim.nix | 0 modules/{ => core}/fs/lvm.nix | 0 modules/{ => core}/fs/scrub.nix | 0 modules/core/kernel.nix | 27 +++++++++++++++ modules/core/locale.nix | 13 +++++++ modules/{ => core}/nix.nix | 0 modules/{ => core}/security.nix | 23 +++---------- modules/{ => core}/user.nix | 0 modules/{ => core}/xdg.nix | 0 modules/desktop/hypridle.nix | 7 ++-- modules/desktop/hyprlock.nix | 1 + modules/desktop/waybar.nix | 30 ++++++++-------- modules/hardware/{pipewire.nix => audio.nix} | 6 ++-- modules/hardware/bluetooth.nix | 6 +++- modules/hardware/default.nix | 6 ++++ modules/hardware/networking.nix | 5 ++- modules/software/system/zswap.nix | 21 ------------ modules/software/tools/direnv.nix | 18 ++++++++++ modules/software/{dev => tools}/git.nix | 4 +-- modules/software/tools/noisetorch.nix | 14 -------- 24 files changed, 144 insertions(+), 128 deletions(-) create mode 100644 modules/core/default.nix rename modules/{ => core}/fs/fstrim.nix (100%) rename modules/{ => core}/fs/lvm.nix (100%) rename modules/{ => core}/fs/scrub.nix (100%) create mode 100644 modules/core/kernel.nix create mode 100644 modules/core/locale.nix rename modules/{ => core}/nix.nix (100%) rename modules/{ => core}/security.nix (77%) rename modules/{ => core}/user.nix (100%) rename modules/{ => core}/xdg.nix (100%) rename modules/hardware/{pipewire.nix => audio.nix} (69%) create mode 100644 modules/hardware/default.nix delete mode 100644 modules/software/system/zswap.nix create mode 100644 modules/software/tools/direnv.nix rename modules/software/{dev => tools}/git.nix (94%) delete mode 100644 modules/software/tools/noisetorch.nix diff --git a/default.nix b/default.nix index 35e6439..c9918bb 100755 --- a/default.nix +++ b/default.nix @@ -19,34 +19,18 @@ in { 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; hm.home.stateVersion = config.system.stateVersion; - boot = { - 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; + boot.kernelPackages = mkDefault pkgs.linuxPackages_latest; + # TODO: drop geoclue entirely. too lazy 2 to that now services.automatic-timezoned.enable = mkDefault true; 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"; services.geoclue2 = { enable = mkDefault true; @@ -57,10 +41,6 @@ in { submissionNick = "geoclue"; }; - hardware.enableRedistributableFirmware = true; - - environment.systemPackages = with pkgs; [ - openssh mosh - git - ]; + # git is needed for flakes, yet, isn't in `environment.corePackages` + environment.systemPackages = with pkgs; [ git ]; } diff --git a/hosts/flubber-machine/default.nix b/hosts/flubber-machine/default.nix index f6aad81..06db379 100755 --- a/hosts/flubber-machine/default.nix +++ b/hosts/flubber-machine/default.nix @@ -33,20 +33,22 @@ boot.kernelPackages = pkgs.cachyosKernels.linuxPackages-cachyos-latest-lto-x86_64-v3; modules = { - security.useDoas = true; - + core = { + # kernel + kernel.v4l2 = true; + kernel.zswap = true; + # security + security.useDoas = true; + }; hardware = { + audio.enable = true; bluetooth.enable = true; - pipewire.enable = true; print.enable = true; pointer.enable = true; tablet.enable = true; networking.enable = true; rgb.enable = true; }; - dev = { - enable = true; - }; desktop = { # set to `x11` or `wayland`, improves compat envProto = "wayland"; @@ -57,7 +59,6 @@ # accessories hyprlock.enable = true; hypridle.enable = true; - hypridle.desktop = true; awww.enable = true; gnome-keyring.enable = true; mate-polkit.enable = true; @@ -92,22 +93,20 @@ system.flatpak.enable = true; system.mpv.enable = true; system.ananicy.enable = true; - system.zswap.enable = true; system.kdeconnect.enable = true; system.virt-manager.enable = true; # editors editors.micro.enable = true; editors.vscode.enable = true; - # dev - dev.git.enable = true; # distractions distractions.discord.enable = true; distractions.discord.vesktop = true; distractions.steam.enable = true; # tools + tools.direnv.enable = true; + tools.git.enable = true; tools.gpg.enable = true; tools.rbw.enable = true; - tools.noisetorch.enable = true; }; }; } diff --git a/hosts/goopnet-interface/default.nix b/hosts/goopnet-interface/default.nix index d09e768..94b493a 100755 --- a/hosts/goopnet-interface/default.nix +++ b/hosts/goopnet-interface/default.nix @@ -31,18 +31,19 @@ ]); modules = { - security.useDoas = true; - + core = { + laptop = true; + # kernel + kernel.zswap = true; + # security + security.useDoas = true; + }; hardware = { + audio.enable = true; bluetooth.enable = true; - pipewire.enable = true; print.enable = true; pointer.enable = true; networking.enable = true; - networking.powersave = true; - }; - dev = { - enable = true; }; desktop = { # set to `x11` or `wayland`, improves compat @@ -92,16 +93,15 @@ # editors editors.micro.enable = true; editors.vscode.enable = true; - # dev - dev.git.enable = true; # distractions distractions.discord.enable = true; distractions.discord.vesktop = true; distractions.steam.enable = true; # tools + tools.direnv.enable = true; + tools.git.enable = true; tools.gpg.enable = true; tools.rbw.enable = true; - tools.noisetorch.enable = true; }; }; } diff --git a/modules/core/default.nix b/modules/core/default.nix new file mode 100644 index 0000000..2110716 --- /dev/null +++ b/modules/core/default.nix @@ -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 + }; +} diff --git a/modules/fs/fstrim.nix b/modules/core/fs/fstrim.nix similarity index 100% rename from modules/fs/fstrim.nix rename to modules/core/fs/fstrim.nix diff --git a/modules/fs/lvm.nix b/modules/core/fs/lvm.nix similarity index 100% rename from modules/fs/lvm.nix rename to modules/core/fs/lvm.nix diff --git a/modules/fs/scrub.nix b/modules/core/fs/scrub.nix similarity index 100% rename from modules/fs/scrub.nix rename to modules/core/fs/scrub.nix diff --git a/modules/core/kernel.nix b/modules/core/kernel.nix new file mode 100644 index 0000000..d9031b1 --- /dev/null +++ b/modules/core/kernel.nix @@ -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 ]; + }) + ]; +} diff --git a/modules/core/locale.nix b/modules/core/locale.nix new file mode 100644 index 0000000..db1ac03 --- /dev/null +++ b/modules/core/locale.nix @@ -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; + }; +} diff --git a/modules/nix.nix b/modules/core/nix.nix similarity index 100% rename from modules/nix.nix rename to modules/core/nix.nix diff --git a/modules/security.nix b/modules/core/security.nix similarity index 77% rename from modules/security.nix rename to modules/core/security.nix index 4bc3f4b..cdec7fa 100755 --- a/modules/security.nix +++ b/modules/core/security.nix @@ -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 ]; }) ]; diff --git a/modules/user.nix b/modules/core/user.nix similarity index 100% rename from modules/user.nix rename to modules/core/user.nix diff --git a/modules/xdg.nix b/modules/core/xdg.nix similarity index 100% rename from modules/xdg.nix rename to modules/core/xdg.nix diff --git a/modules/desktop/hypridle.nix b/modules/desktop/hypridle.nix index abc1143..9a380cc 100644 --- a/modules/desktop/hypridle.nix +++ b/modules/desktop/hypridle.nix @@ -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"; diff --git a/modules/desktop/hyprlock.nix b/modules/desktop/hyprlock.nix index 45da687..cc349ab 100644 --- a/modules/desktop/hyprlock.nix +++ b/modules/desktop/hyprlock.nix @@ -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"; diff --git a/modules/desktop/waybar.nix b/modules/desktop/waybar.nix index 1e71a97..198b9bc 100644 --- a/modules/desktop/waybar.nix +++ b/modules/desktop/waybar.nix @@ -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 = ""; diff --git a/modules/hardware/pipewire.nix b/modules/hardware/audio.nix similarity index 69% rename from modules/hardware/pipewire.nix rename to modules/hardware/audio.nix index ade571f..a9db2d0 100644 --- a/modules/hardware/pipewire.nix +++ b/modules/hardware/audio.nix @@ -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 { diff --git a/modules/hardware/bluetooth.nix b/modules/hardware/bluetooth.nix index f31d1f6..ad80ce4 100644 --- a/modules/hardware/bluetooth.nix +++ b/modules/hardware/bluetooth.nix @@ -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; diff --git a/modules/hardware/default.nix b/modules/hardware/default.nix new file mode 100644 index 0000000..08fb28a --- /dev/null +++ b/modules/hardware/default.nix @@ -0,0 +1,6 @@ +{ pkgs, ... }: +{ + config = { + hardware.enableRedistributableFirmware = true; + }; +} diff --git a/modules/hardware/networking.nix b/modules/hardware/networking.nix index 99069ab..c279b36 100644 --- a/modules/hardware/networking.nix +++ b/modules/hardware/networking.nix @@ -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 { diff --git a/modules/software/system/zswap.nix b/modules/software/system/zswap.nix deleted file mode 100644 index fdfb5c1..0000000 --- a/modules/software/system/zswap.nix +++ /dev/null @@ -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" - ]; - }; -} diff --git a/modules/software/tools/direnv.nix b/modules/software/tools/direnv.nix new file mode 100644 index 0000000..99893be --- /dev/null +++ b/modules/software/tools/direnv.nix @@ -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; + }; + }; +} diff --git a/modules/software/dev/git.nix b/modules/software/tools/git.nix similarity index 94% rename from modules/software/dev/git.nix rename to modules/software/tools/git.nix index ef26246..eeade6e 100644 --- a/modules/software/dev/git.nix +++ b/modules/software/tools/git.nix @@ -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; diff --git a/modules/software/tools/noisetorch.nix b/modules/software/tools/noisetorch.nix deleted file mode 100644 index 4479532..0000000 --- a/modules/software/tools/noisetorch.nix +++ /dev/null @@ -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; - }; -}