From 70efb0a6584efe0d68962328ee4fee61aea82084 Mon Sep 17 00:00:00 2001 From: Felix Uhl Date: Sun, 10 Nov 2024 17:39:39 +0100 Subject: [PATCH] lib: Evaluate partition's _index parameter This is required to be able to generate sgdisk invocations that are equivalent to what's currently generated in nix. --- src/disko_lib/eval-config.nix | 3 ++- tests/disko_lib/eval_config/file-simple-efi-result.json | 2 ++ tests/disko_lib/eval_config/flake-testmachine-result.json | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/disko_lib/eval-config.nix b/src/disko_lib/eval-config.nix index 9225f2c..eebdbe7 100644 --- a/src/disko_lib/eval-config.nix +++ b/src/disko_lib/eval-config.nix @@ -44,6 +44,7 @@ let diskoConfig = evaluatedConfig.config.disko.devices; - finalConfig = lib.filterAttrsRecursive (name: value: !lib.hasPrefix "_" name) diskoConfig; + shouldBeEvaluated = name: (!lib.hasPrefix "_" name) || (name == "_index"); + finalConfig = lib.filterAttrsRecursive (name: value: shouldBeEvaluated name) diskoConfig; in finalConfig diff --git a/tests/disko_lib/eval_config/file-simple-efi-result.json b/tests/disko_lib/eval_config/file-simple-efi-result.json index 5f07782..40ae461 100644 --- a/tests/disko_lib/eval_config/file-simple-efi-result.json +++ b/tests/disko_lib/eval_config/file-simple-efi-result.json @@ -6,6 +6,7 @@ "efiGptPartitionFirst": true, "partitions": { "ESP": { + "_index": 1, "alignment": 0, "content": { "device": "/dev/disk/by-partlabel/disk-main-ESP", @@ -32,6 +33,7 @@ "type": "EF00" }, "root": { + "_index": 2, "alignment": 0, "content": { "device": "/dev/disk/by-partlabel/disk-main-root", diff --git a/tests/disko_lib/eval_config/flake-testmachine-result.json b/tests/disko_lib/eval_config/flake-testmachine-result.json index 00abc61..426f4e5 100644 --- a/tests/disko_lib/eval_config/flake-testmachine-result.json +++ b/tests/disko_lib/eval_config/flake-testmachine-result.json @@ -6,6 +6,7 @@ "efiGptPartitionFirst": true, "partitions": { "ESP": { + "_index": 2, "alignment": 0, "content": { "device": "/dev/disk/by-partlabel/disk-main-ESP", @@ -32,6 +33,7 @@ "type": "EF00" }, "boot": { + "_index": 1, "alignment": 0, "content": null, "device": "/dev/disk/by-partlabel/disk-main-boot", @@ -45,6 +47,7 @@ "type": "EF02" }, "root": { + "_index": 3, "alignment": 0, "content": { "device": "/dev/disk/by-partlabel/disk-main-root",