From 58cd832497f9c87cb4889744b86aba4284fd0474 Mon Sep 17 00:00:00 2001 From: DavHau Date: Fri, 25 Oct 2024 16:22:37 +0700 Subject: [PATCH] lvm_vg: fix size=100% leading to crash lvcreate -l does not accept a '100%' parameter which currently leads to a crash. THis change automatically changes `100%` to `100%FREE` leading to the intended behavior. --- example/luks-lvm.nix | 2 +- lib/types/lvm_vg.nix | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/example/luks-lvm.nix b/example/luks-lvm.nix index 768451b..1bede94 100644 --- a/example/luks-lvm.nix +++ b/example/luks-lvm.nix @@ -45,7 +45,7 @@ type = "lvm_vg"; lvs = { root = { - size = "100M"; + size = "100%"; content = { type = "filesystem"; format = "ext4"; diff --git a/lib/types/lvm_vg.nix b/lib/types/lvm_vg.nix index 9ae6a53..708e88b 100644 --- a/lib/types/lvm_vg.nix +++ b/lib/types/lvm_vg.nix @@ -95,7 +95,7 @@ in --yes \ ${if (lv.lvm_type == "thinlv") then "-V" else if lib.hasInfix "%" lv.size then "-l" else "-L"} \ - ${lv.size} \ + ${if lib.hasSuffix "%" lv.size then "${lv.size}FREE" else lv.size} \ -n "${lv.name}" \ ${lib.optionalString (lv.lvm_type == "thinlv") "--thinpool=${lv.pool}"} \ ${lib.optionalString (lv.lvm_type != null && lv.lvm_type != "thinlv") "--type=${lv.lvm_type}"} \