Store device scripts in scripts
option
This commit is contained in:
parent
68e1990c87
commit
7b5564a632
1 changed files with 56 additions and 46 deletions
|
@ -61,9 +61,16 @@ let
|
|||
default = { };
|
||||
};
|
||||
|
||||
script = mkOption {
|
||||
scripts = {
|
||||
init = mkOption {
|
||||
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}";
|
||||
deviceVariable = deviceVar;
|
||||
|
||||
deviceScript =
|
||||
scripts = {
|
||||
init =
|
||||
if config.path == null then ''
|
||||
${deviceSelector}
|
||||
'' else ''
|
||||
|
@ -191,7 +199,7 @@ let
|
|||
fi
|
||||
'';
|
||||
|
||||
script = lib.mkDefault ''
|
||||
partition = lib.mkDefault ''
|
||||
function partition() {
|
||||
${if (!config.wipe) then cleanup else ""}
|
||||
${probeScript}
|
||||
|
@ -202,6 +210,7 @@ let
|
|||
partition
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -332,8 +341,8 @@ in
|
|||
partitions = (builtins.concatMap (_: (builtins.attrValues _.partitions)) disks);
|
||||
in
|
||||
{
|
||||
init = lib.strings.concatLines (builtins.map (_: _.deviceScript) disks);
|
||||
partition = lib.strings.concatLines (builtins.map (_: _.script) disks);
|
||||
init = lib.strings.concatLines (builtins.map (_: _.scripts.init) disks);
|
||||
partition = lib.strings.concatLines (builtins.map (_: _.scripts.partition) disks);
|
||||
mount = lib.strings.concatLines (
|
||||
(builtins.concatMap
|
||||
(
|
||||
|
@ -360,7 +369,8 @@ in
|
|||
sudo swapon ${partPath _}
|
||||
''
|
||||
)
|
||||
(builtins.filter (_: _.useSwap) partitions)));
|
||||
(builtins.filter (_: _.useSwap) partitions))
|
||||
);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue