mirror of
https://github.com/NixOS/nix
synced 2025-07-06 21:41:48 +02:00
New store settings system
Motivation: See the linked issues for details. The most notable user-relevant bits are: - This cleans up the `MountedSSHStore`: decomposed into its orthogonal parts - This brings us pretty close to being able to then implement a JSON-based config. - Store query parameters can be JSON - Stores can entirely be specified via JSON objects, but this is not yet hooked up to anything. Also behind the scenes have these benefits: 1. The docs are moved out of the headers, good for less rebuilding when they changes 2. Stores are always constructed from store configs 3. Use JSON, avoid custom serializers Context: Part of #11106 Co-Authored-By: Robert Hensing <robert@roberthensing.nl> Co-authored-by: Sergei Zimmerman <145775305+xokdvium@users.noreply.github.com>
This commit is contained in:
parent
bf5d544d3b
commit
2ea9f59978
69 changed files with 2062 additions and 701 deletions
|
@ -19,7 +19,6 @@ in
|
|||
prefix,
|
||||
inlineHTML ? true,
|
||||
}:
|
||||
settingsInfo:
|
||||
|
||||
let
|
||||
|
||||
|
@ -27,11 +26,25 @@ let
|
|||
prefix: setting:
|
||||
{
|
||||
description,
|
||||
documentDefault,
|
||||
defaultValue,
|
||||
aliases,
|
||||
value,
|
||||
|
||||
experimentalFeature,
|
||||
|
||||
# Whether we document the default, because it is machine agostic,
|
||||
# or don't because because it is machine-specific.
|
||||
documentDefault ? true,
|
||||
|
||||
# The default value is JSON for new-style config, rather than then
|
||||
# a string or boolean, for old-style config.
|
||||
isJson ? false,
|
||||
|
||||
defaultValue ? null,
|
||||
|
||||
subSettings ? null,
|
||||
|
||||
aliases ? [ ],
|
||||
|
||||
# The current value for this setting. Purposefully unused.
|
||||
value ? null,
|
||||
}:
|
||||
let
|
||||
result = squash ''
|
||||
|
@ -50,7 +63,7 @@ let
|
|||
|
||||
${description}
|
||||
|
||||
**Default:** ${showDefault documentDefault defaultValue}
|
||||
${showDefaultOrSubSettings}
|
||||
|
||||
${showAliases aliases}
|
||||
'';
|
||||
|
@ -72,9 +85,24 @@ let
|
|||
> ```
|
||||
'';
|
||||
|
||||
showDefaultOrSubSettings =
|
||||
if !isAttrs subSettings then
|
||||
# No subsettings, instead single setting. Show the default value.
|
||||
''
|
||||
**Default:** ${showDefault}
|
||||
''
|
||||
else
|
||||
# Indent the nested sub-settings, and append the outer setting name onto the prefix
|
||||
indent " " ''
|
||||
**Nullable sub-settings**: ${if subSettings.nullable then "true" else "false"}
|
||||
${builtins.trace prefix (showSettings "${prefix}-${setting}" subSettings.map)}
|
||||
'';
|
||||
|
||||
showDefault =
|
||||
documentDefault: defaultValue:
|
||||
if documentDefault then
|
||||
if isJson then
|
||||
"`${builtins.toJSON defaultValue}`"
|
||||
else
|
||||
# a StringMap value type is specified as a string, but
|
||||
# this shows the value type. The empty stringmap is `null` in
|
||||
# JSON, but that converts to `{ }` here.
|
||||
|
@ -95,5 +123,7 @@ let
|
|||
in
|
||||
result;
|
||||
|
||||
showSettings =
|
||||
prefix: settingsInfo: concatStrings (attrValues (mapAttrs (showSetting prefix) settingsInfo));
|
||||
in
|
||||
concatStrings (attrValues (mapAttrs (showSetting prefix) settingsInfo))
|
||||
showSettings prefix
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue