From ab6245fe26ffbd22f4a1dc46f003314f5147a426 Mon Sep 17 00:00:00 2001 From: janis Date: Tue, 18 Nov 2025 15:45:09 +0100 Subject: [PATCH] restructure system.nix into multiple files --- system/boot.nix | 18 +++++ system/default.nix | 152 +++----------------------------------- system/fonts.nix | 40 ++++++++++ system/hardware.nix | 10 +++ system/networking.nix | 26 +++++++ system/power.nix | 37 ++++++++++ system/qemu.nix | 10 +++ system/virtualisation.nix | 16 ++++ system/wireless.nix | 15 ++++ 9 files changed, 182 insertions(+), 142 deletions(-) create mode 100644 system/boot.nix create mode 100644 system/fonts.nix create mode 100644 system/hardware.nix create mode 100644 system/networking.nix create mode 100644 system/power.nix create mode 100644 system/qemu.nix create mode 100644 system/virtualisation.nix create mode 100644 system/wireless.nix diff --git a/system/boot.nix b/system/boot.nix new file mode 100644 index 0000000..a16a115 --- /dev/null +++ b/system/boot.nix @@ -0,0 +1,18 @@ +{pkgs, ...}: { + boot = { + loader = { + grub = { + enable = true; + devices = [ "nodev" ]; + efiSupport = true; + useOSProber = true; + }; + # systemd-boot.enable = true; + efi.canTouchEfiVariables = true; + # timeout = 0; + }; + + # kernelModules = []; + kernelPackages = pkgs.linuxPackages_zen; + }; +} diff --git a/system/default.nix b/system/default.nix index 2632e98..bd38170 100644 --- a/system/default.nix +++ b/system/default.nix @@ -1,6 +1,13 @@ -{inputs, lib, pkgs, config, ...}: { +{pkgs, ...}: { imports = [ - ../options.nix + ./boot.nix + ./fonts.nix + ./hardware.nix + ./networking.nix + ./power.nix + ./qemu.nix + ./virtualisation.nix + ./wireless.nix ]; environment.systemPackages = with pkgs; [ @@ -34,25 +41,7 @@ }; }; - boot = { - loader = { - systemd-boot.enable = true; - efi.canTouchEfiVariables = true; - # timeout = 0; - }; - - # kernelModules = []; - kernelPackages = pkgs.linuxPackages_zen; - }; - - hardware = { - enableAllFirmware = true; - amdgpu.initrd.enable = true; - graphics = { - enable = true; - enable32Bit = true; - }; - }; + time.hardwareClockInLocalTime = true; security = { polkit.enable = true; @@ -60,80 +49,6 @@ sudo.wheelNeedsPassword = false; # Allow sudo without password }; - fonts = { - enableDefaultPackages = true; - packages = with pkgs; [ - noto-fonts - noto-fonts-cjk-sans - noto-fonts-emoji - liberation_ttf - roboto - roboto-mono - twitter-color-emoji - nerd-fonts.fira-code - nerd-fonts.fira-mono - unicode-emoji - fira-sans - font-awesome - fira-mono - fira-code - material-icons - source-sans - source-code-pro - pkgs.nur.repos.redpz.sf-mono - - inputs.apple-fonts.packages.${pkgs.system}.sf-pro-nerd - inputs.apple-fonts.packages.${pkgs.system}.sf-mono-nerd - inputs.apple-fonts.packages.${pkgs.system}.sf-compact-nerd - inputs.apple-fonts.packages.${pkgs.system}.ny-nerd - - ]; - fontconfig = { - defaultFonts = { - monospace = ["SF Mono" "Fira Mono" "Noto Mono"]; - serif = ["Noto Serif"]; - sansSerif = ["SF Pro Text" "Noto Sans" "Roboto"]; - emoji = ["Twitter Color Emoji" "Noto Emoji"]; - }; - }; - }; - - virtualisation = lib.mkIf config.enableVirtualisation { - libvirtd = { - enable = true; - qemu = { - package = pkgs.qemu_kvm; - runAsRoot = true; - swtpm.enable = true; - }; - }; - }; - - networking = { - nameservers = [ "9.9.9.9#dns.quad9.net" "1.1.1.1#one.one.one.one" ]; - # networkmanager.wifi.backend = "iwd"; - # networkmanager.enable = true; - - wireless.iwd = { - enable = true; - settings = { - Settings ={ - AutoConnect = true; - }; - }; - }; - firewall = { - enable = true; - # ssh: 22 TCP - # cups: 631 TCP - # syncthing: - # 22000 TCP and/or UDP for sync traffic - # 21027/UDP for discovery - allowedTCPPorts = [ 22 22000 631 ]; - allowedUDPPorts = [ 22000 21027 ]; - }; - }; - time.timeZone = "Europe/Amsterdam"; i18n.defaultLocale = "en_GB.UTF-8"; @@ -143,55 +58,8 @@ }; services = { - qemuGuest.enable = config.vmGuest; - spice-vdagentd.enable = config.vmGuest; - dbus.implementation = "broker"; - connman = { - enable = true; - wifi.backend = "iwd"; # Use iwd for Wi-Fi management. - extraFlags = [ "--nodnsproxy" ]; - }; - - resolved = { - enable = true; - dnssec = "true"; - domains = ["~."]; - fallbackDns = [ "9.9.9.9#dns.quad9.net" "149.112.112.112#dns.quad9.net" "1.1.1.1#one.one.one.one" "1.0.0.1#one.one.one.one" ]; - dnsovertls = "true"; - }; - - thermald.enable = config.useThermald; - - tlp = lib.mkIf (config.has_battery) { - enable = true; - settings = { - START_CHARGE_THRESH_BAT0 = 50; - STOP_CHARGE_THRESH_BAT0 = 85; - }; - } // config.tlpConfig or {}; - - auto-cpufreq = lib.mkIf (config.has_battery) { - enable = true; - settings = { - battery = { - governor = "powersave"; # Set the CPU governor to powersave. - energy_performance_preference = "power"; - turbo = "never"; - - # enable_thresholds = true; - # start_threshold = 50; - # stop_threshold = 90; - }; - - charger = { - governor = "performance"; # Set the CPU governor to performance when charging. - turbo = "auto"; - }; - }; - } // config.cpufreqConfig or {}; - pipewire = { enable = true; pulse.enable = true; diff --git a/system/fonts.nix b/system/fonts.nix new file mode 100644 index 0000000..5fb2b62 --- /dev/null +++ b/system/fonts.nix @@ -0,0 +1,40 @@ +{inputs, pkgs, ...}: { + fonts = { + enableDefaultPackages = true; + packages = with pkgs; [ + noto-fonts + noto-fonts-cjk-sans + noto-fonts-emoji + liberation_ttf + roboto + roboto-mono + twitter-color-emoji + nerd-fonts.fira-code + nerd-fonts.fira-mono + unicode-emoji + fira-sans + font-awesome + fira-mono + fira-code + material-icons + source-sans + source-code-pro + pkgs.nur.repos.redpz.sf-mono + + inputs.apple-fonts.packages.${pkgs.system}.sf-pro-nerd + inputs.apple-fonts.packages.${pkgs.system}.sf-mono-nerd + inputs.apple-fonts.packages.${pkgs.system}.sf-compact-nerd + inputs.apple-fonts.packages.${pkgs.system}.ny-nerd + + ]; + fontconfig = { + defaultFonts = { + monospace = ["SF Mono" "Fira Mono" "Noto Mono"]; + serif = ["Noto Serif"]; + sansSerif = ["SF Pro Text" "Noto Sans" "Roboto"]; + emoji = ["Twitter Color Emoji" "Noto Emoji"]; + }; + }; + }; + +} diff --git a/system/hardware.nix b/system/hardware.nix new file mode 100644 index 0000000..77d8382 --- /dev/null +++ b/system/hardware.nix @@ -0,0 +1,10 @@ +{...}: { + hardware = { + enableAllFirmware = true; + amdgpu.initrd.enable = true; + graphics = { + enable = true; + enable32Bit = true; + }; + }; +} diff --git a/system/networking.nix b/system/networking.nix new file mode 100644 index 0000000..2d15526 --- /dev/null +++ b/system/networking.nix @@ -0,0 +1,26 @@ +{...}: { + networking = { + nameservers = [ "9.9.9.9#dns.quad9.net" "1.1.1.1#one.one.one.one" ]; + # networkmanager.wifi.backend = "iwd"; + # networkmanager.enable = true; + + firewall = { + enable = true; + # ssh: 22 TCP + # cups: 631 TCP + # syncthing: + # 22000 TCP and/or UDP for sync traffic + # 21027/UDP for discovery + allowedTCPPorts = [ 22 22000 631 ]; + allowedUDPPorts = [ 22000 21027 ]; + }; + }; + + services.resolved = { + enable = true; + dnssec = "true"; + domains = ["~."]; + fallbackDns = [ "9.9.9.9#dns.quad9.net" "149.112.112.112#dns.quad9.net" "1.1.1.1#one.one.one.one" "1.0.0.1#one.one.one.one" ]; + dnsovertls = "true"; + }; +} diff --git a/system/power.nix b/system/power.nix new file mode 100644 index 0000000..78fe719 --- /dev/null +++ b/system/power.nix @@ -0,0 +1,37 @@ +{lib, config, ...}: { + imports = [ + ../options.nix + ]; + + services = { + thermald.enable = config.useThermald; + + tlp = lib.mkIf (config.has_battery) { + enable = true; + settings = { + START_CHARGE_THRESH_BAT0 = 50; + STOP_CHARGE_THRESH_BAT0 = 85; + }; + } // config.tlpConfig or {}; + + auto-cpufreq = lib.mkIf (config.has_battery) { + enable = true; + settings = { + battery = { + governor = "powersave"; # Set the CPU governor to powersave. + energy_performance_preference = "power"; + turbo = "never"; + + # enable_thresholds = true; + # start_threshold = 50; + # stop_threshold = 90; + }; + + charger = { + governor = "performance"; # Set the CPU governor to performance when charging. + turbo = "auto"; + }; + }; + } // config.cpufreqConfig or {}; + }; +} diff --git a/system/qemu.nix b/system/qemu.nix new file mode 100644 index 0000000..5cf7d32 --- /dev/null +++ b/system/qemu.nix @@ -0,0 +1,10 @@ +{config, ...}: { + imports = [ + ../options.nix + ]; + + services = { + qemuGuest.enable = config.vmGuest; + spice-vdagentd.enable = config.vmGuest; + }; +} diff --git a/system/virtualisation.nix b/system/virtualisation.nix new file mode 100644 index 0000000..0d4f67d --- /dev/null +++ b/system/virtualisation.nix @@ -0,0 +1,16 @@ +{lib, pkgs, config, ...}: { + imports = [ + ../options.nix + ]; + + virtualisation = lib.mkIf config.enableVirtualisation { + libvirtd = { + enable = true; + qemu = { + package = pkgs.qemu_kvm; + runAsRoot = true; + swtpm.enable = true; + }; + }; + }; +} diff --git a/system/wireless.nix b/system/wireless.nix new file mode 100644 index 0000000..88340b0 --- /dev/null +++ b/system/wireless.nix @@ -0,0 +1,15 @@ +{...}: { + networking.wireless.iwd = { + enable = true; + settings = { + Settings ={ + AutoConnect = true; + }; + }; + }; + services.connman = { + enable = true; + wifi.backend = "iwd"; # Use iwd for Wi-Fi management. + extraFlags = [ "--nodnsproxy" ]; + }; +}