Store device scripts in scripts
option
This commit is contained in:
parent
8c6bf72323
commit
ed0ccb340f
1 changed files with 56 additions and 46 deletions
|
@ -61,9 +61,16 @@ let
|
||||||
default = { };
|
default = { };
|
||||||
};
|
};
|
||||||
|
|
||||||
script = mkOption {
|
scripts = {
|
||||||
|
init = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
description = "The script for formatting the disk.";
|
description = "A script for loading the device path into the device variable";
|
||||||
|
};
|
||||||
|
|
||||||
|
partition = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
description = "A script for partitioning and formatting the device.";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -172,7 +179,8 @@ let
|
||||||
id = "disk-${name}";
|
id = "disk-${name}";
|
||||||
deviceVariable = deviceVar;
|
deviceVariable = deviceVar;
|
||||||
|
|
||||||
deviceScript =
|
scripts = {
|
||||||
|
init =
|
||||||
if config.path == null then ''
|
if config.path == null then ''
|
||||||
${deviceSelector}
|
${deviceSelector}
|
||||||
'' else ''
|
'' else ''
|
||||||
|
@ -191,7 +199,7 @@ let
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
|
|
||||||
script = lib.mkDefault ''
|
partition = lib.mkDefault ''
|
||||||
function partition() {
|
function partition() {
|
||||||
${if (!config.wipe) then cleanup else ""}
|
${if (!config.wipe) then cleanup else ""}
|
||||||
${probeScript}
|
${probeScript}
|
||||||
|
@ -202,6 +210,7 @@ let
|
||||||
partition
|
partition
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -332,8 +341,8 @@ in
|
||||||
partitions = (builtins.concatMap (_: (builtins.attrValues _.partitions)) disks);
|
partitions = (builtins.concatMap (_: (builtins.attrValues _.partitions)) disks);
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
init = lib.strings.concatLines (builtins.map (_: _.deviceScript) disks);
|
init = lib.strings.concatLines (builtins.map (_: _.scripts.init) disks);
|
||||||
partition = lib.strings.concatLines (builtins.map (_: _.script) disks);
|
partition = lib.strings.concatLines (builtins.map (_: _.scripts.partition) disks);
|
||||||
mount = lib.strings.concatLines (
|
mount = lib.strings.concatLines (
|
||||||
(builtins.concatMap
|
(builtins.concatMap
|
||||||
(
|
(
|
||||||
|
@ -360,7 +369,8 @@ in
|
||||||
sudo swapon ${partPath _}
|
sudo swapon ${partPath _}
|
||||||
''
|
''
|
||||||
)
|
)
|
||||||
(builtins.filter (_: _.useSwap) partitions)));
|
(builtins.filter (_: _.useSwap) partitions))
|
||||||
|
);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue