add debug output

This commit is contained in:
phaer committed 2023-01-19 13:07:31 +01:00
1 parent c7e5f3caec
commit ad6ab7df50
1 file changed
+17 -14
+17 -14
View File
@@ -137,15 +137,15 @@ rec {
hookMixin = { config, options,... }: { hookMixin = { config, options,... }: {
options = let options = let
mkHook = mkOption { mkHook = default: mkOption {
type = types.str; type = types.str;
default = ""; default = default;
}; };
in { in {
preCreateHook = mkHook; preCreateHook = mkHook "echo 'DEBUG preCreate: ${config.type}'";
postCreateHook = mkHook; postCreateHook = mkHook "echo 'DEBUG postCreate: ${config.type}'";
preMountHook = mkHook; preMountHook = mkHook "echo 'DEBUG preMount: ${config.type}'";
postMountHook = mkHook; postMountHook = mkHook "echo 'DEBUG postMount: ${config.type}'";
}; };
}; };
@@ -155,14 +155,17 @@ rec {
readOnly = true; readOnly = true;
type = types.functionTo types.str; type = types.functionTo types.str;
default = args: default = args:
lib.concatStringsSep "\n" [ let name = "format";
"(" # subshell for namespacing test = lib.optionalString (config ? name) "${config.${name}}";
(diskoLib.defineHookVariables { inherit config options; }) in
config.preCreateHook ''
(attrs.default args) ( # ${config.type} ${concatMapStringsSep " " (n: toString (config.${n} or "")) ["name" "device" "format" "mountpoint"]}
config.postCreateHook ${diskoLib.defineHookVariables { inherit config options; }}
")" ${config.preCreateHook}
]; ${attrs.default args}
${config.postCreateHook}
)
'';
description = "Creation script"; description = "Creation script";
}; };