mirror of
https://github.com/TECHNOFAB11/disko.git
synced 2025-12-12 16:10:03 +01:00
_create: take an attrset
Please enter the commit message for your changes. Lines starting
This commit is contained in:
parent
360ee1522f
commit
30642cadbc
1 changed files with 33 additions and 33 deletions
66
types.nix
66
types.nix
|
|
@ -155,7 +155,7 @@ rec {
|
||||||
sortedDeviceList = diskoLib.sortDevicesByDependencies ((diskoLib.meta devices).deviceDependencies or {}) devices;
|
sortedDeviceList = diskoLib.sortDevicesByDependencies ((diskoLib.meta devices).deviceDependencies or {}) devices;
|
||||||
in ''
|
in ''
|
||||||
set -efux
|
set -efux
|
||||||
${concatMapStrings (dev: attrByPath (dev ++ [ "_create" ]) "" devices) sortedDeviceList}
|
${concatMapStrings (dev: (attrByPath (dev ++ [ "_create" ]) ({}: {}) devices) {}) sortedDeviceList}
|
||||||
'';
|
'';
|
||||||
/* Takes a disko device specification and returns a string which mounts the disks
|
/* Takes a disko device specification and returns a string which mounts the disks
|
||||||
|
|
||||||
|
|
@ -307,8 +307,8 @@ rec {
|
||||||
_create = mkOption {
|
_create = mkOption {
|
||||||
internal = true;
|
internal = true;
|
||||||
readOnly = true;
|
readOnly = true;
|
||||||
type = types.str;
|
type = types.functionTo types.str;
|
||||||
default = "";
|
default = {}: "";
|
||||||
description = "Creation script";
|
description = "Creation script";
|
||||||
};
|
};
|
||||||
_mount = mkOption {
|
_mount = mkOption {
|
||||||
|
|
@ -387,9 +387,9 @@ rec {
|
||||||
internal = true;
|
internal = true;
|
||||||
readOnly = true;
|
readOnly = true;
|
||||||
type = types.functionTo types.str;
|
type = types.functionTo types.str;
|
||||||
default = dev: ''
|
default = {dev}: ''
|
||||||
mkfs.btrfs ${dev} ${config.extraArgs}
|
mkfs.btrfs ${dev} ${config.extraArgs}
|
||||||
${concatMapStrings (subvol: subvol._create dev) (attrValues config.subvolumes)}
|
${concatMapStrings (subvol: subvol._create { inherit dev; }) (attrValues config.subvolumes)}
|
||||||
'';
|
'';
|
||||||
description = "Creation script";
|
description = "Creation script";
|
||||||
};
|
};
|
||||||
|
|
@ -479,7 +479,7 @@ rec {
|
||||||
internal = true;
|
internal = true;
|
||||||
readOnly = true;
|
readOnly = true;
|
||||||
type = types.functionTo types.str;
|
type = types.functionTo types.str;
|
||||||
default = dev: ''
|
default = {dev}: ''
|
||||||
MNTPOINT=$(mktemp -d)
|
MNTPOINT=$(mktemp -d)
|
||||||
(
|
(
|
||||||
mount ${dev} "$MNTPOINT" -o subvol=/
|
mount ${dev} "$MNTPOINT" -o subvol=/
|
||||||
|
|
@ -571,7 +571,7 @@ rec {
|
||||||
internal = true;
|
internal = true;
|
||||||
readOnly = true;
|
readOnly = true;
|
||||||
type = types.functionTo types.str;
|
type = types.functionTo types.str;
|
||||||
default = dev: ''
|
default = {dev}: ''
|
||||||
mkfs.${config.format} \
|
mkfs.${config.format} \
|
||||||
${config.extraArgs} \
|
${config.extraArgs} \
|
||||||
${dev}
|
${dev}
|
||||||
|
|
@ -656,9 +656,9 @@ rec {
|
||||||
internal = true;
|
internal = true;
|
||||||
readOnly = true;
|
readOnly = true;
|
||||||
type = types.functionTo types.str;
|
type = types.functionTo types.str;
|
||||||
default = dev: ''
|
default = {dev}: ''
|
||||||
parted -s ${dev} -- mklabel ${config.format}
|
parted -s ${dev} -- mklabel ${config.format}
|
||||||
${concatMapStrings (partition: partition._create dev config.format) config.partitions}
|
${concatMapStrings (partition: partition._create {inherit dev; type = config.format;} ) config.partitions}
|
||||||
'';
|
'';
|
||||||
description = "Creation script";
|
description = "Creation script";
|
||||||
};
|
};
|
||||||
|
|
@ -754,8 +754,8 @@ rec {
|
||||||
_create = mkOption {
|
_create = mkOption {
|
||||||
internal = true;
|
internal = true;
|
||||||
readOnly = true;
|
readOnly = true;
|
||||||
type = types.functionTo (types.functionTo types.str);
|
type = types.functionTo types.str;
|
||||||
default = dev: type: ''
|
default = {dev, type}: ''
|
||||||
${optionalString (type == "gpt") ''
|
${optionalString (type == "gpt") ''
|
||||||
parted -s ${dev} -- mkpart ${config.name} ${diskoLib.maybeStr config.fs-type} ${config.start} ${config.end}
|
parted -s ${dev} -- mkpart ${config.name} ${diskoLib.maybeStr config.fs-type} ${config.start} ${config.end}
|
||||||
''}
|
''}
|
||||||
|
|
@ -772,7 +772,7 @@ rec {
|
||||||
'') config.flags}
|
'') config.flags}
|
||||||
# ensure further operations can detect new partitions
|
# ensure further operations can detect new partitions
|
||||||
udevadm trigger --subsystem-match=block; udevadm settle
|
udevadm trigger --subsystem-match=block; udevadm settle
|
||||||
${optionalString (!isNull config.content) (config.content._create (diskoLib.deviceNumbering dev config.index))}
|
${optionalString (!isNull config.content) (config.content._create {dev = (diskoLib.deviceNumbering dev config.index);})}
|
||||||
'';
|
'';
|
||||||
description = "Creation script";
|
description = "Creation script";
|
||||||
};
|
};
|
||||||
|
|
@ -825,7 +825,7 @@ rec {
|
||||||
internal = true;
|
internal = true;
|
||||||
readOnly = true;
|
readOnly = true;
|
||||||
type = types.functionTo types.str;
|
type = types.functionTo types.str;
|
||||||
default = dev: ''
|
default = {dev}: ''
|
||||||
mkswap ${dev}
|
mkswap ${dev}
|
||||||
'';
|
'';
|
||||||
description = "Creation script";
|
description = "Creation script";
|
||||||
|
|
@ -888,7 +888,7 @@ rec {
|
||||||
internal = true;
|
internal = true;
|
||||||
readOnly = true;
|
readOnly = true;
|
||||||
type = types.functionTo types.str;
|
type = types.functionTo types.str;
|
||||||
default = dev: ''
|
default = {dev}: ''
|
||||||
pvcreate ${dev}
|
pvcreate ${dev}
|
||||||
LVMDEVICES_${config.vg}="''${LVMDEVICES_${config.vg}:-}${dev} "
|
LVMDEVICES_${config.vg}="''${LVMDEVICES_${config.vg}:-}${dev} "
|
||||||
'';
|
'';
|
||||||
|
|
@ -946,10 +946,10 @@ rec {
|
||||||
_create = mkOption {
|
_create = mkOption {
|
||||||
internal = true;
|
internal = true;
|
||||||
readOnly = true;
|
readOnly = true;
|
||||||
type = types.str;
|
type = types.functionTo types.str;
|
||||||
default = ''
|
default = {}: ''
|
||||||
vgcreate ${config.name} $LVMDEVICES_${config.name}
|
vgcreate ${config.name} $LVMDEVICES_${config.name}
|
||||||
${concatMapStrings (lv: lv._create config.name) (attrValues config.lvs)}
|
${concatMapStrings (lv: lv._create {vg = config.name; }) (attrValues config.lvs)}
|
||||||
'';
|
'';
|
||||||
description = "Creation script";
|
description = "Creation script";
|
||||||
};
|
};
|
||||||
|
|
@ -1025,7 +1025,7 @@ rec {
|
||||||
internal = true;
|
internal = true;
|
||||||
readOnly = true;
|
readOnly = true;
|
||||||
type = types.functionTo types.str;
|
type = types.functionTo types.str;
|
||||||
default = vg: ''
|
default = {vg}: ''
|
||||||
lvcreate \
|
lvcreate \
|
||||||
--yes \
|
--yes \
|
||||||
${if hasInfix "%" config.size then "-l" else "-L"} ${config.size} \
|
${if hasInfix "%" config.size then "-l" else "-L"} ${config.size} \
|
||||||
|
|
@ -1033,7 +1033,7 @@ rec {
|
||||||
${optionalString (!isNull config.lvm_type) "--type=${config.lvm_type}"} \
|
${optionalString (!isNull config.lvm_type) "--type=${config.lvm_type}"} \
|
||||||
${config.extraArgs} \
|
${config.extraArgs} \
|
||||||
${vg}
|
${vg}
|
||||||
${optionalString (!isNull config.content) (config.content._create "/dev/${vg}/${config.name}")}
|
${optionalString (!isNull config.content) (config.content._create {dev = "/dev/${vg}/${config.name}";})}
|
||||||
'';
|
'';
|
||||||
description = "Creation script";
|
description = "Creation script";
|
||||||
};
|
};
|
||||||
|
|
@ -1091,7 +1091,7 @@ rec {
|
||||||
internal = true;
|
internal = true;
|
||||||
readOnly = true;
|
readOnly = true;
|
||||||
type = types.functionTo types.str;
|
type = types.functionTo types.str;
|
||||||
default = dev: ''
|
default = {dev}: ''
|
||||||
ZFSDEVICES_${config.pool}="''${ZFSDEVICES_${config.pool}:-}${dev} "
|
ZFSDEVICES_${config.pool}="''${ZFSDEVICES_${config.pool}:-}${dev} "
|
||||||
'';
|
'';
|
||||||
description = "Creation script";
|
description = "Creation script";
|
||||||
|
|
@ -1174,14 +1174,14 @@ rec {
|
||||||
_create = mkOption {
|
_create = mkOption {
|
||||||
internal = true;
|
internal = true;
|
||||||
readOnly = true;
|
readOnly = true;
|
||||||
type = types.str;
|
type = types.functionTo types.str;
|
||||||
default = ''
|
default = {}: ''
|
||||||
zpool create ${config.name} \
|
zpool create ${config.name} \
|
||||||
${config.mode} \
|
${config.mode} \
|
||||||
${concatStringsSep " " (mapAttrsToList (n: v: "-o ${n}=${v}") config.options)} \
|
${concatStringsSep " " (mapAttrsToList (n: v: "-o ${n}=${v}") config.options)} \
|
||||||
${concatStringsSep " " (mapAttrsToList (n: v: "-O ${n}=${v}") config.rootFsOptions)} \
|
${concatStringsSep " " (mapAttrsToList (n: v: "-O ${n}=${v}") config.rootFsOptions)} \
|
||||||
''${ZFSDEVICES_${config.name}}
|
''${ZFSDEVICES_${config.name}}
|
||||||
${concatMapStrings (dataset: dataset._create config.name) (attrValues config.datasets)}
|
${concatMapStrings (dataset: dataset._create {zpool = config.name;}) (attrValues config.datasets)}
|
||||||
'';
|
'';
|
||||||
description = "Creation script";
|
description = "Creation script";
|
||||||
};
|
};
|
||||||
|
|
@ -1290,13 +1290,13 @@ rec {
|
||||||
internal = true;
|
internal = true;
|
||||||
readOnly = true;
|
readOnly = true;
|
||||||
type = types.functionTo types.str;
|
type = types.functionTo types.str;
|
||||||
default = zpool: ''
|
default = {zpool}: ''
|
||||||
zfs create ${zpool}/${config.name} \
|
zfs create ${zpool}/${config.name} \
|
||||||
${concatStringsSep " " (mapAttrsToList (n: v: "-o ${n}=${v}") config.options)} \
|
${concatStringsSep " " (mapAttrsToList (n: v: "-o ${n}=${v}") config.options)} \
|
||||||
${optionalString (config.zfs_type == "volume") "-V ${config.size}"}
|
${optionalString (config.zfs_type == "volume") "-V ${config.size}"}
|
||||||
${optionalString (config.zfs_type == "volume") ''
|
${optionalString (config.zfs_type == "volume") ''
|
||||||
udevadm trigger --subsystem-match=block; udevadm settle
|
udevadm trigger --subsystem-match=block; udevadm settle
|
||||||
${optionalString (!isNull config.content) (config.content._create "/dev/zvol/${zpool}/${config.name}")}
|
${optionalString (!isNull config.content) (config.content._create {dev = "/dev/zvol/${zpool}/${config.name}";})}
|
||||||
''}
|
''}
|
||||||
'';
|
'';
|
||||||
description = "Creation script";
|
description = "Creation script";
|
||||||
|
|
@ -1377,8 +1377,8 @@ rec {
|
||||||
_create = mkOption {
|
_create = mkOption {
|
||||||
internal = true;
|
internal = true;
|
||||||
readOnly = true;
|
readOnly = true;
|
||||||
type = types.str;
|
type = types.functionTo types.str;
|
||||||
default = ''
|
default = {}: ''
|
||||||
echo 'y' | mdadm --create /dev/md/${config.name} \
|
echo 'y' | mdadm --create /dev/md/${config.name} \
|
||||||
--level=${toString config.level} \
|
--level=${toString config.level} \
|
||||||
--raid-devices=''${RAIDDEVICES_N_${config.name}} \
|
--raid-devices=''${RAIDDEVICES_N_${config.name}} \
|
||||||
|
|
@ -1387,7 +1387,7 @@ rec {
|
||||||
--homehost=any \
|
--homehost=any \
|
||||||
''${RAIDDEVICES_${config.name}}
|
''${RAIDDEVICES_${config.name}}
|
||||||
udevadm trigger --subsystem-match=block; udevadm settle
|
udevadm trigger --subsystem-match=block; udevadm settle
|
||||||
${optionalString (!isNull config.content) (config.content._create "/dev/md/${config.name}")}
|
${optionalString (!isNull config.content) (config.content._create {dev = "/dev/md/${config.name}";})}
|
||||||
'';
|
'';
|
||||||
description = "Creation script";
|
description = "Creation script";
|
||||||
};
|
};
|
||||||
|
|
@ -1442,7 +1442,7 @@ rec {
|
||||||
internal = true;
|
internal = true;
|
||||||
readOnly = true;
|
readOnly = true;
|
||||||
type = types.functionTo types.str;
|
type = types.functionTo types.str;
|
||||||
default = dev: ''
|
default = {dev}: ''
|
||||||
RAIDDEVICES_N_${config.name}=$((''${RAIDDEVICES_N_${config.name}:-0}+1))
|
RAIDDEVICES_N_${config.name}=$((''${RAIDDEVICES_N_${config.name}:-0}+1))
|
||||||
RAIDDEVICES_${config.name}="''${RAIDDEVICES_${config.name}:-}${dev} "
|
RAIDDEVICES_${config.name}="''${RAIDDEVICES_${config.name}:-}${dev} "
|
||||||
'';
|
'';
|
||||||
|
|
@ -1506,10 +1506,10 @@ rec {
|
||||||
internal = true;
|
internal = true;
|
||||||
readOnly = true;
|
readOnly = true;
|
||||||
type = types.functionTo types.str;
|
type = types.functionTo types.str;
|
||||||
default = dev: ''
|
default = {dev}: ''
|
||||||
cryptsetup -q luksFormat ${dev} ${diskoLib.maybeStr config.keyFile} ${toString config.extraArgs}
|
cryptsetup -q luksFormat ${dev} ${diskoLib.maybeStr config.keyFile} ${toString config.extraArgs}
|
||||||
cryptsetup luksOpen ${dev} ${config.name} ${optionalString (!isNull config.keyFile) "--key-file ${config.keyFile}"}
|
cryptsetup luksOpen ${dev} ${config.name} ${optionalString (!isNull config.keyFile) "--key-file ${config.keyFile}"}
|
||||||
${optionalString (!isNull config.content) (config.content._create "/dev/mapper/${config.name}")}
|
${optionalString (!isNull config.content) (config.content._create {dev = "/dev/mapper/${config.name}";})}
|
||||||
'';
|
'';
|
||||||
description = "Creation script";
|
description = "Creation script";
|
||||||
};
|
};
|
||||||
|
|
@ -1580,8 +1580,8 @@ rec {
|
||||||
_create = mkOption {
|
_create = mkOption {
|
||||||
internal = true;
|
internal = true;
|
||||||
readOnly = true;
|
readOnly = true;
|
||||||
type = types.str;
|
type = types.functionTo types.str;
|
||||||
default = config.content._create config.device;
|
default = {}: config.content._create {dev = config.device;};
|
||||||
description = "Creation script";
|
description = "Creation script";
|
||||||
};
|
};
|
||||||
_mount = mkOption {
|
_mount = mkOption {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue