From 2cef0d1dba0d8da695389b202dea1a8e7c0d612c Mon Sep 17 00:00:00 2001 From: Gabriel Arazas Date: Thu, 21 Nov 2024 11:51:25 +0800 Subject: [PATCH] diskoConfigs/laptop-ssd: init --- configs/disko/laptop-ssd/default.nix | 30 +++++++ configs/flake-parts/disko.nix | 1 + configs/flake-parts/nixos.nix | 1 + configs/nixos/ni/disko.nix | 116 ++++++++++++++------------- 4 files changed, 91 insertions(+), 57 deletions(-) create mode 100644 configs/disko/laptop-ssd/default.nix diff --git a/configs/disko/laptop-ssd/default.nix b/configs/disko/laptop-ssd/default.nix new file mode 100644 index 00000000..63fd8565 --- /dev/null +++ b/configs/disko/laptop-ssd/default.nix @@ -0,0 +1,30 @@ +{ disk ? "/dev/nvme1n1", prefix ? "ni", ... }: + +{ + disko.devices = { + disk."${prefix}-secondary" = { + device = disk; + type = "disk"; + content = { + type = "gpt"; + partitions = { + data = { + size = "100%"; + type = "8300"; + content = { + type = "btrfs"; + extraArgs = [ "-f" ]; + + subvolumes = { + "/root" = { + mountOptions = [ "compress=zstd:10" ]; + mountpoint = "/"; + }; + }; + }; + }; + }; + }; + }; + }; +} diff --git a/configs/flake-parts/disko.nix b/configs/flake-parts/disko.nix index 8f253284..f6b9eb13 100644 --- a/configs/flake-parts/disko.nix +++ b/configs/flake-parts/disko.nix @@ -4,5 +4,6 @@ setups.disko.configs = { archive = { }; external-hdd = { }; + laptop-ssd = { }; }; } diff --git a/configs/flake-parts/nixos.nix b/configs/flake-parts/nixos.nix index cfcc12dd..b7be5c63 100644 --- a/configs/flake-parts/nixos.nix +++ b/configs/flake-parts/nixos.nix @@ -57,6 +57,7 @@ in }; }; }; + diskoConfigs = [ "laptop-ssd" ]; }; # A remote server. diff --git a/configs/nixos/ni/disko.nix b/configs/nixos/ni/disko.nix index 8180932e..cdb74f6e 100644 --- a/configs/nixos/ni/disko.nix +++ b/configs/nixos/ni/disko.nix @@ -1,70 +1,72 @@ -{ disk ? "/dev/nvme0n1", config, lib, ... }: +{ primaryDisk ? "/dev/nvme0n1", secondaryDisk ? null, config, lib, ... }: { - disko.devices = { - disk."${config.hostname}-primary" = { - device = disk; - type = "disk"; - content = { - type = "gpt"; - partitions = { - # You can't really have a btrfs-layered boot so this'll have to do. - ESP = { - priority = 1; - start = "0"; - end = "512MiB"; - type = "EF00"; - content = { - type = "filesystem"; - mountpoint = "/boot"; - format = "vfat"; + disko.devices = lib.mkMerge [ + { + disk."${config.networking.hostName}-primary" = { + device = primaryDisk; + type = "disk"; + content = { + type = "gpt"; + partitions = { + # You can't really have a btrfs-layered boot so this'll have to do. + ESP = { + priority = 1; + start = "0"; + end = "512MiB"; + type = "EF00"; + content = { + type = "filesystem"; + mountpoint = "/boot"; + format = "vfat"; + }; }; - }; - swap = { - start = "-8GiB"; - end = "-0"; - type = "8200"; - content = { - type = "swap"; - randomEncryption = true; + swap = { + start = "-8GiB"; + end = "-0"; + type = "8200"; + content = { + type = "swap"; + randomEncryption = true; + }; }; - }; - root = { - size = "100%"; - type = "8300"; - content = { - type = "btrfs"; - extraArgs = [ "-f" ]; + root = { + size = "100%"; + type = "8300"; + content = { + type = "btrfs"; + extraArgs = [ "-f" ]; - subvolumes = lib.mkMerge [ - { - "/root" = { - mountOptions = [ "compress=zstd" ]; - mountpoint = "/"; - }; - "/home" = { - mountOptions = [ "compress=zstd" ]; - mountpoint = "/home"; - }; - "/nix" = { - mountOptions = [ "compress=zstd" "noatime" "noacl" ]; - mountpoint = "/nix"; - }; - } + subvolumes = lib.mkMerge [ + { + "/root" = { + mountOptions = [ "compress=zstd" ]; + mountpoint = "/"; + }; + "/home" = { + mountOptions = [ "compress=zstd" ]; + mountpoint = "/home"; + }; + "/nix" = { + mountOptions = [ "compress=zstd" "noatime" "noacl" ]; + mountpoint = "/nix"; + }; + } - (lib.mkIf config.services.guix.enable { - "/gnu" = { - mountOptions = [ "compress=zstd" "noatime" "noacl" ]; - mountpoint = "/gnu"; - }; - }) - ]; + (lib.mkIf config.services.guix.enable { + "/gnu" = { + mountOptions = [ "compress=zstd" "noatime" "noacl" ]; + mountpoint = "/gnu"; + }; + }) + ]; + }; }; }; }; }; - }; - }; + } + ]; }