diff --git a/flake.nix b/flake.nix index b10ad2a..6d1a806 100644 --- a/flake.nix +++ b/flake.nix @@ -174,6 +174,20 @@ ] ++ osModules; }; + nixos-desk = nixpkgs.lib.nixosSystem { + modules = + [ + ./systems/nixos-desk + { + _module.args = args; + nixpkgs.pkgs = pkgs; + nix.registry.nixpkgs.flake = nixpkgs; + home-manager.sharedModules = hmModules; + home-manager.extraSpecialArgs = args; + } + ] + ++ osModules; + }; }; }; } diff --git a/systems/nixos-desk/default.nix b/systems/nixos-desk/default.nix new file mode 100644 index 0000000..54b6725 --- /dev/null +++ b/systems/nixos-desk/default.nix @@ -0,0 +1,65 @@ +{ config +, lib +, pkgs +, modulesPath +, system +, inputs +, ... +}: { + imports = [ + (modulesPath + "/installer/scan/not-detected.nix") + ../../os-mods/common + ../../os-mods/desktop + ../../os-mods/network + ../../os-mods/virt + ../../users + ./disko.nix + ]; + system.stateVersion = "23.05"; + + boot = { + kernelPackages = pkgs.linuxPackages_latest; + loader = { + systemd-boot = { + enable = true; + configurationLimit = 32; + }; + efi.canTouchEfiVariables = true; + }; + + initrd = { + availableKernelModules = [ "amdgpu" "nvme" "xhci_pci" "uas" "usbhid" "usb_storage" "sd_mod" ]; + kernelModules = [ ]; + systemd.enable = true; + }; + + kernelModules = [ "kvm-amd" "amdgpu" ]; + extraModulePackages = [ ]; + }; + + services.btrfs.autoScrub.enable = true; + services.xserver.videoDrivers = [ "amdgpu" ]; + + networking = { + hostName = "nixos-pulse"; + useDHCP = lib.mkDefault true; + }; + systemd.tmpfiles.rules = [ + "L+ /opt/rocm/hip - - - - ${pkgs.hip}" + ]; + + hardware = { + opengl = { + driSupport = true; + driSupport32Bit = true; + extraPackages = with pkgs; [ + rocm-opencl-icd + rocm-opencl-runtime + ]; + }; + + cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; + }; + + zramSwap.enable = true; +} diff --git a/systems/nixos-desk/disko.nix b/systems/nixos-desk/disko.nix new file mode 100644 index 0000000..aac7df6 --- /dev/null +++ b/systems/nixos-desk/disko.nix @@ -0,0 +1,184 @@ +{ + disko.devices = { + disk = { + cryptboot_1 = { + type = "disk"; + device = "/dev/disk/by-path/pci-0000:08:00.0-nvme-1"; + content = { + type = "gpt"; + partitions = { + luks = { + # size = "831.5G"; + end = "-100G"; + label = "Linux LUKS"; + type = "8309"; + content = { + type = "luks"; + name = "cryptboot_1"; + extraOpenArgs = [ "--allow-discards" ]; + passwordFile = "/tmp/secret.key"; + additionalKeyFiles = [ ]; + # content is empty here as the btrfs partition will be created via extraArgs of the cryptroot_1 partition def + }; + }; + luksSwap = { + # TODO Create + size = "32G"; + content = { + type = "luks"; + name = "cryptswap_0"; + extraOpenArgs = [ "--allow-discards" ]; + passwordFile = "/tmp/secret.key"; + additionalKeyFiles = [ ]; + content = { + type = "swap"; + }; + }; + }; + }; + }; + }; + cryptboot_0 = { + type = "disk"; + device = "/dev/disk/by-path/pci-0000:03:00.0-nvme-1"; + content = { + type = "gpt"; + partitions = { + luks = { + # size = "831.5G"; + end = "-100G"; + label = "Linux LUKS"; + type = "8309"; + content = { + type = "luks"; + name = "cryptboot_0"; + extraOpenArgs = [ "--allow-discards" ]; + passwordFile = "/tmp/secret.key"; + additionalKeyFiles = [ ]; + content = { + # this partiton needs to be in the last parent part alphabetically to ensure the referenced dev already exists + type = "btrfs"; + extraArgs = [ + "-L cryptboot_btrfs" + "-f" + "-m raid1" + "-d raid1" + "/dev/mapper/cryptboot_0" + ]; + subvolumes = { + "/" = { + mountpoint = "/media/@btrfsroot"; + mountOptions = [ + "rw" + "autodefrag" + "compress=zstd" + "discard=async" + "relatime" + "space_cache=v2" + "ssd" + ]; + }; + "/_active" = { }; + "/_active/rootvol" = { }; + "/_active/pkgvol" = { }; + "/_active/nix_rootvol" = { + mountpoint = "/"; + mountOptions = [ + "rw" + "autodefrag" + "compress=zstd" + "discard=async" + "relatime" + "space_cache=v2" + "ssd" + ]; + }; + "/_active/homevol" = { + mountpoint = "/home"; + mountOptions = [ + "rw" + "autodefrag" + "compress=zstd" + "discard=async" + "relatime" + "space_cache=v2" + "ssd" + ]; + }; + "/_active/nixvol" = { + mountpoint = "/nix"; + mountOptions = [ + "rw" + "autodefrag" + "compress=zstd" + "discard=async" + "relatime" + "space_cache=v2" + "ssd" + ]; + }; + }; + }; + }; + }; + ESP = { + label = "EFI system partition"; + name = "ESP"; + size = "1024M"; + type = "EF00"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + mountOptions = [ + "rw" + "relatime" + "fmask=0022" + "dmask=0022" + "codepage=437" + "iocharset=ascii" + "shortname=mixed" + "utf8" + "errors=remount-ro" + ]; + }; + }; + }; + }; + }; + sandisk = { + type = "disk"; + device = "/dev/disk/by-path/pci-0000:06:00.0-ata-4"; + content = { + type = "gpt"; + partitions = { + luks = { + # ~size = "3.4T"; + end = "-250G"; + label = "Linux filesystem"; + type = "8300"; + content = { + type = "btrfs"; + extraArgs = [ ]; + subvolumes = { + "/" = { + mountpoint = "/media/SanDisk"; + mountOptions = [ + "rw" + "autodefrag" + "compress=zstd" + "discard=async" + "relatime" + "space_cache=v2" + "ssd" + ]; + }; + }; + }; + }; + }; + }; + }; + }; + }; +}