Generators Reference
age
Generate an age private key.
Inputs:
pq- Whether to generate a post-quantum key (falseby default).
Type:
age :: { pq :: Bool; } -> Derivation
Examples:
generator = "age";
generator.age = {
pq = true;
};
alphanumeric
Generate a random alphanumeric string.
Short-hand for generator.random with charset set to "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".
Inputs:
length- Length of the generated string (32by default).count- Number of strings to generate (1by default).
Type:
alphanumeric :: { length :: Int; count :: Int; } -> AttrSet
Examples:
generator = "alphanumeric";
generator.alphanumeric = {
length = 64;
count = 2;
};
alnum
Generate a random alphanumeric string.
Alias for generator.alphanumeric.
base64
Generate a random Base64 string.
Inputs:
length- Number of random bytes to generate (32by default). The output string will be4 * ceil(length / 3)characters long.count- Number of strings to generate (1by default).
Type:
base64 :: { length :: Int; count :: Int; } -> Derivation
Examples:
generator = "base64";
generator.base64 = {
length = 64;
count = 2;
};
random
Generate a random string.
Inputs:
length- Length of the generated string (32by default).charset- Characters to use for generating the string ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*"by default).count- Number of strings to generate (1by default).
Type:
random :: { length :: Int; charset :: String; count :: Int; } -> Derivation
Examples:
generator = "random";
generator.random = {
length = 64;
charset = "abcdefghijklmnopqrstuvwxyz0123456789";
count = 2;
};
dkim
Generate a DKIM private key.
Short-hand for generator.ssh-rsa with format set to "PKCS8".
Inputs:
bits- Number of bits for the RSA key (2048by default).
Type:
dkim :: { bits :: (Int | Null); } -> AttrSet
Examples:
generator = "dkim";
generator.dkim = {
bits = 4096;
};
hex
Generate a random hexadecimal string.
Short-hand for generator.random with charset set to "0123456789abcdef".
Inputs:
length- Length of the generated string (32by default).count- Number of strings to generate (1by default).
Type:
hex :: { length :: Int; count :: Int; } -> AttrSet
Examples:
generator = "hex";
generator.hex = {
length = 64;
count = 2;
};
numeric
Generate a random numeric string.
Short-hand for generator.random with charset set to "0123456789".
Inputs:
length- Length of the generated string (32by default).count- Number of strings to generate (1by default).
Type:
numeric :: { length :: Int; count :: Int; } -> AttrSet
Examples:
generator = "numeric";
generator.numeric = {
length = 6;
count = 1;
};
password
Generate a random password from configurable character groups.
Short-hand for generator.random with a charset composed from the
selected character groups.
Inputs:
length- Length of the generated string (32by default).count- Number of strings to generate (1by default).lowercase- Include lowercase Latin letters (trueby default).uppercase- Include uppercase Latin letters (trueby default).numbers- Include digits (trueby default).symbols- Include symbols:!@#$%^&*()-_+=(falseby default).extraCharset- Additional characters to include (""by default).deduplicateCharset- Remove duplicate characters from the final charset (trueby default). Duplicates are only possible when explicitly specified inextraCharset.
Type:
password :: { length :: Int; count :: Int; lowercase :: Bool; uppercase :: Bool; numbers :: Bool; symbols :: Bool; extraCharset :: String; deduplicateCharset :: Bool; } -> AttrSet
Examples:
generator = "password";
generator.password = {
length = 64;
count = 2;
symbols = true;
};
generator.password = {
length = 16;
uppercase = false;
symbols = false;
};
generator.password = {
extraCharset = "~`";
};
generator.password = {
lowercase = false;
extraCharset = "aaa";
deduplicateCharset = false;
};
ssh
Generate an SSH private key.
Inputs:
type- SSH key type ("ed25519"by default).bits- Number of bits for the key (nullby default).comment- Comment to add to the public key (nullby default).format- Private key format (nullby default).
Type:
ssh :: { type :: String; bits :: (Int | Null); comment :: (String | Null); format :: (String | Null); } -> Derivation
Examples:
generator = "ssh";
generator.ssh = {
type = "rsa";
bits = 4096;
comment = "user@host";
format = "PEM";
};
ssh-ed25519
Generate an Ed25519 SSH private key.
Short-hand for generator.ssh with type set to "ed25519".
Inputs:
comment- Comment to add to the public key (nullby default).format- Private key format (nullby default).
Type:
ssh-ed25519 :: { comment :: (String | Null); format :: (String | Null); } -> AttrSet
Examples:
generator = "ssh-ed25519";
generator.ssh-ed25519 = {
comment = "user@host";
format = "PEM";
};
ssh-rsa
Generate an RSA SSH private key.
Short-hand for generator.ssh with type set to "rsa".
Inputs:
bits- Number of bits for the key (nullby default).comment- Comment to add to the public key (nullby default).format- Private key format (nullby default).
Type:
ssh-rsa :: { bits :: (Int | Null); comment :: (String | Null); format :: (String | Null); } -> AttrSet
Examples:
generator = "ssh-rsa";
generator.ssh-rsa = {
bits = 4096;
comment = "user@host";
format = "PEM";
};
uuid
Generate random UUIDs.
Inputs:
count- Number of UUIDs to generate (1by default).raw- Whether to remove hyphens from generated UUIDs (falseby default).
Type:
uuid :: { count :: Int; raw :: Bool; } -> Derivation
Examples:
generator = "uuid";
generator.uuid = {
count = 5;
raw = true;
};
wireguard
Generate a WireGuard private key.
Short-hand for generator.base64 with length set to 32.
Inputs:
count- Number of keys to generate (1by default).
Type:
wireguard :: { count :: Int; } -> AttrSet
Examples:
generator = "wireguard";
generator.wireguard = {
count = 2;
};