From 3a32da519b1d626e171cac71c65b6885aa12ec38 Mon Sep 17 00:00:00 2001 From: Shahab Dogar Date: Fri, 7 Feb 2025 00:05:50 +0500 Subject: [PATCH] fix: NixOS | fix disko lvm_luks setup --- nixos/disko-config.nix | 150 +++++++++++++++++++++-------------------- 1 file changed, 76 insertions(+), 74 deletions(-) diff --git a/nixos/disko-config.nix b/nixos/disko-config.nix index d45338b..3cea945 100644 --- a/nixos/disko-config.nix +++ b/nixos/disko-config.nix @@ -1,86 +1,88 @@ -{device ? throw "Set this to your disk device, e.g. /dev/sda", ...}: { - disko.devices = { - disk = { - main = { - inherit device; - type = "disk"; - content = { - type = "gpt"; - partitions = { - boot = { - name = "boot"; - size = "1M"; - type = "EF02"; - }; - esp = { - name = "ESP"; - size = "500M"; - type = "EF00"; - content = { - type = "filesystem"; - format = "vfat"; - mountpoint = "/boot"; +{ + disko = { + devices = { + disk = { + main = { + device = "/dev/nvme0n1"; + type = "disk"; + content = { + type = "gpt"; + partitions = { + boot = { + name = "boot"; + size = "1M"; + type = "EF02"; }; - }; - luks = { - size = "100%"; - content = { - name = "crypted"; - type = "luks"; - settings = { - allowDiscards = true; - keyFile = "/tmp/secret.key"; - crypttabExtraOpts = [ - "fido2-device=auto" - "token-timeout=10" - ]; - }; + esp = { + name = "ESP"; + size = "500M"; + type = "EF00"; content = { - type = "lvm_pv"; - vg = "luks_vg"; + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + }; + }; + luks = { + size = "100%"; + content = { + name = "crypted"; + type = "luks"; + passwordFile = "/tmp/secret.key"; + settings = { + allowDiscards = true; + crypttabExtraOpts = [ + "fido2-device=auto" + "token-timeout=10" + ]; + }; + content = { + type = "lvm_pv"; + vg = "luks_vg"; + }; }; }; }; }; }; }; - }; - }; - lvm_vg = { - luks_vg = { - type = "lvm_vg"; - lvs = { - swap = { - size = "64G"; - content = { - type = "swap"; - resumeDevice = true; - }; - }; - root = { - size = "100%FREE"; - content = { - type = "btrfs"; - extraArgs = ["-L" "nixos" "-f"]; - subvolumes = { - "/root" = { - mountpoint = "/"; + lvm_vg = { + luks_vg = { + type = "lvm_vg"; + lvs = { + swap = { + size = "64G"; + content = { + type = "swap"; + resumeDevice = true; }; - "/nix" = { - mountpoint = "/nix"; - mountOptions = [ - "subvol=nix" - "compress=zstd" - "noatime" - ]; - }; - "/persistant" = { - mountpoint = "/persistant"; - mountOptions = [ - "subvol=persistant" - "compress=zstd" - "noatime" - ]; + }; + root = { + size = "100%"; + content = { + type = "btrfs"; + extraArgs = ["-L" "nixos" "-f"]; + subvolumes = { + "/root" = { + mountpoint = "/"; + }; + "/nix" = { + mountpoint = "/nix"; + mountOptions = [ + "subvol=nix" + "compress=zstd" + "noatime" + ]; + }; + "/persistant" = { + mountpoint = "/persistant"; + mountOptions = [ + "subvol=persistant" + "compress=zstd" + "noatime" + ]; + }; + }; }; }; };