vars: cleanup nix interface

This commit is contained in:
DavHau
2025-07-14 18:20:04 +07:00
parent 6ccee60e39
commit 6fe2b195a9

View File

@@ -22,6 +22,7 @@ let
package package
path path
str str
strMatching
submoduleWith submoduleWith
; ;
# the original types.submodule has strange behavior # the original types.submodule has strange behavior
@@ -47,7 +48,7 @@ in
imports = [ ./generator.nix ]; imports = [ ./generator.nix ];
options = { options = {
name = lib.mkOption { name = lib.mkOption {
type = lib.types.str; type = str;
description = '' description = ''
The name of the generator. The name of the generator.
This name will be used to refer to the generator in other generators. This name will be used to refer to the generator in other generators.
@@ -153,7 +154,7 @@ in
options = options =
{ {
name = lib.mkOption { name = lib.mkOption {
type = lib.types.str; type = str;
description = '' description = ''
name of the public fact name of the public fact
''; '';
@@ -162,7 +163,7 @@ in
defaultText = "Name of the file"; defaultText = "Name of the file";
}; };
generatorName = lib.mkOption { generatorName = lib.mkOption {
type = lib.types.str; type = str;
description = '' description = ''
name of the generator name of the generator
''; '';
@@ -171,7 +172,7 @@ in
defaultText = "Name of the generator that generates this file"; defaultText = "Name of the generator that generates this file";
}; };
share = lib.mkOption { share = lib.mkOption {
type = lib.types.bool; type = bool;
description = '' description = ''
Whether the generated vars should be shared between machines. Whether the generated vars should be shared between machines.
Shared vars are only generated once, when the first machine using it is deployed. Shared vars are only generated once, when the first machine using it is deployed.
@@ -233,7 +234,7 @@ in
By setting this to `user`, the secret will be deployed prior to users and groups are created, allowing By setting this to `user`, the secret will be deployed prior to users and groups are created, allowing
users' passwords to be managed by vars. The secret will be stored in `/run/secrets-for-users` and `owner` and `group` must be `root`. users' passwords to be managed by vars. The secret will be stored in `/run/secrets-for-users` and `owner` and `group` must be `root`.
''; '';
type = lib.types.enum [ type = enum [
"partitioning" "partitioning"
"activation" "activation"
"users" "users"
@@ -251,7 +252,7 @@ in
defaultText = lib.literalExpression ''if _class == "darwin" then "wheel" else "root"''; defaultText = lib.literalExpression ''if _class == "darwin" then "wheel" else "root"'';
}; };
mode = lib.mkOption { mode = lib.mkOption {
type = lib.types.strMatching "^[0-7]{4}$"; type = strMatching "^[0-7]{4}$";
description = "The unix file mode of the file. Must be a 4-digit octal number."; description = "The unix file mode of the file. Must be a 4-digit octal number.";
default = "0400"; default = "0400";
}; };
@@ -375,7 +376,7 @@ in
- all required programs are in PATH - all required programs are in PATH
- sandbox is set up correctly - sandbox is set up correctly
''; '';
type = lib.types.path; type = path;
readOnly = true; readOnly = true;
internal = true; internal = true;
}; };