diff --git a/flake.nix b/flake.nix index 86b248b..7e3c9c3 100644 --- a/flake.nix +++ b/flake.nix @@ -39,7 +39,11 @@ flake = false; }; - # TODO: Add Disko - https://github.com/nix-community/disko + # Disk management via Disko - https://github.com/nix-community/disko + disko = { + url = "github:nix-community/disko/v1.6.1"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; outputs = @@ -52,6 +56,7 @@ nixos-hardware, lix-module, nix-secrets, + disko, ... }: let @@ -76,6 +81,7 @@ lanzaboote.nixosModules.lanzaboote nix-flatpak.nixosModules.nix-flatpak home-manager.nixosModules.home-manager + disko.nixosModules.disko { home-manager = { /* diff --git a/hosts/Khanda/hardware-configuration.nix b/hosts/Khanda/hardware-configuration.nix index d5c2e00..3333807 100644 --- a/hosts/Khanda/hardware-configuration.nix +++ b/hosts/Khanda/hardware-configuration.nix @@ -81,6 +81,7 @@ }; }; + # TODO: Disable once DIsko is up and running swapDevices = [ { device = "/dev/disk/by-uuid/8c2519d9-3e47-4aa1-908d-98b1aa8b909d"; } ]; networking = { @@ -100,4 +101,73 @@ # NOTE: Use a default kernel to skip full kernel rebuilds # boot.kernelPackages = lib.mkForce pkgs.linuxPackages_latest; + + # Disk management + disko.enableConfig = false; # Disable while testing + disko.devices = { + disk = { + nvme0n1 = { + type = "disk"; + device = "/dev/disk/by-id/nvme-MZ9L4256HCJQ-00BMV-SAMSUNG_S69VNE0X195093"; + content = { + type = "gpt"; + partitions = { + ESP = { + priority = 1; + name = "ESP"; + label = "boot"; + size = "1G"; + type = "EF00"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + }; + }; + luks = { + size = "100%"; + label = "nixos"; + content = { + type = "luks"; + name = "cryptroot"; + settings = { + allowDiscards = true; + crypttabExtraOpts = ["tpm2-device=auto"]; + }; + content = { + type = "btrfs"; + extraArgs = [ "-f" ]; # Override existing partition + # Subvolumes must set a mountpoint in order to be mounted, + # unless their parent is mounted + subvolumes = { + # Subvolume name is different from mountpoint + "/root" = { + mountOptions = [ "compress=zstd" "noatime" ]; + mountpoint = "/"; + }; + "/home" = { + mountOptions = [ "compress=zstd" "noatime" ]; + mountpoint = "/home"; + }; + "/nix" = { + mountOptions = [ "compress=zstd" "noatime" ]; + mountpoint = "/nix"; + }; + "/swap" = { + mountpoint = "/.swapvol"; + swap.swapfile.size = "8G"; + }; + "/log" = { + mountpoint = "/var/log"; + mountOptions = ["compress=zstd" "noatime"]; + }; + }; + }; + }; + }; + }; + }; + }; + }; + }; }