From dc4bcb4d22809a3ad880623be98088eb7e4e575c Mon Sep 17 00:00:00 2001
From: Manuel Thalmann <m@nuth.ch>
Date: Sat, 22 Jun 2024 18:21:25 +0200
Subject: [PATCH] Make partition size nullable

---
 lib/modules/partition.nix | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/lib/modules/partition.nix b/lib/modules/partition.nix
index f0995d6f..3859716e 100644
--- a/lib/modules/partition.nix
+++ b/lib/modules/partition.nix
@@ -131,7 +131,7 @@
           order = mkOption {
             type = types.int;
             description = "The sort order of the partition creation.";
-            default = if (!isSwap) && ((builtins.match ".*[^[:space:]].*" config.size) == null) then 1 else 0;
+            default = if (!isSwap) && ((builtins.match ".*[^[:space:]].*" (toString config.size)) == null) then 1 else 0;
           };
 
           label = mkOption {
@@ -147,8 +147,9 @@
           };
 
           size = mkOption {
-            type = types.str;
+            type = types.nullOr types.str;
             description = "The size of the partition.";
+            default = null;
           };
 
           sizeScript = mkOption {
@@ -170,7 +171,7 @@
             then
               ''echo "$(cat /proc/meminfo | awk -F " " '/^MemTotal/ { print $2 }' | awk '{ print int((($1 / 1024 / 1024) * 0.75) + 0.5)}')"G''
             else
-              "echo ${lib.strings.escapeShellArg config.size}"
+              "echo ${lib.strings.escapeShellArg (toString config.size)}"
           );
         };
       }