vars: rename createFile -> persist

This commit is contained in:
DavHau
2025-01-08 11:55:12 +07:00
parent f743ec2616
commit bbe37a998f
6 changed files with 12 additions and 9 deletions

View File

@@ -52,7 +52,7 @@ let
migrateFact = "${secret_id opt}"; migrateFact = "${secret_id opt}";
prompts.${secret_id opt} = { prompts.${secret_id opt} = {
type = "hidden"; type = "hidden";
createFile = true; persist = true;
}; };
}; };
}; };

View File

@@ -14,9 +14,9 @@ let
name = "iwd.${name}"; name = "iwd.${name}";
value = { value = {
prompts.ssid.type = "line"; prompts.ssid.type = "line";
prompts.ssid.createFile = true; prompts.ssid.persist = true;
prompts.password.type = "hidden"; prompts.password.type = "hidden";
prompts.password.createFile = true; prompts.password.persist = true;
share = true; share = true;
}; };
}; };

View File

@@ -21,7 +21,7 @@ let
promptsToFilesScript = concatMapStrings promptToFile; promptsToFilesScript = concatMapStrings promptToFile;
filePromptNames = attrNames (filterAttrs (_name: prompt: prompt.createFile) config.prompts); filePromptNames = attrNames (filterAttrs (_name: prompt: prompt.persist) config.prompts);
in in
{ {
finalScript = mkOptionDefault ( finalScript = mkOptionDefault (

View File

@@ -253,6 +253,9 @@ in
default = { }; default = { };
type = attrsOf ( type = attrsOf (
submodule (prompt: { submodule (prompt: {
imports = [
(lib.mkRenamedOptionModule [ "createFile" ] [ "persist" ])
];
options = { options = {
name = lib.mkOption { name = lib.mkOption {
description = '' description = ''
@@ -263,7 +266,7 @@ in
default = prompt.config._module.args.name; default = prompt.config._module.args.name;
defaultText = "Name of the prompt"; defaultText = "Name of the prompt";
}; };
createFile = lib.mkOption { persist = lib.mkOption {
description = '' description = ''
Whether the prompted value should be stored in a file with the same name as the prompt. Whether the prompted value should be stored in a file with the same name as the prompt.

View File

@@ -32,7 +32,7 @@ class Prompt:
name=data["name"], name=data["name"],
description=data["description"], description=data["description"],
prompt_type=PromptType(data["type"]), prompt_type=PromptType(data["type"]),
create_file=data["createFile"], create_file=data.get("persist", data["createFile"]),
previous_value=data.get("previousValue"), previous_value=data.get("previousValue"),
) )

View File

@@ -477,14 +477,14 @@ def test_prompt(
my_generator["files"]["multiline_value"]["secret"] = False my_generator["files"]["multiline_value"]["secret"] = False
my_generator["prompts"]["prompt1"]["description"] = "dream2nix" my_generator["prompts"]["prompt1"]["description"] = "dream2nix"
my_generator["prompts"]["prompt1"]["createFile"] = False my_generator["prompts"]["prompt1"]["persist"] = False
my_generator["prompts"]["prompt1"]["type"] = "line" my_generator["prompts"]["prompt1"]["type"] = "line"
my_generator["prompts"]["prompt2"]["description"] = "dream2nix" my_generator["prompts"]["prompt2"]["description"] = "dream2nix"
my_generator["prompts"]["prompt2"]["createFile"] = False my_generator["prompts"]["prompt2"]["persist"] = False
my_generator["prompts"]["prompt2"]["type"] = "line" my_generator["prompts"]["prompt2"]["type"] = "line"
my_generator["prompts"]["prompt_create_file"]["createFile"] = True my_generator["prompts"]["prompt_create_file"]["persist"] = True
my_generator["script"] = ( my_generator["script"] = (
"cat $prompts/prompt1 > $out/line_value; cat $prompts/prompt2 > $out/multiline_value" "cat $prompts/prompt1 > $out/line_value; cat $prompts/prompt2 > $out/multiline_value"