This commit is contained in:
Shelvacu
2025-06-28 18:41:17 -07:00
committed by Shelvacu on fw
parent dbfa763c40
commit c4b22b1406
3 changed files with 56 additions and 37 deletions

View File

@@ -185,7 +185,7 @@ in
esac
echo "path:"
while [[ -L "$path" ]]; do
dest="$(readlink "$path")"
declare dest="$(readlink -- "$path")"
echo " $path is a symlink to $dest"
if [[ "$dest" != /* ]]; then
dest="$(dirname -- "$path")/$dest"

8
flake.lock generated
View File

@@ -7,11 +7,11 @@
]
},
"locked": {
"lastModified": 1749092770,
"narHash": "sha256-qb8L1q5Gu+RoysPymHn+fR7OpmIcbuWQnxk75m4wXP4=",
"lastModified": 1751161021,
"narHash": "sha256-vQn7xm264wIEG8ZA2UIumy5KiwsMOfmU0twISf0DLYM=",
"ref": "refs/heads/master",
"rev": "4d09eb6a7442b0cc520831bb4cd3d957ac6ab8dc",
"revCount": 1249,
"rev": "b2f7daa80bfb441e25d5e2c53edab8c86a26b5bd",
"revCount": 1250,
"type": "git",
"url": "https://git.uninsane.org/shelvacu/disko.git"
},

View File

@@ -33,10 +33,14 @@ let
size = "${builtins.toString sizeKi}K";
type = fs_type_zfs;
priority = 1000 + value.idx;
content = {
type = "zfs";
pool = poolname;
};
};
}
) slabsMin;
slapParts = lib.mapAttrs (_: v: v.partitionConfig) slabs;
slabParts = lib.mapAttrs (_: v: v.partitionConfig) slabs;
path_prefix = "/dev/disk/by-id/";
# 8TB
seagate_1 = "ata-ST8000DM004-2U9188_ZR115511";
@@ -83,19 +87,51 @@ let
fs_type_zfs = "a504"; # FreeBSD ZFS
poolname = "propdata";
mk_configs = { groupName, drives, partitions }:
builtins.listToAttrs (map (name: {
name = "${groupName}_${lib.last (lib.splitString "_" name)}}";
diskName = groupName: id: "${groupName}_${lib.last (lib.splitString "_" id)}";
mk_configs = { groupName, diskIds, partitions }:
builtins.listToAttrs (map (id: {
name = diskName groupName id;
value = {
type = "disk";
device = path_prefix + name;
device = path_prefix + id;
content = {
type = "gpt";
inherit partitions;
};
};
}) drives)
}) diskIds)
;
groupAttrs = {
easystore14active = {
groupName = "easystore14active";
diskIds = easystores_14_active;
partitions = {
inherit (slabParts) slabA slabB slabC;
};
};
easystore14spare = {
groupName = "easystore14spare";
diskIds = easystores_14_spare;
partitions = {
inherit (slabParts) slabA slabB slabC;
};
};
easystore10 = {
groupName = "easystore10";
diskIds = easystores_10;
partitions = {
inherit (slabParts) slabA slabB;
};
};
seagate8 = {
groupName = "seagate8";
diskIds = seagates;
partitions = {
inherit (slabParts) slabA;
};
};
};
partNames = groupName: partName: map (id: (diskName groupName id)+"-"+partName) groupAttrs.${groupName}.diskIds;
in
{
imports = [ inputs.disko.nixosModules.default ];
@@ -111,27 +147,10 @@ in
checkScripts = true;
rootMountPoint = "/";
devices.disk = {}
// mk_configs {
groupName = "easystore14";
drives = easystores_14;
partitions = {
inherit (slapParts) slabA slabB slabC;
};
}
// mk_configs {
groupName = "easystore10";
drives = easystores_10;
partitions = {
inherit (slapParts) slabA slabB;
};
}
// mk_configs {
groupName = "seagate8";
drives = seagates;
partitions = {
inherit (slapParts) slabA;
};
}
// mk_configs groupAttrs.easystore14active
// mk_configs groupAttrs.easystore14spare
// mk_configs groupAttrs.easystore10
// mk_configs groupAttrs.seagate8
;
devices.zpool."${poolname}" = {
type = "zpool";
@@ -154,26 +173,26 @@ in
redundant_metadata = "most";
xattr = "sa";
};
mode = {
mode.topology = {
type = "topology";
vdev = [
# slabA
{
mode = "raidz3";
members = map (drive: path_prefix+drive+"-part1") (seagates ++ easystores_10 ++ easystores_14_active);
members = lib.concatMap (a: partNames a "slabA") [ "seagate8" "easystore10" "easystore14active" ];
}
# slabB
{
mode = "raidz3";
members = map (drive: path_prefix+drive+"-part2") (easystores_10 ++ easystores_14_active);
members = lib.concatMap (a: partNames a "slabB") [ "easystore10" "easystore14active" ];
}
# slabC
{
mode = "raidz3";
members = map (drive: path_prefix+drive+"-part3") easystores_14_active;
members = partNames "easystore14active" "slabC";
}
];
spare = easystores_14_spare;
spare = lib.concatMap (b: partNames "easystore14spare" b) (builtins.attrNames slabs);
};
};
};