From 0de7ae5a431437c7019d1e5eacd5a91ff5833545 Mon Sep 17 00:00:00 2001 From: serenity-F Date: Sat, 16 Nov 2024 21:10:42 +1000 Subject: [PATCH] added template hosts/orcus/ config --- hosts/orcus/default.nix | 94 +++++++++++++++++++++ hosts/orcus/hardware-configuration.nix | 90 +++++++++++++++++++++ hosts/orcus/modules/default.nix | 14 ++++ hosts/orcus/modules/disko.nix | 69 ++++++++++++++++ hosts/orcus/modules/network.nix | 108 +++++++++++++++++++++++++ hosts/orcus/modules/syncthing.nix | 0 hosts/orcus/modules/zfs.nix | 68 ++++++++++++++++ 7 files changed, 443 insertions(+) create mode 100644 hosts/orcus/default.nix create mode 100644 hosts/orcus/hardware-configuration.nix create mode 100644 hosts/orcus/modules/default.nix create mode 100644 hosts/orcus/modules/disko.nix create mode 100644 hosts/orcus/modules/network.nix create mode 100644 hosts/orcus/modules/syncthing.nix create mode 100644 hosts/orcus/modules/zfs.nix diff --git a/hosts/orcus/default.nix b/hosts/orcus/default.nix new file mode 100644 index 0000000..6a1363d --- /dev/null +++ b/hosts/orcus/default.nix @@ -0,0 +1,94 @@ +{ inputs, outputs, modulesPath, lib, config, pkgs, ... }: + +{ + imports = [ + + ## Host specific files + ./hardware-configuration.nix # hardware config + ./modules # more host specific configs + + ## Shared 'core' config options + ../../core/config.nix + + ]; + + ## ooh, hostname - this one's important! + networking.hostName = "hades"; + + hardware = { + + ## No bluetooth inside Hades (yet) + bluetooth.enable = false; + + graphics = { + enable = true; + #enable32Bit = false; + + ## Packages for the iGPU inside Hades + extraPackages = with pkgs; [ + #intel-compute-runtime + #intel-media-driver + #vaapiIntel + #vaapiVdpau + #libvdpau-va-gl + ]; + + }; + + ## Packages for the dGPU inside Hades + amdgpu = { + initrd.enable = true; + opencl.enable = true; + ## Vulkan packages for the dGPU inside Hades + amdvlk = { + #enable = false; + #package = [ ]; + #support32Bit.enable = false; + #supportExperimental.enable = false; + #settings = { + #}; + }; + }; + + }; + + programs = { + + ## For tweaking system performance + corectrl = { + enable = true; + ## Allows tweaking GPU performance + gpuOverclock = { + enable = true; + ## Needed for radeon GPU overclocking + ppfeaturemask = "0xfffd7fff"; + }; + }; + ## Performance tweaking continued + tuxclocker = { + enable = false; + enableAMD = true; + useUnfree = true; + }; + + }; + + ## Some packages for managing the hardware inside Hades + environment.systemPackages = with pkgs; [ + #umr + lact + radeontop + #amdgpu_top + #radeontools + #radeon-profile + nvtopPackages.amd + ]; + + systemd = { + packages = with pkgs; [ + lact + ]; + services.lactd.wantedBy = [ "multi-user.target" ]; + }; + +} diff --git a/hosts/orcus/hardware-configuration.nix b/hosts/orcus/hardware-configuration.nix new file mode 100644 index 0000000..1b9d04d --- /dev/null +++ b/hosts/orcus/hardware-configuration.nix @@ -0,0 +1,90 @@ +{ lib, config, pkgs, modulesPath, ... }: + +{ + imports = [ + ## Include results from the (non-existent) hardware scan + ## as well as the host-specific hardware config options + (modulesPath + "/installer/scan/not-detected.nix") + + ]; + + fileSystems."/" = { + device = "/dev/disk/by-uuid/5cbed60c-33e3-4d69-a39e-c1d6d19406ea"; + fsType = "btrfs"; + options = [ "subvol=@" ]; + }; + + fileSystems."/home/serenity/Disks/Tartarus" = { + device = "/dev/disk/by-uuid/26d8d9d1-67d2-4d61-a092-10ed7368b9f6"; + fsType = "ext4"; + options = [ "users" ]; + }; + + #fileSystems."/home/serenity/Disks/Orcus" = { + #device = "/dev/disk/???"; + #fsType = "zfs"; + #options = [ ]; + #}; + + swapDevices = [ ]; + + ## Enable swap on luks + 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 = { + "/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 = { + efi = { + canTouchEfiVariables = true; + }; + ## For some reason GPT/UEFI didn't work, so neither does systemd-boot + ## stuck using MBR/DOS and GRUB instead + grub = { + enable = true; + device = "/dev/sda"; + enableCryptodisk = true; + }; + }; + + }; + ## 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/hosts/orcus/modules/default.nix b/hosts/orcus/modules/default.nix new file mode 100644 index 0000000..f4251bd --- /dev/null +++ b/hosts/orcus/modules/default.nix @@ -0,0 +1,14 @@ +{ inputs, outputs, modulesPath, lib, config, pkgs, ... }: + +{ + imports = [ + + ## Selected modules for import + ./zfs.nix # zfs storage config + #./disko.nix # disk/partition config + ./network.nix # network/internet config + #./syncthing.nix # syncthing config + + ]; + +} diff --git a/hosts/orcus/modules/disko.nix b/hosts/orcus/modules/disko.nix new file mode 100644 index 0000000..494bf7d --- /dev/null +++ b/hosts/orcus/modules/disko.nix @@ -0,0 +1,69 @@ +{ + + disko.devices = { + disk = { + + sda = { + type = "disk"; + device = "/dev/disk/by-id/ata-SAMSUNG_MZNLN128HAHQ-000H1_S3T8NF0K724651"; + content = { + type = "gpt"; + partitions = { + ESP = { + size = "1024M"; + type = "EF00"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + mountOptions = [ + "defaults" + ]; + }; + }; + + luks = { + size = "100%"; + content = { + type = "luks"; + name = "pomegranate"; + ## disable settings.keyFile if you want to use interactive password entry + #passwordFile = "/tmp/secret.key"; # Interactive + settings = { + allowDiscards = true; + #keyFile = "/tmp/secret.key"; + }; + #additionalKeyFiles = [ "/tmp/additionalSecret.key" ]; + content = { + type = "btrfs"; + extraArgs = [ "-f" ]; + subvolumes = { + "/root" = { + mountpoint = "/"; + mountOptions = [ "compress=zstd" "noatime" ]; + }; + "/home" = { + mountpoint = "/home"; + mountOptions = [ "compress=zstd" "noatime" ]; + }; + "/nix" = { + mountpoint = "/nix"; + mountOptions = [ "compress=zstd" "noatime" ]; + }; + "/swap" = { + mountpoint = "/.swapvol"; + swap.swapfile.size = "8192M"; + }; + }; + + }; + }; + }; + }; + }; + }; + }; + + }; + +} diff --git a/hosts/orcus/modules/network.nix b/hosts/orcus/modules/network.nix new file mode 100644 index 0000000..110cdfb --- /dev/null +++ b/hosts/orcus/modules/network.nix @@ -0,0 +1,108 @@ +{ pkgs, lib, config, ... }: + +{ + + imports = [ + # ./file.nix + ]; + + networking = { + wireless.enable = false; + nameservers = [ "127.0.0.1" "::1" ]; + networkmanager = { + enable = true; + dns = "none"; + }; + + #nameservers = [ + #"1.1.1.1" + #]; + + #proxy = { + #default = "https://user:password@proxy:port/"; + #noProxy = "127.0.0.1, localhost, internal.domain"; + #}; + + }; + + ## i knooooowwwwwww i need a proper firewall config but im laaaazzyyyyyyyyyy + networking.firewall = rec { + enable = true; + #checkReversePath = "loose"; + #allowedTCPPortRanges = [ { from = 1720; to = 1770; } ]; + #allowedUDPPortRanges = allowedTCPPortRanges; + #interfaces."DEVICENAME".allowedTCPPorts = [ + #22999 + #] + #allowedTCPPorts = [ + #22000 + #21027 + #25565 + #]; + #allowedUDPPorts = [ + #22000 + #21027 + #41641 + #51820 + #]; + }; + + services.dnscrypt-proxy2 = { + enable = true; + settings = { + ipv6_servers = true; + require_dnssec = true; + + sources.public-resolvers = { + urls = [ + "https://raw.githubusercontent.com/DNSCrypt/dnscrypt-resolvers/master/v3/public-resolvers.md" + "https://download.dnscrypt.info/resolvers-list/v3/public-resolvers.md" + ]; + cache_file = "/var/lib/dnscrypt-proxy2/public-resolvers.md"; + minisign_key = "RWQf6LRCGA9i53mlYecO4IzT51TGPpvWucNSCh1CBM0QTaLn73Y7GFO3"; + }; + + # You can choose a specific set of servers from https://github.com/DNSCrypt/dnscrypt-resolvers/blob/master/v3/public-resolvers.md + server_names = [ + "adfilter-syd" + "adfilter-syd-ipv6" + "cs-sydney" + "cs-singapore" + "userspace-australia" + "userspace-australia-ipv6" + ]; + }; + }; + + systemd.services.dnscrypt-proxy2.serviceConfig = { + StateDirectory = "dnscrypt-proxy"; + }; + + ## syncthing for device <-> device filesharing and,,, syncing + ## still not set up, grrrr + services.syncthing = { + enable = false; + user = "serenity"; + dataDir = "/home/serenity/sync/"; + configDir = "/home/serenity/flakes/nixdots/home/common/dotconfig/syncthing/"; + #overrideDevices = true; + #overrideFolder = true; + + ## these 3 devices are pretty much my entire ecosystem for now + settings.devices = { + #hades.id = "DEVICE_ID"; + #proserpina.id = "DEVICE_ID"; + #hecate.id = "DEVICE_ID"; + }; + + ## plan to have this dir automatically committed and pushed to a git repo daily + settings.folders = { + #"FOLDER_ID" = { + #path = "/home/serenity/Documents/Notes"; + #devices = [ "hecate" "hades" "persephone" ]; + #}; + + }; + }; + +} diff --git a/hosts/orcus/modules/syncthing.nix b/hosts/orcus/modules/syncthing.nix new file mode 100644 index 0000000..e69de29 diff --git a/hosts/orcus/modules/zfs.nix b/hosts/orcus/modules/zfs.nix new file mode 100644 index 0000000..b6eacb9 --- /dev/null +++ b/hosts/orcus/modules/zfs.nix @@ -0,0 +1,68 @@ +## ZFS Support NixOS module + +## temporary location while we figure out how ZFS works, +## eventually this will be embedded into the flake in a better way + +{ config, lib, pkgs, ... }: + +let + ## This 'let' binding creates an attribute set + ## called "LatestZfsLinux", which we can call as + ## a package to specify when building our kernel. + latestZfsLinux = lib.pipe pkgs.linuxKernel.packages [ + builtins.attrValues + (builtins.filter ( + kPkgs: + (builtins.tryEval kPkgs).success + && kPkgs ? kernel + && kPkgs.kernel.pname == "linux" + && !kPkgs.zfs.meta.broken + )) + (builtins.sort (a: b: (lib.versionOlder a.kernel.version b.kernel.version))) + lib.last + ]; +in + +{ + + imports = [ + ]; + + ## Enable zfs in kernel and boot + boot = { + kernelPackages = latestZfsLinux; + supportedFilesystems = [ "zfs" ]; + zfs = { + extraPools = [ "orcus" ]; + forceImportRoot = false; + }; + }; + + #fileSystems."/home/serenity/Disks/Orcus" = { + #device = "orcus"; + #fsType = "zfs"; + #options = [ "users" ]; + #}; + + environment.systemPackages = with pkgs; [ + zfs + ]; + + ## Enable trim for ZFS SSDs + services = { + zfs = { + ## Trim for SSSds with ZFS + #trim.enable = true; + ## Autoscrub data integrity ZFS service, + ## more to be added soon + autoScrub = { + enable = true; + }; + }; + }; + + networking = { + hostId = "603b0c8b"; + }; + +}