mirror of
https://github.com/nix-community/disko.git
synced 2024-09-17 09:37:17 +03:00
run hooks, fix defineHookVariables
This commit is contained in:
parent
313d0e2315
commit
0e658ad7f7
26
types.nix
26
types.nix
@ -120,12 +120,20 @@ rec {
|
|||||||
subset of config variables as a shell script snippet.
|
subset of config variables as a shell script snippet.
|
||||||
*/
|
*/
|
||||||
defineHookVariables = {config, options}:
|
defineHookVariables = {config, options}:
|
||||||
|
let
|
||||||
|
sanitizeName = lib.replaceStrings ["-"] ["_"];
|
||||||
|
isAttrsOfSubmodule = o: o.type.name == "attrsOf" && o.type.nestedTypes.elemType.name == "submodule";
|
||||||
|
isSerializable = n: o: !(
|
||||||
|
lib.hasPrefix "_" n
|
||||||
|
|| lib.hasSuffix "Hook" n
|
||||||
|
|| isAttrsOfSubmodule o
|
||||||
|
# TODO don't hardcode diskoLib.subType options.
|
||||||
|
|| n == "content" || n == "partitions");
|
||||||
|
in
|
||||||
lib.toShellVars
|
lib.toShellVars
|
||||||
(lib.mapAttrs
|
(lib.mapAttrs'
|
||||||
(n: o: o.value)
|
(n: o: lib.nameValuePair (sanitizeName n) o.value)
|
||||||
(lib.filterAttrs diskoLib.isSerializable options));
|
(lib.filterAttrs isSerializable options));
|
||||||
isSerializable = n: o: !(lib.hasPrefix "_" n || lib.hasSuffix "Hook" n || diskoLib.isAttrsOfSubmodule o);
|
|
||||||
isAttrsOfSubmodule = o: o.type.name == "attrsOf" && o.type.nestedTypes.elemType.name == "submodule";
|
|
||||||
|
|
||||||
hookMixin = { config, options,... }: {
|
hookMixin = { config, options,... }: {
|
||||||
options = let
|
options = let
|
||||||
@ -146,7 +154,13 @@ rec {
|
|||||||
internal = true;
|
internal = true;
|
||||||
readOnly = true;
|
readOnly = true;
|
||||||
type = types.functionTo types.str;
|
type = types.functionTo types.str;
|
||||||
default = {}: "";
|
default = args:
|
||||||
|
lib.concatStrings [
|
||||||
|
(diskoLib.defineHookVariables { inherit config options; })
|
||||||
|
config.preCreateHook
|
||||||
|
(default args)
|
||||||
|
config.postCreateHook
|
||||||
|
];
|
||||||
description = "Creation script";
|
description = "Creation script";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user