From ad6ab7df50a162f2183f5752146d051b5ab05e04 Mon Sep 17 00:00:00 2001 From: phaer Date: Sat, 14 Jan 2023 17:24:49 +0100 Subject: [PATCH] add debug output --- types.nix | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/types.nix b/types.nix index a7f61bd..1476ca7 100644 --- a/types.nix +++ b/types.nix @@ -137,15 +137,15 @@ rec { hookMixin = { config, options,... }: { options = let - mkHook = mkOption { + mkHook = default: mkOption { type = types.str; - default = ""; + default = default; }; in { - preCreateHook = mkHook; - postCreateHook = mkHook; - preMountHook = mkHook; - postMountHook = mkHook; + preCreateHook = mkHook "echo 'DEBUG preCreate: ${config.type}'"; + postCreateHook = mkHook "echo 'DEBUG postCreate: ${config.type}'"; + preMountHook = mkHook "echo 'DEBUG preMount: ${config.type}'"; + postMountHook = mkHook "echo 'DEBUG postMount: ${config.type}'"; }; }; @@ -155,14 +155,17 @@ rec { readOnly = true; type = types.functionTo types.str; default = args: - lib.concatStringsSep "\n" [ - "(" # subshell for namespacing - (diskoLib.defineHookVariables { inherit config options; }) - config.preCreateHook - (attrs.default args) - config.postCreateHook - ")" - ]; + let name = "format"; + test = lib.optionalString (config ? name) "${config.${name}}"; + in + '' + ( # ${config.type} ${concatMapStringsSep " " (n: toString (config.${n} or "")) ["name" "device" "format" "mountpoint"]} + ${diskoLib.defineHookVariables { inherit config options; }} + ${config.preCreateHook} + ${attrs.default args} + ${config.postCreateHook} + ) + ''; description = "Creation script"; };