From 1c3161233550db32a3f4ad1da1cce32d2ef2a800 Mon Sep 17 00:00:00 2001 From: lassulus Date: Tue, 16 May 2023 15:31:18 +0200 Subject: [PATCH] lib: read types from subdir --- lib/default.nix | 29 ++++++++++------------------- lib/{ => types}/btrfs.nix | 0 lib/{ => types}/btrfs_subvol.nix | 0 lib/{ => types}/disk.nix | 0 lib/{ => types}/filesystem.nix | 0 lib/{ => types}/luks.nix | 0 lib/{ => types}/lvm_pv.nix | 0 lib/{ => types}/lvm_vg.nix | 0 lib/{ => types}/mdadm.nix | 0 lib/{ => types}/mdraid.nix | 0 lib/{ => types}/nodev.nix | 0 lib/{ => types}/swap.nix | 0 lib/{ => types}/table.nix | 0 lib/{ => types}/zfs.nix | 0 lib/{ => types}/zfs_fs.nix | 0 lib/{ => types}/zfs_volume.nix | 0 lib/{ => types}/zpool.nix | 0 17 files changed, 10 insertions(+), 19 deletions(-) rename lib/{ => types}/btrfs.nix (100%) rename lib/{ => types}/btrfs_subvol.nix (100%) rename lib/{ => types}/disk.nix (100%) rename lib/{ => types}/filesystem.nix (100%) rename lib/{ => types}/luks.nix (100%) rename lib/{ => types}/lvm_pv.nix (100%) rename lib/{ => types}/lvm_vg.nix (100%) rename lib/{ => types}/mdadm.nix (100%) rename lib/{ => types}/mdraid.nix (100%) rename lib/{ => types}/nodev.nix (100%) rename lib/{ => types}/swap.nix (100%) rename lib/{ => types}/table.nix (100%) rename lib/{ => types}/zfs.nix (100%) rename lib/{ => types}/zfs_fs.nix (100%) rename lib/{ => types}/zfs_volume.nix (100%) rename lib/{ => types}/zpool.nix (100%) diff --git a/lib/default.nix b/lib/default.nix index a5854d0..98b779c 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -337,25 +337,16 @@ let }; }; - types = lib.mapAttrs (_: diskoLib.mkSubType) { - nodev = ./nodev.nix; - btrfs = ./btrfs.nix; - btrfs_subvol = ./btrfs_subvol.nix; - filesystem = ./filesystem.nix; - table = ./table.nix; - swap = ./swap.nix; - lvm_pv = ./lvm_pv.nix; - lvm_vg = ./lvm_vg.nix; - zfs = ./zfs.nix; - zpool = ./zpool.nix; - zfs_dataset = ./zfs_dataset.nix; - zfs_fs = ./zfs_fs.nix; - zfs_volume = ./zfs_volume.nix; - mdadm = ./mdadm.nix; - mdraid = ./mdraid.nix; - luks = ./luks.nix; - disk = ./disk.nix; - }; + # import all tge types from the types directory + types = lib.listToAttrs ( + map + (file: lib.nameValuePair + (lib.removeSuffix ".nix" file) + (diskoLib.mkSubType ./types/${file}) + ) + (lib.attrNames (builtins.readDir ./types)) + ); + }; in diskoLib diff --git a/lib/btrfs.nix b/lib/types/btrfs.nix similarity index 100% rename from lib/btrfs.nix rename to lib/types/btrfs.nix diff --git a/lib/btrfs_subvol.nix b/lib/types/btrfs_subvol.nix similarity index 100% rename from lib/btrfs_subvol.nix rename to lib/types/btrfs_subvol.nix diff --git a/lib/disk.nix b/lib/types/disk.nix similarity index 100% rename from lib/disk.nix rename to lib/types/disk.nix diff --git a/lib/filesystem.nix b/lib/types/filesystem.nix similarity index 100% rename from lib/filesystem.nix rename to lib/types/filesystem.nix diff --git a/lib/luks.nix b/lib/types/luks.nix similarity index 100% rename from lib/luks.nix rename to lib/types/luks.nix diff --git a/lib/lvm_pv.nix b/lib/types/lvm_pv.nix similarity index 100% rename from lib/lvm_pv.nix rename to lib/types/lvm_pv.nix diff --git a/lib/lvm_vg.nix b/lib/types/lvm_vg.nix similarity index 100% rename from lib/lvm_vg.nix rename to lib/types/lvm_vg.nix diff --git a/lib/mdadm.nix b/lib/types/mdadm.nix similarity index 100% rename from lib/mdadm.nix rename to lib/types/mdadm.nix diff --git a/lib/mdraid.nix b/lib/types/mdraid.nix similarity index 100% rename from lib/mdraid.nix rename to lib/types/mdraid.nix diff --git a/lib/nodev.nix b/lib/types/nodev.nix similarity index 100% rename from lib/nodev.nix rename to lib/types/nodev.nix diff --git a/lib/swap.nix b/lib/types/swap.nix similarity index 100% rename from lib/swap.nix rename to lib/types/swap.nix diff --git a/lib/table.nix b/lib/types/table.nix similarity index 100% rename from lib/table.nix rename to lib/types/table.nix diff --git a/lib/zfs.nix b/lib/types/zfs.nix similarity index 100% rename from lib/zfs.nix rename to lib/types/zfs.nix diff --git a/lib/zfs_fs.nix b/lib/types/zfs_fs.nix similarity index 100% rename from lib/zfs_fs.nix rename to lib/types/zfs_fs.nix diff --git a/lib/zfs_volume.nix b/lib/types/zfs_volume.nix similarity index 100% rename from lib/zfs_volume.nix rename to lib/types/zfs_volume.nix diff --git a/lib/zpool.nix b/lib/types/zpool.nix similarity index 100% rename from lib/zpool.nix rename to lib/types/zpool.nix