mirror of
https://github.com/TECHNOFAB11/disko.git
synced 2025-12-11 23:50:05 +01:00
Merge #116
116: types,module,tests: run shellcheck on scripts before running them in NixOS tests r=Mic92 a=lilyinstarlight Co-authored-by: Lily Foster <lily@lily.flowers> Co-authored-by: lassulus <git@lassul.us>
This commit is contained in:
commit
d0d62973a0
17 changed files with 69 additions and 48 deletions
3
BREAKING_CHANGES.md
Normal file
3
BREAKING_CHANGES.md
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
2023-02-14 6d630b8
|
||||||
|
|
||||||
|
btrfs, btrfs_subvol filesystem and lvm_lv extraArgs are now lists
|
||||||
19
default.nix
19
default.nix
|
|
@ -1,5 +1,6 @@
|
||||||
{ lib ? import <nixpkgs/lib>
|
{ lib ? import <nixpkgs/lib>
|
||||||
, rootMountPoint ? "/mnt"
|
, rootMountPoint ? "/mnt"
|
||||||
|
, checked ? false
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
types = import ./types { inherit lib rootMountPoint; };
|
types = import ./types { inherit lib rootMountPoint; };
|
||||||
|
|
@ -18,33 +19,27 @@ in
|
||||||
{
|
{
|
||||||
types = types;
|
types = types;
|
||||||
create = cfg: types.diskoLib.create (eval cfg).config.devices;
|
create = cfg: types.diskoLib.create (eval cfg).config.devices;
|
||||||
createScript = cfg: pkgs: pkgs.writeScript "disko-create" ''
|
createScript = cfg: pkgs: (types.diskoLib.writeCheckedBash { inherit pkgs checked; }) "disko-create" ''
|
||||||
#!/usr/bin/env bash
|
|
||||||
export PATH=${lib.makeBinPath (types.diskoLib.packages (eval cfg).config.devices pkgs)}:$PATH
|
export PATH=${lib.makeBinPath (types.diskoLib.packages (eval cfg).config.devices pkgs)}:$PATH
|
||||||
${types.diskoLib.create (eval cfg).config.devices}
|
${types.diskoLib.create (eval cfg).config.devices}
|
||||||
'';
|
'';
|
||||||
createScriptNoDeps = cfg: pkgs: pkgs.writeScript "disko-create" ''
|
createScriptNoDeps = cfg: pkgs: (types.diskoLib.writeCheckedBash { inherit pkgs checked; noDeps = true; }) "disko-create" ''
|
||||||
#!/usr/bin/env bash
|
|
||||||
${types.diskoLib.create (eval cfg).config.devices}
|
${types.diskoLib.create (eval cfg).config.devices}
|
||||||
'';
|
'';
|
||||||
mount = cfg: types.diskoLib.mount (eval cfg).config.devices;
|
mount = cfg: types.diskoLib.mount (eval cfg).config.devices;
|
||||||
mountScript = cfg: pkgs: pkgs.writeScript "disko-mount" ''
|
mountScript = cfg: pkgs: (types.diskoLib.writeCheckedBash { inherit pkgs checked; }) "disko-mount" ''
|
||||||
#!/usr/bin/env bash
|
|
||||||
export PATH=${lib.makeBinPath (types.diskoLib.packages (eval cfg).config.devices pkgs)}:$PATH
|
export PATH=${lib.makeBinPath (types.diskoLib.packages (eval cfg).config.devices pkgs)}:$PATH
|
||||||
${types.diskoLib.mount (eval cfg).config.devices}
|
${types.diskoLib.mount (eval cfg).config.devices}
|
||||||
'';
|
'';
|
||||||
mountScriptNoDeps = cfg: pkgs: pkgs.writeScript "disko-mount" ''
|
mountScriptNoDeps = cfg: pkgs: (types.diskoLib.writeCheckedBash { inherit pkgs checked; noDeps = true; }) "disko-mount" ''
|
||||||
#!/usr/bin/env bash
|
|
||||||
${types.diskoLib.mount (eval cfg).config.devices}
|
${types.diskoLib.mount (eval cfg).config.devices}
|
||||||
'';
|
'';
|
||||||
zapCreateMount = cfg: types.diskoLib.zapCreateMount (eval cfg).config.devices;
|
zapCreateMount = cfg: types.diskoLib.zapCreateMount (eval cfg).config.devices;
|
||||||
zapCreateMountScript = cfg: pkgs: pkgs.writeScript "disko-zap-create-mount" ''
|
zapCreateMountScript = cfg: pkgs: (types.diskoLib.writeCheckedBash { inherit pkgs checked; }) "disko-zap-create-mount" ''
|
||||||
#!/usr/bin/env bash
|
|
||||||
export PATH=${lib.makeBinPath (types.diskoLib.packages (eval cfg).config.devices pkgs)}:$PATH
|
export PATH=${lib.makeBinPath (types.diskoLib.packages (eval cfg).config.devices pkgs)}:$PATH
|
||||||
${types.diskoLib.zapCreateMount (eval cfg).config.devices}
|
${types.diskoLib.zapCreateMount (eval cfg).config.devices}
|
||||||
'';
|
'';
|
||||||
zapCreateMountScriptNoDeps = cfg: pkgs: pkgs.writeScript "disko-zap-create-mount" ''
|
zapCreateMountScriptNoDeps = cfg: pkgs: (types.diskoLib.writeCheckedBash { inherit pkgs checked; noDeps = true; }) "disko-zap-create-mount" ''
|
||||||
#!/usr/bin/env bash
|
|
||||||
${types.diskoLib.zapCreateMount (eval cfg).config.devices}
|
${types.diskoLib.zapCreateMount (eval cfg).config.devices}
|
||||||
'';
|
'';
|
||||||
config = cfg: { imports = types.diskoLib.config (eval cfg).config.devices; };
|
config = cfg: { imports = types.diskoLib.config (eval cfg).config.devices; };
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
end = "100%";
|
end = "100%";
|
||||||
content = {
|
content = {
|
||||||
type = "btrfs";
|
type = "btrfs";
|
||||||
extraArgs = "-f"; # Override existing partition
|
extraArgs = [ "-f" ]; # Override existing partition
|
||||||
subvolumes = {
|
subvolumes = {
|
||||||
# Subvolume name is different from mountpoint
|
# Subvolume name is different from mountpoint
|
||||||
"/rootfs" = {
|
"/rootfs" = {
|
||||||
|
|
|
||||||
17
module.nix
17
module.nix
|
|
@ -5,6 +5,7 @@ let
|
||||||
rootMountPoint = config.disko.rootMountPoint;
|
rootMountPoint = config.disko.rootMountPoint;
|
||||||
};
|
};
|
||||||
cfg = config.disko;
|
cfg = config.disko;
|
||||||
|
checked = cfg.checkScripts;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.disko = {
|
options.disko = {
|
||||||
|
|
@ -27,26 +28,32 @@ in
|
||||||
type = lib.types.bool;
|
type = lib.types.bool;
|
||||||
default = true;
|
default = true;
|
||||||
};
|
};
|
||||||
|
checkScripts = lib.mkOption {
|
||||||
|
description = ''
|
||||||
|
Whether to run shellcheck on script outputs
|
||||||
|
'';
|
||||||
|
type = lib.types.bool;
|
||||||
|
default = false;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
config = lib.mkIf (cfg.devices.disk != { }) {
|
config = lib.mkIf (cfg.devices.disk != { }) {
|
||||||
system.build.formatScript = pkgs.writers.writeBash "disko-create" ''
|
system.build.formatScript = (types.diskoLib.writeCheckedBash { inherit pkgs checked; }) "disko-create" ''
|
||||||
export PATH=${lib.makeBinPath (types.diskoLib.packages cfg.devices pkgs)}:$PATH
|
export PATH=${lib.makeBinPath (types.diskoLib.packages cfg.devices pkgs)}:$PATH
|
||||||
${types.diskoLib.create cfg.devices}
|
${types.diskoLib.create cfg.devices}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
system.build.mountScript = pkgs.writers.writeBash "disko-mount" ''
|
system.build.mountScript = (types.diskoLib.writeCheckedBash { inherit pkgs checked; }) "disko-mount" ''
|
||||||
export PATH=${lib.makeBinPath (types.diskoLib.packages cfg.devices pkgs)}:$PATH
|
export PATH=${lib.makeBinPath (types.diskoLib.packages cfg.devices pkgs)}:$PATH
|
||||||
${types.diskoLib.mount cfg.devices}
|
${types.diskoLib.mount cfg.devices}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
system.build.disko = pkgs.writers.writeBash "disko" ''
|
system.build.disko = (types.diskoLib.writeCheckedBash { inherit pkgs checked; }) "disko" ''
|
||||||
export PATH=${lib.makeBinPath (types.diskoLib.packages cfg.devices pkgs)}:$PATH
|
export PATH=${lib.makeBinPath (types.diskoLib.packages cfg.devices pkgs)}:$PATH
|
||||||
${types.diskoLib.zapCreateMount cfg.devices}
|
${types.diskoLib.zapCreateMount cfg.devices}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
# This is useful to skip copying executables uploading a script to an in-memory installer
|
# This is useful to skip copying executables uploading a script to an in-memory installer
|
||||||
system.build.diskoNoDeps = pkgs.writeScript "disko" ''
|
system.build.diskoNoDeps = (types.diskoLib.writeCheckedBash { inherit pkgs checked; noDeps = true; }) "disko" ''
|
||||||
#!/usr/bin/env bash
|
|
||||||
${types.diskoLib.zapCreateMount cfg.devices}
|
${types.diskoLib.zapCreateMount cfg.devices}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,8 @@ let
|
||||||
disko-config = import configFile;
|
disko-config = import configFile;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
"${name}-tsp-create" = pkgs.writeScript "create" ((pkgs.callPackage ../. { }).create disko-config);
|
"${name}-tsp-create" = (pkgs.callPackage ../. { checked = true; }).createScript disko-config pkgs;
|
||||||
"${name}-tsp-mount" = pkgs.writeScript "mount" ((pkgs.callPackage ../. { }).mount disko-config);
|
"${name}-tsp-mount" = (pkgs.callPackage ../. { checked = true; }).mountScript disko-config pkgs;
|
||||||
};
|
};
|
||||||
|
|
||||||
allTestFilenames =
|
allTestFilenames =
|
||||||
|
|
|
||||||
|
|
@ -24,10 +24,11 @@
|
||||||
inherit (pkgs) system;
|
inherit (pkgs) system;
|
||||||
};
|
};
|
||||||
disks = [ "/dev/vda" "/dev/vdb" "/dev/vdc" "/dev/vdd" "/dev/vde" "/dev/vdf" ];
|
disks = [ "/dev/vda" "/dev/vdb" "/dev/vdc" "/dev/vdd" "/dev/vde" "/dev/vdf" ];
|
||||||
tsp-create = pkgs.writeScript "create" ((pkgs.callPackage ../. { }).create (import disko-config { disks = builtins.tail disks; inherit lib; }));
|
tsp-generator = pkgs.callPackage ../. { checked = true; };
|
||||||
tsp-mount = pkgs.writeScript "mount" ((pkgs.callPackage ../. { }).mount (import disko-config { disks = builtins.tail disks; inherit lib; }));
|
tsp-create = (tsp-generator.createScript (import disko-config { disks = builtins.tail disks; inherit lib; })) pkgs;
|
||||||
tsp-config = (pkgs.callPackage ../. { }).config (import disko-config { inherit disks; inherit lib; });
|
tsp-mount = (tsp-generator.mountScript (import disko-config { disks = builtins.tail disks; inherit lib; })) pkgs;
|
||||||
tsp-disko = pkgs.writeScript "disko" ((pkgs.callPackage ../. { }).zapCreateMount (import disko-config { disks = builtins.tail disks; inherit lib; }));
|
tsp-disko = (tsp-generator.zapCreateMountScript (import disko-config { disks = builtins.tail disks; inherit lib; })) pkgs;
|
||||||
|
tsp-config = tsp-generator.config (import disko-config { inherit disks; inherit lib; });
|
||||||
num-disks = builtins.length (lib.attrNames (import disko-config { inherit lib; }).disk);
|
num-disks = builtins.length (lib.attrNames (import disko-config { inherit lib; }).disk);
|
||||||
installed-system = { modulesPath, ... }: {
|
installed-system = { modulesPath, ... }: {
|
||||||
imports = [
|
imports = [
|
||||||
|
|
@ -78,14 +79,15 @@
|
||||||
imports = [ ../module.nix ];
|
imports = [ ../module.nix ];
|
||||||
disko = {
|
disko = {
|
||||||
enableConfig = false;
|
enableConfig = false;
|
||||||
|
checkScripts = true;
|
||||||
devices = import disko-config { disks = builtins.tail disks; inherit lib; };
|
devices = import disko-config { disks = builtins.tail disks; inherit lib; };
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
(lib.optionalAttrs (testMode == "cli") {
|
(lib.optionalAttrs (testMode == "cli") {
|
||||||
imports = [ (modulesPath + "/installer/cd-dvd/channel.nix") ];
|
imports = [ (modulesPath + "/installer/cd-dvd/channel.nix") ];
|
||||||
system.extraDependencies = [
|
system.extraDependencies = [
|
||||||
((pkgs.callPackage ../. { }).createScript (import disko-config { disks = builtins.tail disks; inherit lib; }) pkgs)
|
((pkgs.callPackage ../. { checked = true; }).createScript (import disko-config { disks = builtins.tail disks; inherit lib; }) pkgs)
|
||||||
((pkgs.callPackage ../. { }).mountScript (import disko-config { disks = builtins.tail disks; inherit lib; }) pkgs)
|
((pkgs.callPackage ../. { checked = true; }).mountScript (import disko-config { disks = builtins.tail disks; inherit lib; }) pkgs)
|
||||||
];
|
];
|
||||||
})
|
})
|
||||||
(modulesPath + "/profiles/base.nix")
|
(modulesPath + "/profiles/base.nix")
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,9 @@
|
||||||
description = "Type";
|
description = "Type";
|
||||||
};
|
};
|
||||||
extraArgs = lib.mkOption {
|
extraArgs = lib.mkOption {
|
||||||
type = lib.types.str;
|
type = lib.types.listOf lib.types.str;
|
||||||
default = "";
|
default = [ ];
|
||||||
description = "Arguments to pass to BTRFS";
|
description = "Extra arguments";
|
||||||
};
|
};
|
||||||
mountOptions = lib.mkOption {
|
mountOptions = lib.mkOption {
|
||||||
type = lib.types.listOf lib.types.str;
|
type = lib.types.listOf lib.types.str;
|
||||||
|
|
@ -37,7 +37,7 @@
|
||||||
_create = diskoLib.mkCreateOption {
|
_create = diskoLib.mkCreateOption {
|
||||||
inherit config options;
|
inherit config options;
|
||||||
default = { dev }: ''
|
default = { dev }: ''
|
||||||
mkfs.btrfs ${dev} ${config.extraArgs}
|
mkfs.btrfs ${dev} ${toString config.extraArgs}
|
||||||
${lib.concatMapStrings (subvol: subvol._create { inherit dev; }) (lib.attrValues config.subvolumes)}
|
${lib.concatMapStrings (subvol: subvol._create { inherit dev; }) (lib.attrValues config.subvolumes)}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,9 @@
|
||||||
description = "Type";
|
description = "Type";
|
||||||
};
|
};
|
||||||
extraArgs = lib.mkOption {
|
extraArgs = lib.mkOption {
|
||||||
type = lib.types.str;
|
type = lib.types.listOf lib.types.str;
|
||||||
default = "";
|
default = [ ];
|
||||||
description = "Extra arguments to pass";
|
description = "Extra arguments";
|
||||||
};
|
};
|
||||||
mountOptions = lib.mkOption {
|
mountOptions = lib.mkOption {
|
||||||
type = lib.types.listOf lib.types.str;
|
type = lib.types.listOf lib.types.str;
|
||||||
|
|
@ -41,7 +41,7 @@
|
||||||
(
|
(
|
||||||
mount ${dev} "$MNTPOINT" -o subvol=/
|
mount ${dev} "$MNTPOINT" -o subvol=/
|
||||||
trap 'umount $MNTPOINT; rm -rf $MNTPOINT' EXIT
|
trap 'umount $MNTPOINT; rm -rf $MNTPOINT' EXIT
|
||||||
btrfs subvolume create "$MNTPOINT"/${config.name} ${config.extraArgs}
|
btrfs subvolume create "$MNTPOINT"/${config.name} ${toString config.extraArgs}
|
||||||
)
|
)
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -193,6 +193,15 @@ rec {
|
||||||
description = "Mount script";
|
description = "Mount script";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Writer for optionally checking bash scripts before writing them to the store
|
||||||
|
|
||||||
|
writeCheckedBash :: AttrSet -> str -> str -> derivation
|
||||||
|
*/
|
||||||
|
writeCheckedBash = { pkgs, checked ? false, noDeps ? false }: pkgs.writers.makeScriptWriter {
|
||||||
|
interpreter = if noDeps then "/usr/bin/env bash" else "${pkgs.bash}/bin/bash";
|
||||||
|
check = lib.optionalString checked "${pkgs.shellcheck}/bin/shellcheck -e SC2034";
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/* Takes a disko device specification, returns an attrset with metadata
|
/* Takes a disko device specification, returns an attrset with metadata
|
||||||
|
|
||||||
|
|
@ -243,6 +252,7 @@ rec {
|
||||||
set -efux
|
set -efux
|
||||||
umount -Rv "${rootMountPoint}" || :
|
umount -Rv "${rootMountPoint}" || :
|
||||||
|
|
||||||
|
# shellcheck disable=SC2043
|
||||||
for dev in ${toString (lib.catAttrs "device" (lib.attrValues devices.disk))}; do
|
for dev in ${toString (lib.catAttrs "device" (lib.attrValues devices.disk))}; do
|
||||||
${../disk-deactivate}/disk-deactivate "$dev" | bash -x
|
${../disk-deactivate}/disk-deactivate "$dev" | bash -x
|
||||||
done
|
done
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,9 @@
|
||||||
description = "Type";
|
description = "Type";
|
||||||
};
|
};
|
||||||
extraArgs = lib.mkOption {
|
extraArgs = lib.mkOption {
|
||||||
type = lib.types.str;
|
type = lib.types.listOf lib.types.str;
|
||||||
default = "";
|
default = [ ];
|
||||||
description = "Arguments to pass";
|
description = "Extra arguments";
|
||||||
};
|
};
|
||||||
mountOptions = lib.mkOption {
|
mountOptions = lib.mkOption {
|
||||||
type = lib.types.listOf lib.types.str;
|
type = lib.types.listOf lib.types.str;
|
||||||
|
|
@ -35,7 +35,7 @@
|
||||||
inherit config options;
|
inherit config options;
|
||||||
default = { dev }: ''
|
default = { dev }: ''
|
||||||
mkfs.${config.format} \
|
mkfs.${config.format} \
|
||||||
${config.extraArgs} \
|
${toString config.extraArgs} \
|
||||||
${dev}
|
${dev}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,8 @@
|
||||||
description = "LVM type";
|
description = "LVM type";
|
||||||
};
|
};
|
||||||
extraArgs = lib.mkOption {
|
extraArgs = lib.mkOption {
|
||||||
type = lib.types.str;
|
type = lib.types.listOf lib.types.str;
|
||||||
default = "";
|
default = [ ];
|
||||||
description = "Extra arguments";
|
description = "Extra arguments";
|
||||||
};
|
};
|
||||||
content = diskoLib.partitionType;
|
content = diskoLib.partitionType;
|
||||||
|
|
@ -43,7 +43,7 @@
|
||||||
${if lib.hasInfix "%" config.size then "-l" else "-L"} ${config.size} \
|
${if lib.hasInfix "%" config.size then "-l" else "-L"} ${config.size} \
|
||||||
-n ${config.name} \
|
-n ${config.name} \
|
||||||
${lib.optionalString (config.lvm_type != null) "--type=${config.lvm_type}"} \
|
${lib.optionalString (config.lvm_type != null) "--type=${config.lvm_type}"} \
|
||||||
${config.extraArgs} \
|
${toString config.extraArgs} \
|
||||||
${vg}
|
${vg}
|
||||||
${lib.optionalString (config.content != null) (config.content._create {dev = "/dev/${vg}/${config.name}";})}
|
${lib.optionalString (config.content != null) (config.content._create {dev = "/dev/${vg}/${config.name}";})}
|
||||||
'';
|
'';
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
inherit config options;
|
inherit config options;
|
||||||
default = { dev }: ''
|
default = { dev }: ''
|
||||||
pvcreate ${dev}
|
pvcreate ${dev}
|
||||||
echo "${dev}" >> $disko_devices_dir/lvm_${config.vg}
|
echo "${dev}" >> "$disko_devices_dir"/lvm_${config.vg}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
_mount = diskoLib.mkMountOption {
|
_mount = diskoLib.mkMountOption {
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,9 @@
|
||||||
_create = diskoLib.mkCreateOption {
|
_create = diskoLib.mkCreateOption {
|
||||||
inherit config options;
|
inherit config options;
|
||||||
default = _: ''
|
default = _: ''
|
||||||
vgcreate ${config.name} $(tr '\n' ' ' < $disko_devices_dir/lvm_${config.name})
|
readarray -t lvm_devices < <(cat "$disko_devices_dir"/lvm_${config.name})
|
||||||
|
vgcreate ${config.name} \
|
||||||
|
"''${lvm_devices[@]}"
|
||||||
${lib.concatMapStrings (lv: lv._create {vg = config.name; }) (lib.attrValues config.lvs)}
|
${lib.concatMapStrings (lv: lv._create {vg = config.name; }) (lib.attrValues config.lvs)}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -34,13 +34,14 @@
|
||||||
_create = diskoLib.mkCreateOption {
|
_create = diskoLib.mkCreateOption {
|
||||||
inherit config options;
|
inherit config options;
|
||||||
default = _: ''
|
default = _: ''
|
||||||
|
readarray -t disk_devices < <(cat "$disko_devices_dir"/raid_${config.name})
|
||||||
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=$(wc -l $disko_devices_dir/raid_${config.name} | cut -f 1 -d " ") \
|
--raid-devices="$(wc -l "$disko_devices_dir"/raid_${config.name} | cut -f 1 -d " ")" \
|
||||||
--metadata=${config.metadata} \
|
--metadata=${config.metadata} \
|
||||||
--force \
|
--force \
|
||||||
--homehost=any \
|
--homehost=any \
|
||||||
$(tr '\n' ' ' < $disko_devices_dir/raid_${config.name})
|
"''${disk_devices[@]}"
|
||||||
udevadm trigger --subsystem-match=block; udevadm settle
|
udevadm trigger --subsystem-match=block; udevadm settle
|
||||||
${lib.optionalString (config.content != null) (config.content._create {dev = "/dev/md/${config.name}";})}
|
${lib.optionalString (config.content != null) (config.content._create {dev = "/dev/md/${config.name}";})}
|
||||||
'';
|
'';
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
_create = diskoLib.mkCreateOption {
|
_create = diskoLib.mkCreateOption {
|
||||||
inherit config options;
|
inherit config options;
|
||||||
default = { dev }: ''
|
default = { dev }: ''
|
||||||
echo "${dev}" >> $disko_devices_dir/raid_${config.name}
|
echo "${dev}" >> "$disko_devices_dir"/raid_${config.name}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
_mount = diskoLib.mkMountOption {
|
_mount = diskoLib.mkMountOption {
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
_create = diskoLib.mkCreateOption {
|
_create = diskoLib.mkCreateOption {
|
||||||
inherit config options;
|
inherit config options;
|
||||||
default = { dev }: ''
|
default = { dev }: ''
|
||||||
echo "${dev}" >> $disko_devices_dir/zfs_${config.pool}
|
echo "${dev}" >> "$disko_devices_dir"/zfs_${config.pool}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
_mount = diskoLib.mkMountOption {
|
_mount = diskoLib.mkMountOption {
|
||||||
|
|
|
||||||
|
|
@ -52,11 +52,12 @@
|
||||||
_create = diskoLib.mkCreateOption {
|
_create = diskoLib.mkCreateOption {
|
||||||
inherit config options;
|
inherit config options;
|
||||||
default = _: ''
|
default = _: ''
|
||||||
|
readarray -t zfs_devices < <(cat "$disko_devices_dir"/zfs_${config.name})
|
||||||
zpool create ${config.name} \
|
zpool create ${config.name} \
|
||||||
${config.mode} \
|
${config.mode} \
|
||||||
${lib.concatStringsSep " " (lib.mapAttrsToList (n: v: "-o ${n}=${v}") config.options)} \
|
${lib.concatStringsSep " " (lib.mapAttrsToList (n: v: "-o ${n}=${v}") config.options)} \
|
||||||
${lib.concatStringsSep " " (lib.mapAttrsToList (n: v: "-O ${n}=${v}") config.rootFsOptions)} \
|
${lib.concatStringsSep " " (lib.mapAttrsToList (n: v: "-O ${n}=${v}") config.rootFsOptions)} \
|
||||||
$(tr '\n' ' ' < $disko_devices_dir/zfs_${config.name})
|
"''${zfs_devices[@]}"
|
||||||
${lib.concatMapStrings (dataset: dataset._create {zpool = config.name;}) (lib.attrValues config.datasets)}
|
${lib.concatMapStrings (dataset: dataset._create {zpool = config.name;}) (lib.attrValues config.datasets)}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue