From 0c7d4cc1f7ce567af1098e8752ecddd29e39c521 Mon Sep 17 00:00:00 2001 From: 0xTux <0xtux@pm.me> Date: Sun, 6 Oct 2024 12:54:02 +0530 Subject: [PATCH] add disko --- hosts/canopus/default.nix | 2 + hosts/canopus/disko.nix | 48 ++++++++++++++++++++++++ hosts/canopus/hardware-configuration.nix | 17 +-------- 3 files changed, 51 insertions(+), 16 deletions(-) create mode 100644 hosts/canopus/disko.nix diff --git a/hosts/canopus/default.nix b/hosts/canopus/default.nix index a3c98bf..aec0af8 100755 --- a/hosts/canopus/default.nix +++ b/hosts/canopus/default.nix @@ -5,6 +5,8 @@ }: { imports = [ inputs.nixos-hardware.nixosModules.asus-zephyrus-ga503 + inputs.disko.nixosModules.default + (./disko.nix {device = "/dev/nvme0n1";}) ./hardware-configuration.nix ../common ../../modules/nixos/desktop diff --git a/hosts/canopus/disko.nix b/hosts/canopus/disko.nix new file mode 100644 index 0000000..4494539 --- /dev/null +++ b/hosts/canopus/disko.nix @@ -0,0 +1,48 @@ +{device ? throw "Set this to the disk device, e.g. /dev/nvme0n1", ...}: { + disko.devices.disk.primary = { + inherit device; + type = "disk"; + content = { + type = "gpt"; # GPT partitioning scheme + partitions = { + # EFI Partition + ESP = { + size = "512M"; + type = "EF00"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + mountOptions = ["defaults" "umask=0077"]; + }; + }; + # Btrfs Root Partition + root = { + size = "100%"; # Use remaining space + type = "8300"; # Linux filesystem type + content = { + type = "btrfs"; + subvolumes = { + "/root" = { + mountOptions = ["compress=zstd"]; # Compression for better performance + mountpoint = "/"; # Root subvolume + }; + "/persistent" = { + mountOptions = ["compress=zstd"]; # Compression for persistent data + mountpoint = "/persistent"; # Persistent subvolume + }; + "/nix" = { + mountOptions = [ + "compress=zstd" + "noatime" + "noacl" + ]; # Optimize for Nix store + mountpoint = "/nix"; # Nix subvolume + }; + }; + }; + }; + }; + }; + }; +} diff --git a/hosts/canopus/hardware-configuration.nix b/hosts/canopus/hardware-configuration.nix index 0ea9028..60b5722 100755 --- a/hosts/canopus/hardware-configuration.nix +++ b/hosts/canopus/hardware-configuration.nix @@ -8,26 +8,11 @@ [ (modulesPath + "/installer/scan/not-detected.nix") ]; - boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "usb_storage" "usbhid" "sd_mod" "sdhci_pci" ]; + boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "usbhid" "usb_storage" "sd_mod" "sdhci_pci" ]; boot.initrd.kernelModules = [ ]; boot.kernelModules = [ "kvm-amd" ]; boot.extraModulePackages = [ ]; - fileSystems."/" = - { device = "/dev/disk/by-uuid/b76b1267-0c4e-425b-aec5-968aece6e55d"; - fsType = "ext4"; - }; - - fileSystems."/boot" = - { device = "/dev/disk/by-uuid/2A0B-D264"; - fsType = "vfat"; - options = [ "fmask=0022" "dmask=0022" ]; - }; - - swapDevices = - [ { device = "/dev/disk/by-uuid/f3c7073e-2e51-490f-8668-09faeed74043"; } - ]; - # 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