From eb85e2573da8289280c45e2766615de5f6839e7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Eug=C3=AAnio?= Date: Thu, 13 Jun 2024 22:43:42 -0300 Subject: [PATCH] disko: add monolith config --- flake.lock | 21 +++++ hosts/monolith/default.nix | 169 ++++++++++++++++++----------------- hosts/monolith/partition.nix | 68 ++++++++++++++ 3 files changed, 175 insertions(+), 83 deletions(-) create mode 100644 hosts/monolith/partition.nix diff --git a/flake.lock b/flake.lock index d51c314..8c9aa48 100644 --- a/flake.lock +++ b/flake.lock @@ -148,6 +148,26 @@ "type": "github" } }, + "disko": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1718242063, + "narHash": "sha256-n3AWItJ4a94GT0cray/eUV7tt3mulQ52L+lWJN9d1E8=", + "owner": "nix-community", + "repo": "disko", + "rev": "832a9f2c81ff3485404bd63952eadc17bf7ccef2", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "disko", + "type": "github" + } + }, "dzgui-nix": { "inputs": { "nixpkgs": [ @@ -565,6 +585,7 @@ "agenix": "agenix", "demoji": "demoji", "dhist": "dhist", + "disko": "disko", "dzgui-nix": "dzgui-nix", "home-manager": "home-manager", "nix-index-database": "nix-index-database", diff --git a/hosts/monolith/default.nix b/hosts/monolith/default.nix index 262f19a..ed9acbe 100644 --- a/hosts/monolith/default.nix +++ b/hosts/monolith/default.nix @@ -20,7 +20,10 @@ let ]; in { - imports = [ (modulesPath + "/installer/scan/not-detected.nix") ]; + imports = [ + (modulesPath + "/installer/scan/not-detected.nix") + ./partition.nix + ]; boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" @@ -43,8 +46,8 @@ in "amdgpu.dcdebugmask=0x10" # amdgpu undervolting bug "video=DP-1:1920x1080@144" # hibernation - "resume=LABEL=BTRFS_ROOT" # findmnt -o LABEL --noheadings /swap/ - "resume_offset=36709632" # btrfs inspect-internal map-swapfile -r /swap/swapfile + # "resume=LABEL=BTRFS_ROOT" # findmnt -o LABEL --noheadings /swap/ + # "resume_offset=36709632" # btrfs inspect-internal map-swapfile -r /swap/swapfile ]; systemd.sleep.extraConfig = '' HibernateDelaySec=30s @@ -74,73 +77,73 @@ in }; }; - fileSystems."/" = { - device = "/dev/disk/by-label/BTRFS_ROOT"; - fsType = "btrfs"; - options = [ "subvol=nixos" ] ++ btrfs_options ++ btrfs_ssd; - }; - # boot.initrd.luks.reusePassphrases = true; - boot.initrd.luks.devices = { - "main" = { - bypassWorkqueues = true; - device = "/dev/disk/by-label/CRYPT_ROOT"; - }; - "data" = { - bypassWorkqueues = true; - device = "/dev/disk/by-label/CRYPT_DATA"; - }; - "bigboy" = { - bypassWorkqueues = true; - device = "/dev/disk/by-label/CRYPT_BIGBOY"; - }; - }; - boot.loader.efi.efiSysMountPoint = "/boot/efi"; - fileSystems."/boot/efi" = { - device = "/dev/disk/by-label/NIXBOOT"; - fsType = "vfat"; - }; - fileSystems."/home" = { - device = "/dev/disk/by-label/BTRFS_ROOT"; - fsType = "btrfs"; - options = [ "subvol=home" ] ++ btrfs_options ++ btrfs_ssd; - }; - fileSystems."/home/lelgenio/Games" = { - device = "/dev/disk/by-label/BTRFS_DATA"; - fsType = "btrfs"; - options = [ - "subvol=@games" - "nofail" - ] ++ btrfs_options; - }; - fileSystems."/home/lelgenio/Downloads/Torrents" = { - device = "/dev/disk/by-label/BTRFS_DATA"; - fsType = "btrfs"; - options = [ - "subvol=@torrents" - "nofail" - ] ++ btrfs_options; - }; - fileSystems."/home/lelgenio/Música" = { - device = "/dev/disk/by-label/BTRFS_DATA"; - fsType = "btrfs"; - options = [ - "subvol=@music" - "nofail" - ] ++ btrfs_options; - }; - fileSystems."/home/lelgenio/.local/mount/data" = { - device = "/dev/disk/by-label/BTRFS_DATA"; - fsType = "btrfs"; - options = [ - "subvol=@data" - "nofail" - ] ++ btrfs_options; - }; - fileSystems."/home/lelgenio/.local/mount/bigboy" = { - device = "/dev/disk/by-label/BTRFS_BIGBOY"; - fsType = "btrfs"; - options = [ "nofail" ] ++ btrfs_options ++ btrfs_ssd; - }; + # fileSystems."/" = { + # device = "/dev/disk/by-label/BTRFS_ROOT"; + # fsType = "btrfs"; + # options = [ "subvol=nixos" ] ++ btrfs_options ++ btrfs_ssd; + # }; + # # boot.initrd.luks.reusePassphrases = true; + # boot.initrd.luks.devices = { + # "main" = { + # bypassWorkqueues = true; + # device = "/dev/disk/by-label/CRYPT_ROOT"; + # }; + # "data" = { + # bypassWorkqueues = true; + # device = "/dev/disk/by-label/CRYPT_DATA"; + # }; + # "bigboy" = { + # bypassWorkqueues = true; + # device = "/dev/disk/by-label/CRYPT_BIGBOY"; + # }; + # }; + # boot.loader.efi.efiSysMountPoint = "/boot/efi"; + # fileSystems."/boot/efi" = { + # device = "/dev/disk/by-label/NIXBOOT"; + # fsType = "vfat"; + # }; + # fileSystems."/home" = { + # device = "/dev/disk/by-label/BTRFS_ROOT"; + # fsType = "btrfs"; + # options = [ "subvol=home" ] ++ btrfs_options ++ btrfs_ssd; + # }; + # fileSystems."/home/lelgenio/Games" = { + # device = "/dev/disk/by-label/BTRFS_DATA"; + # fsType = "btrfs"; + # options = [ + # "subvol=@games" + # "nofail" + # ] ++ btrfs_options; + # }; + # fileSystems."/home/lelgenio/Downloads/Torrents" = { + # device = "/dev/disk/by-label/BTRFS_DATA"; + # fsType = "btrfs"; + # options = [ + # "subvol=@torrents" + # "nofail" + # ] ++ btrfs_options; + # }; + # fileSystems."/home/lelgenio/Música" = { + # device = "/dev/disk/by-label/BTRFS_DATA"; + # fsType = "btrfs"; + # options = [ + # "subvol=@music" + # "nofail" + # ] ++ btrfs_options; + # }; + # fileSystems."/home/lelgenio/.local/mount/data" = { + # device = "/dev/disk/by-label/BTRFS_DATA"; + # fsType = "btrfs"; + # options = [ + # "subvol=@data" + # "nofail" + # ] ++ btrfs_options; + # }; + # fileSystems."/home/lelgenio/.local/mount/bigboy" = { + # device = "/dev/disk/by-label/BTRFS_BIGBOY"; + # fsType = "btrfs"; + # options = [ "nofail" ] ++ btrfs_options ++ btrfs_ssd; + # }; # 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 @@ -162,17 +165,17 @@ in ''; # swap - fileSystems."/swap" = { - device = "/dev/disk/by-label/BTRFS_ROOT"; - fsType = "btrfs"; - # Note these options effect the entire BTRFS filesystem and not just this volume, - # with the exception of `"subvol=swap"`, the other options are repeated in my other `fileSystem` mounts - options = [ "subvol=swap" ] ++ btrfs_options ++ btrfs_ssd; - }; - swapDevices = [ - { - device = "/swap/swapfile"; - size = (1024 * 16) + (1024 * 2); # RAM size + 2 GB - } - ]; + # fileSystems."/swap" = { + # device = "/dev/disk/by-label/BTRFS_ROOT"; + # fsType = "btrfs"; + # # Note these options effect the entire BTRFS filesystem and not just this volume, + # # with the exception of `"subvol=swap"`, the other options are repeated in my other `fileSystem` mounts + # options = [ "subvol=swap" ] ++ btrfs_options ++ btrfs_ssd; + # }; + # swapDevices = [ + # { + # device = "/swap/swapfile"; + # size = (1024 * 16) + (1024 * 2); # RAM size + 2 GB + # } + # ]; } diff --git a/hosts/monolith/partition.nix b/hosts/monolith/partition.nix new file mode 100644 index 0000000..d75d814 --- /dev/null +++ b/hosts/monolith/partition.nix @@ -0,0 +1,68 @@ +let + btrfs_options = [ + "compress=zstd:3" + "noatime" + "x-systemd.device-timeout=0" + ]; + btrfs_ssd = btrfs_options ++ [ + "ssd" + "discard=async" + ]; +in +{ + disko.devices = { + disk = { + bigboy_disk = { + type = "disk"; + device = "/dev/nvme0n1"; + content = { + type = "gpt"; + partitions = { + ESP = { + size = "2G"; + type = "EF00"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + mountOptions = [ "defaults" ]; + }; + }; + luks = { + size = "100%"; + content = { + type = "luks"; + name = "bigboy"; + # 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 = { + "/@nixos" = { + mountpoint = "/"; + mountOptions = btrfs_ssd; + }; + "/@home" = { + mountpoint = "/home"; + mountOptions = btrfs_ssd; + }; + "/@swap" = { + mountpoint = "/.swapvol"; + swap.swapfile.size = "32G"; + }; + }; + }; + }; + }; + }; + }; + }; + }; + }; +}