From e8c7f177e8aaad50767643bd26c85e987a1acc4c Mon Sep 17 00:00:00 2001 From: h7x4 Date: Tue, 27 Jan 2026 17:58:15 +0900 Subject: [PATCH] kommode: use disko to configure disks --- flake.nix | 3 +- hosts/kommode/configuration.nix | 1 + hosts/kommode/disks.nix | 80 ++++++++++++++++++++++++ hosts/kommode/hardware-configuration.nix | 15 ----- 4 files changed, 83 insertions(+), 16 deletions(-) create mode 100644 hosts/kommode/disks.nix diff --git a/flake.nix b/flake.nix index 9dc2058..b533518 100644 --- a/flake.nix +++ b/flake.nix @@ -147,7 +147,7 @@ in { bakke = stableNixosConfig "bakke" { modules = [ - disko.nixosModules.disko + inputs.disko.nixosModules.disko ]; }; bicep = stableNixosConfig "bicep" { @@ -195,6 +195,7 @@ ]; modules = [ inputs.nix-gitea-themes.nixosModules.default + inputs.disko.nixosModules.disko ]; }; diff --git a/hosts/kommode/configuration.nix b/hosts/kommode/configuration.nix index ab32558..a79a5b3 100644 --- a/hosts/kommode/configuration.nix +++ b/hosts/kommode/configuration.nix @@ -4,6 +4,7 @@ # Include the results of the hardware scan. ./hardware-configuration.nix (fp /base) + ./disks.nix ./services/gitea ./services/nginx.nix diff --git a/hosts/kommode/disks.nix b/hosts/kommode/disks.nix new file mode 100644 index 0000000..55fb500 --- /dev/null +++ b/hosts/kommode/disks.nix @@ -0,0 +1,80 @@ +{ lib, ... }: +{ + disko.devices = { + disk = { + sda = { + type = "disk"; + device = "/dev/sda"; + content = { + type = "gpt"; + partitions = { + root = { + name = "root"; + label = "root"; + start = "1MiB"; + end = "-5G"; + content = { + type = "btrfs"; + extraArgs = [ "-f" ]; # Override existing partition + # subvolumes = let + # makeSnapshottable = subvolPath: mountOptions: let + # name = lib.replaceString "/" "-" subvolPath; + # in { + # "@${name}/active" = { + # mountpoint = subvolPath; + # inherit mountOptions; + # }; + # "@${name}/snapshots" = { + # mountpoint = "${subvolPath}/.snapshots"; + # inherit mountOptions; + # }; + # }; + # in { + # "@" = { }; + # "@/swap" = { + # mountpoint = "/.swapvol"; + # swap.swapfile.size = "4G"; + # }; + # "@/root" = { + # mountpoint = "/"; + # mountOptions = [ "compress=zstd" "noatime" ]; + # }; + # } + # // (makeSnapshottable "/home" [ "compress=zstd" "noatime" ]) + # // (makeSnapshottable "/nix" [ "compress=zstd" "noatime" ]) + # // (makeSnapshottable "/var/lib" [ "compress=zstd" "noatime" ]) + # // (makeSnapshottable "/var/log" [ "compress=zstd" "noatime" ]) + # // (makeSnapshottable "/var/cache" [ "compress=zstd" "noatime" ]); + + # swap.swapfile.size = "4G"; + mountpoint = "/"; + }; + }; + + swap = { + name = "swap"; + label = "swap"; + start = "-5G"; + end = "-1G"; + content.type = "swap"; + }; + + ESP = { + name = "ESP"; + label = "ESP"; + start = "-1G"; + end = "100%"; + type = "EF00"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + mountOptions = [ "umask=0077" ]; + }; + }; + }; + }; + }; + }; + }; +} diff --git a/hosts/kommode/hardware-configuration.nix b/hosts/kommode/hardware-configuration.nix index 987aca5..caea79b 100644 --- a/hosts/kommode/hardware-configuration.nix +++ b/hosts/kommode/hardware-configuration.nix @@ -13,21 +13,6 @@ boot.kernelModules = [ ]; boot.extraModulePackages = [ ]; - fileSystems."/" = - { device = "/dev/disk/by-uuid/d421538f-a260-44ae-8e03-47cac369dcc1"; - fsType = "btrfs"; - }; - - fileSystems."/boot" = - { device = "/dev/disk/by-uuid/86CD-4C23"; - fsType = "vfat"; - options = [ "fmask=0077" "dmask=0077" ]; - }; - - swapDevices = - [ { device = "/dev/disk/by-uuid/4cfbb41e-801f-40dd-8c58-0a0c1a6025f6"; } - ]; - # 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