feat: made impermanence create datasets for zfs and persistence

This commit is contained in:
Leyla Becker 2025-11-07 16:29:56 -06:00
parent 409fdb7276
commit adc6b90c93
4 changed files with 188 additions and 43 deletions

View file

@ -9,18 +9,21 @@ args @ {
# max gpt length is 36 and disk adds formats it like disk-xxxx-zfs which means we need to be 9 characters under that
hashDisk = drive: (builtins.substring 0 27 (builtins.hashString "sha256" drive));
poolVdevs = [
(builtins.map (
device: let
deviceStr =
if builtins.isString device
then device
else device.device;
in
lib.attrsets.nameValuePair (hashDisk deviceStr) deviceStr
)
config.storage.zfs.pool.vdevs)
];
poolVdevs =
builtins.map (
vdev:
builtins.map (
device: let
deviceStr =
if builtins.isString device
then device
else device.device;
in
lib.attrsets.nameValuePair (hashDisk deviceStr) deviceStr
)
vdev
)
config.storage.zfs.pool.vdevs;
poolCache = builtins.map (
name: let
@ -45,7 +48,7 @@ args @ {
then false
else device.boot
)
config.storage.zfs.pool.vdevs);
(lib.lists.flatten config.storage.zfs.pool.vdevs));
allDrives = (lib.lists.flatten poolVdevs) ++ poolCache;
in {
@ -113,8 +116,9 @@ in {
description = "Size of the boot partition on boot drives";
};
vdevs = lib.mkOption {
type = lib.types.listOf deviceType;
type = lib.types.listOf (lib.types.listOf deviceType);
default = [];
description = "List of vdevs, where each vdev is a list of devices";
};
cache = lib.mkOption {
type = lib.types.attrsOf deviceType;
@ -359,7 +363,7 @@ in {
fi
''
)
config.storage.zfs.pool.vdevs}
(lib.lists.flatten config.storage.zfs.pool.vdevs)}
# Check pool mode matches configuration
if ! echo "$pool_status" | grep -q "$expected_mode"; then