From 3bcc6a1091c695b8ae41f878b49e80d9be0a237d Mon Sep 17 00:00:00 2001 From: Martin Nikov Date: Tue, 7 Oct 2025 14:53:34 +0300 Subject: [PATCH] config(mcl-disko): Add option for swap `randomEncryption` --- modules/mcl-disko/default.nix | 25 +++++++++++++------ .../mcl-disko/primaryPartition/default.nix | 12 ++++++++- modules/mcl-disko/primaryPartition/ext4.nix | 3 ++- .../primaryPartition/zfs-legacy-boot.nix | 3 ++- modules/mcl-disko/primaryPartition/zfs.nix | 3 ++- 5 files changed, 35 insertions(+), 11 deletions(-) diff --git a/modules/mcl-disko/default.nix b/modules/mcl-disko/default.nix index a6499f90..a71b5bb7 100644 --- a/modules/mcl-disko/default.nix +++ b/modules/mcl-disko/default.nix @@ -29,11 +29,20 @@ description = "Declare the type of the primary partition"; }; - swapSize = mkOption { - type = types.nullOr types.str; - default = "32G"; - example = "32768M"; - description = "The size of the hard disk space used when RAM is full"; + swap = { + size = mkOption { + type = types.nullOr types.str; + default = "32G"; + example = "32768M"; + description = "The size of the hard disk space used when RAM is full"; + }; + + randomEncryption = mkOption { + type = types.bool; + default = true; + example = false; + description = "Whether to use random encryption for swap partition"; + }; }; espSize = mkOption { @@ -162,9 +171,10 @@ inherit disk lib; isSecondary = true; espSize = cfg.espSize; - swapSize = cfg.swapSize; + swapSize = cfg.swap.size; partitioningPreset = cfg.partitioningPreset; poolName = cfg.zpool.name; + randomEncryption = cfg.swap.randomEncryption; } else makeSecondaryZfsDisk { @@ -183,9 +193,10 @@ disk = first; isSecondary = false; espSize = cfg.espSize; - swapSize = cfg.swapSize; + swapSize = cfg.swap.size; partitioningPreset = cfg.partitioningPreset; poolName = cfg.zpool.name; + randomEncryption = cfg.swap.randomEncryption; }; }; zpool = import ./zpool.nix { diff --git a/modules/mcl-disko/primaryPartition/default.nix b/modules/mcl-disko/primaryPartition/default.nix index 442c5131..bf9e730e 100644 --- a/modules/mcl-disko/primaryPartition/default.nix +++ b/modules/mcl-disko/primaryPartition/default.nix @@ -6,6 +6,7 @@ swapSize, partitioningPreset, poolName, + randomEncryption, }: { type = "disk"; @@ -21,10 +22,18 @@ espSize swapSize poolName + randomEncryption ; } else if partitioningPreset == "ext4" then - import ./ext4.nix { inherit lib espSize swapSize; } + import ./ext4.nix { + inherit + lib + espSize + swapSize + randomEncryption + ; + } else import ./zfs.nix { inherit @@ -34,6 +43,7 @@ espSize swapSize poolName + randomEncryption ; }; } diff --git a/modules/mcl-disko/primaryPartition/ext4.nix b/modules/mcl-disko/primaryPartition/ext4.nix index 36433f42..a05541e3 100644 --- a/modules/mcl-disko/primaryPartition/ext4.nix +++ b/modules/mcl-disko/primaryPartition/ext4.nix @@ -2,6 +2,7 @@ lib, espSize, swapSize, + randomEncryption, }: { ESP = { @@ -33,7 +34,7 @@ size = swapSize; content = { type = "swap"; - randomEncryption = true; + inherit randomEncryption; }; }; } diff --git a/modules/mcl-disko/primaryPartition/zfs-legacy-boot.nix b/modules/mcl-disko/primaryPartition/zfs-legacy-boot.nix index 187a7d06..31c51bb4 100644 --- a/modules/mcl-disko/primaryPartition/zfs-legacy-boot.nix +++ b/modules/mcl-disko/primaryPartition/zfs-legacy-boot.nix @@ -4,6 +4,7 @@ espSize, swapSize, poolName, + randomEncryption, }: [ { @@ -43,7 +44,7 @@ part-type = "primary"; content = { type = "swap"; - randomEncryption = true; + inherit randomEncryption; }; } ] diff --git a/modules/mcl-disko/primaryPartition/zfs.nix b/modules/mcl-disko/primaryPartition/zfs.nix index 02dd8757..5ae3d500 100644 --- a/modules/mcl-disko/primaryPartition/zfs.nix +++ b/modules/mcl-disko/primaryPartition/zfs.nix @@ -5,6 +5,7 @@ espSize, swapSize, poolName, + randomEncryption, }: { "ESP" = { @@ -38,7 +39,7 @@ size = swapSize; content = { type = "swap"; - randomEncryption = true; + inherit randomEncryption; }; }; }