From 54eb4fce3288f8835381538ba4e47104072063d2 Mon Sep 17 00:00:00 2001 From: serenity-F Date: Thu, 26 Sep 2024 20:59:59 +1000 Subject: [PATCH] tidying up --- core/hosts/hades/hardware/default.nix | 16 ++- core/hosts/persephone/default.nix | 89 +++----------- core/hosts/persephone/hardware.nix | 28 ----- core/hosts/persephone/hardware/default.nix | 112 ++++++++++++++++++ .../hosts/persephone/{ => hardware}/disko.nix | 0 core/hosts/persephone/network.nix | 72 ----------- core/hosts/persephone/network/default.nix | 66 +++++++++++ 7 files changed, 203 insertions(+), 180 deletions(-) delete mode 100644 core/hosts/persephone/hardware.nix create mode 100644 core/hosts/persephone/hardware/default.nix rename core/hosts/persephone/{ => hardware}/disko.nix (100%) delete mode 100644 core/hosts/persephone/network.nix create mode 100644 core/hosts/persephone/network/default.nix diff --git a/core/hosts/hades/hardware/default.nix b/core/hosts/hades/hardware/default.nix index f28c0fa..68c19ea 100644 --- a/core/hosts/hades/hardware/default.nix +++ b/core/hosts/hades/hardware/default.nix @@ -30,17 +30,17 @@ ## Enable swap on luks boot = { - kernelModules = [ - "kvm-intel" - ]; - extraModulePackages = [ - ]; + kernelModules = [ "kvm-intel" ]; + extraModulePackages = [ ]; supportedFilesystems = [ "btrfs" "xfs" "ntfs" ]; + initrd = { + systemd.enable = true; + kernelModules = [ ]; availableKernelModules = [ "xhci_pci" "ehci_pci" @@ -49,20 +49,18 @@ "usb_storage" "sd_mod" ]; - kernelModules = [ - ]; - - systemd.enable = true; secrets = { "/boot/crypto_keyfile.bin" = null; }; + luks = { devices."luks-3de671ef-22a3-4f28-9251-a0687ab44f96" = { device = "/dev/disk/by-uuid/3de671ef-22a3-4f28-9251-a0687ab44f96"; #keyFile = "/boot/crypto_keyfile.bin"; }; }; + }; loader = { diff --git a/core/hosts/persephone/default.nix b/core/hosts/persephone/default.nix index 65e7fce..267bb05 100644 --- a/core/hosts/persephone/default.nix +++ b/core/hosts/persephone/default.nix @@ -2,88 +2,35 @@ { imports = [ - ## Include the results of the hardware scan. - ./hardware.nix - #${builtins.fetchTarball "https://github.com/nix-community/disko/archive/master.tar.gz"}/module.nix" - ./network.nix + + ## Import necessary flake modules + #"${builtins.fetchTarball ""}/module.nix" + + ## Include host specific options + ./hardware + ./network + + ## Include core config options ../../config.nix - + ]; - ## Enable swap on luks - boot = { - - loader = { - systemd-boot = { - enable = true; - configurationLimit = 5; - }; - efi = { - canTouchEfiVariables = true; - #efiSysMountPoint = "/boot/efi"; - }; - }; - - initrd = { - systemd.enable = true; - secrets = { - #"crypto_keyfile.bin" = null; - }; - #luks = { - #devices."luks-DISK_UUID" = { - #device = "/dev/disk/by-uuid/DISK_UUID"; - #keyfile = "/crypto_keyfile.bin"; - #}; - #}; - }; - - }; - - services.fstrim.enable = true; - - powerManagement = { - enable = true; - powertop.enable = true; - #cpuFreqGovernor = Lib.mkDefault "powersave"; - #cpufreq = { - #min = 80000; - #max = 2000000; - #}; - }; - - environment.memoryAllocator.provider = "graphene-hardened-light"; - - hardware = { - - cpu.intel.updateMicrocode = true; - - enableAllFirmware = false; - - bluetooth.enable = true; - - opengl = { - enable = true; - extraPackages = with pkgs; [ - intel-compute-runtime - intel-media-driver - vaapiIntel - vaapiVdpau - libvdpau-va-gl - ]; - }; - - }; - nix = { + #settings = { #}; + gc = { + ## Automatically run 'nix-collect-garbage', automatic = true; + ## every day, dates = "daily"; - options = "--delete-older-than 2d"; + ## and clear junk older than 1 day + options = "--delete-older-than 1d"; + + ## No clue what this does lol. persistent = true; }; }; - system.stateVersion = "23.11"; } diff --git a/core/hosts/persephone/hardware.nix b/core/hosts/persephone/hardware.nix deleted file mode 100644 index e3141bb..0000000 --- a/core/hosts/persephone/hardware.nix +++ /dev/null @@ -1,28 +0,0 @@ -# Do not modify this file! It was generated by ‘nixos-generate-config’ -# and may be overwritten by future invocations. Please make changes -# to /etc/nixos/configuration.nix instead. -{ config, lib, pkgs, modulesPath, ... }: - -{ - imports = - [ - (modulesPath + "/installer/scan/not-detected.nix") - ./disko.nix - ]; - - boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "usb_storage" "sd_mod" ]; - boot.initrd.kernelModules = [ ]; - boot.kernelModules = [ "kvm-intel" ]; - boot.extraModulePackages = [ ]; - - # Enables DHCP on each ethernet and wireless interface. In case of scripted networking - # (the default) this is the recommended approach. When using systemd-networkd it's - # still possible to use this option, but it's recommended to use it in conjunction - # with explicit per-interface declarations with `networking.interfaces..useDHCP`. - networking.useDHCP = lib.mkDefault true; - # networking.interfaces.enp0s31f6.useDHCP = lib.mkDefault true; - # networking.interfaces.wlp58s0.useDHCP = lib.mkDefault true; - - nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; - hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; -} diff --git a/core/hosts/persephone/hardware/default.nix b/core/hosts/persephone/hardware/default.nix new file mode 100644 index 0000000..bcfdf89 --- /dev/null +++ b/core/hosts/persephone/hardware/default.nix @@ -0,0 +1,112 @@ +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = + ## Import necessary flake modules + #"${builtins.fetchTarball "https://github.com/nix-community/disko/archive/master.tar.gz"}/module.nix" + + ## Include results from the (non-existent) hardware scan + ## as well as the host-specific hardware config options + (modulesPath + "/installer/scan/not-detected.nix") + + ## Disko config, should eventually let us nuke our boot drive and reinstall + ## with zero worries. + ./disko.nix + + ]; + + boot = { + kernelModules = [ "kvm-intel" ]; + extraModulePackages = [ ]; + supportedFilesystems = [ + "btrfs" + "xfs" + "ntfs" + ]; + initrd = { + systemd.enable = true; + kernelModules = [ ]; + availableKernelModules = [ + "xhci_pci" + "ehci_pci" + "ahci" + "usbhid" + "usb_storage" + "sd_mod" + ]; + + secrets = { + #"crypto_keyfile.bin" = null; + }; + #luks = { + #devices."luks-DISK_UUID" = { + #device = "/dev/disk/by-uuid/DISK_UUID"; + #keyfile = "/crypto_keyfile.bin"; + #}; + #}; + }; + + loader = { + systemd-boot = { + enable = true; + configurationLimit = 5; + }; + efi = { + canTouchEfiVariables = true; + #efiSysMountPoint = "/boot/efi"; + }; + }; + + }; + + ## Hardware-related services + services = { + ## TRIM to keep SSDs healthy-ish + fstrim.enable = true; + + }; + + powerManagement = { + enable = true; + powertop.enable = true; + #cpuFreqGovernor = Lib.mkDefault "performance"; + #cpufreq = { + #min = 1500000; + #max = 4400000; + #}; + }; + + hardware = { + ## Pick either "true" OR "lib.mkDefault -" + cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; + #cpu.intel.updateMicrocode = true; + + enableAllFirmware = true; + bluetooth.enable = false; + + graphics = { + enable = true; + ## Packages for integrated graphics inside Persephone + extraPackages = with pkgs; [ + intel-compute-runtime + intel-media-driver + vaapiIntel + vaapiVdpau + libvdpau-va-gl + ]; + }; + }; + + ## Trying out an alternate memory allocator + environment.memoryAllocator.provider = "graphene-hardened-light"; + + ## Enables DHCP on each ethernet and wireless interface. In case of scripted networking + ## (the default) this is the recommended approach. When using systemd-networkd it's + ## still possible to use this option, but it's recommended to use it in conjunction + ## with explicit per-interface declarations with `networking.interfaces..useDHCP`. + networking.useDHCP = lib.mkDefault true; + #networking.interfaces.enp0s31f6.useDHCP = lib.mkDefault true; + #networking.interfaces.wlp58s0.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; +} diff --git a/core/hosts/persephone/disko.nix b/core/hosts/persephone/hardware/disko.nix similarity index 100% rename from core/hosts/persephone/disko.nix rename to core/hosts/persephone/hardware/disko.nix diff --git a/core/hosts/persephone/network.nix b/core/hosts/persephone/network.nix deleted file mode 100644 index 4f6aa60..0000000 --- a/core/hosts/persephone/network.nix +++ /dev/null @@ -1,72 +0,0 @@ -{ pkgs, lib, config, ... }: - -{ - - imports = [ - # ./file.nix - ]; - - networking = { - hostName = "persephone"; - wireless.enable = false; - networkmanager = { - enable = true; - }; - # nameservers = [ - # "1.1.1.1" - # ]; - }; - - # networking.proxy = { - # default = "https://user:password@proxy:port/"; - # noProxy = "127.0.0.1, localhost, internal.comain"; - # }; - - networking.firewall = { - enable = false; - # checkReversePath = "loose"; - # allowedTCPPorts = [ 22000 21027 25565 ]; - # allowedUDPPorts = [ 22000 21027 41641 51820 ]; - # allowedTCPPortRanges = [ - # { from = 9999; to = 9999; } # KDE COnnect - # { from = 9999; to = 9999; } # Nicotine+ - # ]; - # allowedUDPPortRanges = [ - # { from = 9999; to = 9999; } # KDE COnnect - # ]; - # interfaces."DEVICENAME".allowedTCPPorts = [ 22999 ] - }; - - services.syncthing = { - enable = false; - dataDir = "/home/serenity/"; - configDir = "/home/serenity/.config/syncthing"; - user = "serenity"; - settings.devices = { - - # hades.id = "DEVICE_ID"; - # proserpina.id = "DEVICE_ID"; - # hecate.id = "DEVICE_ID"; - - }; - settings.folders = { - - # "FOLDER_ID" = { - # path = "/home/serenity/Documents/Notes"; - # devices = [ "hecate" "hades" "proserpina" ]; - # }; - - # "FOLDER_ID" = { - # path = "/home/serenity/Documents/Notes"; - # devices = [ "hecate" "hades" "proserpina" ]; - # }; - - # "FOLDER_ID" = { - # path = "/home/serenity/Documents/Notes"; - # devices = [ "hecate" "hades" "proserpina" ]; - # }; - - }; - }; - -} diff --git a/core/hosts/persephone/network/default.nix b/core/hosts/persephone/network/default.nix new file mode 100644 index 0000000..56ea19b --- /dev/null +++ b/core/hosts/persephone/network/default.nix @@ -0,0 +1,66 @@ +{ pkgs, lib, config, ... }: + +{ + + imports = [ + ./file.nix + ]; + + networking = { + hostName = "persephone"; + wireless.enable = false; + networkmanager = { + enable = true; + }; + #nameservers = [ + #"1.1.1.1" + #]; + #proxy = { + #default = "https://user:password@proxy:port/"; + #noProxy = "127.0.0.1, localhost, internal.comain"; + #}; + firewall = { + enable = false; + #checkReversePath = "loose"; + #allowedTCPPorts = [ 22000 21027 25565 ]; + #allowedUDPPorts = [ 22000 21027 41641 51820 ]; + #allowedTCPPortRanges = [ + #{ from = 9999; to = 9999; } # KDE COnnect + #{ from = 9999; to = 9999; } # Nicotine+ + #]; + #allowedUDPPortRanges = [ + #{ from = 9999; to = 9999; } # KDE COnnect + #]; + #interfaces."DEVICENAME".allowedTCPPorts = [ 22999 ] + }; + }; + + services.syncthing = { + enable = false; + dataDir = "/home/serenity/"; + configDir = "/home/serenity/.config/syncthing"; + user = "serenity"; + settings = { + devices = { + #hades.id = "DEVICE_ID"; + #proserpina.id = "DEVICE_ID"; + #hecate.id = "DEVICE_ID"; + }; + folders = { + #"FOLDER_ID" = { + #path = "/home/serenity/Documents/Notes"; + #devices = [ "hecate" "hades" "proserpina" ]; + #}; + #"FOLDER_ID" = { + #path = "/home/serenity/Documents/Notes"; + #devices = [ "hecate" "hades" "proserpina" ]; + #}; + #"FOLDER_ID" = { + #path = "/home/serenity/Documents/Notes"; + #devices = [ "hecate" "hades" "proserpina" ]; + #}; + }; + }; + }; + +}