Skip to content

Commit 2daf1ee

Browse files
Ericson2314roberthxokdvium
committed
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 <[email protected]> Co-authored-by: Sergei Zimmerman <[email protected]>
1 parent e088ab3 commit 2daf1ee

File tree

95 files changed

+2322
-900
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+2322
-900
lines changed

doc/manual/generate-settings.nix

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,32 @@ in
1919
prefix,
2020
inlineHTML ? true,
2121
}:
22-
settingsInfo:
2322

2423
let
2524

2625
showSetting =
2726
prefix: setting:
2827
{
2928
description,
30-
documentDefault,
31-
defaultValue,
32-
aliases,
33-
value,
29+
3430
experimentalFeature,
31+
32+
# Whether we document the default, because it is machine agostic,
33+
# or don't because because it is machine-specific.
34+
documentDefault ? true,
35+
36+
# The default value is JSON for new-style config, rather than then
37+
# a string or boolean, for old-style config.
38+
isJson ? false,
39+
40+
defaultValue ? null,
41+
42+
subSettings ? null,
43+
44+
aliases ? [ ],
45+
46+
# The current value for this setting. Purposefully unused.
47+
value ? null,
3548
}:
3649
let
3750
result = squash ''
@@ -50,7 +63,7 @@ let
5063
5164
${description}
5265
53-
**Default:** ${showDefault documentDefault defaultValue}
66+
${showDefaultOrSubSettings}
5467
5568
${showAliases aliases}
5669
'';
@@ -72,9 +85,24 @@ let
7285
> ```
7386
'';
7487

88+
showDefaultOrSubSettings =
89+
if !isAttrs subSettings then
90+
# No subsettings, instead single setting. Show the default value.
91+
''
92+
**Default:** ${showDefault}
93+
''
94+
else
95+
# Indent the nested sub-settings, and append the outer setting name onto the prefix
96+
indent " " ''
97+
**Nullable sub-settings**: ${if subSettings.nullable then "true" else "false"}
98+
${builtins.trace prefix (showSettings "${prefix}-${setting}" subSettings.map)}
99+
'';
100+
75101
showDefault =
76-
documentDefault: defaultValue:
77102
if documentDefault then
103+
if isJson then
104+
"`${builtins.toJSON defaultValue}`"
105+
else
78106
# a StringMap value type is specified as a string, but
79107
# this shows the value type. The empty stringmap is `null` in
80108
# JSON, but that converts to `{ }` here.
@@ -95,5 +123,7 @@ let
95123
in
96124
result;
97125

126+
showSettings =
127+
prefix: settingsInfo: concatStrings (attrValues (mapAttrs (showSetting prefix) settingsInfo));
98128
in
99-
concatStrings (attrValues (mapAttrs (showSetting prefix) settingsInfo))
129+
showSettings prefix

src/build-remote/build-remote.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include "nix/store/globals.hh"
1717
#include "nix/util/serialise.hh"
1818
#include "nix/store/build-result.hh"
19-
#include "nix/store/store-api.hh"
19+
#include "nix/store/store-open.hh"
2020
#include "nix/util/strings.hh"
2121
#include "nix/store/derivations.hh"
2222
#include "nix/store/local-store.hh"

src/libcmd/command.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#include "nix/cmd/command.hh"
55
#include "nix/cmd/markdown.hh"
6-
#include "nix/store/store-api.hh"
6+
#include "nix/store/store-open.hh"
77
#include "nix/store/local-fs-store.hh"
88
#include "nix/store/derivations.hh"
99
#include "nix/expr/nixexpr.hh"

src/libcmd/common-eval-args.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include "nix/fetchers/registry.hh"
1010
#include "nix/flake/flakeref.hh"
1111
#include "nix/flake/settings.hh"
12-
#include "nix/store/store-api.hh"
12+
#include "nix/store/store-open.hh"
1313
#include "nix/cmd/command.hh"
1414
#include "nix/fetchers/tarball.hh"
1515
#include "nix/fetchers/fetch-to-store.hh"

src/libcmd/repl.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include "nix/expr/eval-settings.hh"
1313
#include "nix/expr/attr-path.hh"
1414
#include "nix/util/signals.hh"
15-
#include "nix/store/store-api.hh"
15+
#include "nix/store/store-open.hh"
1616
#include "nix/store/log-store.hh"
1717
#include "nix/cmd/common-eval-args.hh"
1818
#include "nix/expr/get-drvs.hh"

src/libexpr/primops/fetchClosure.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "nix/expr/primops.hh"
2-
#include "nix/store/store-api.hh"
2+
#include "nix/store/store-open.hh"
33
#include "nix/store/realisation.hh"
44
#include "nix/store/make-content-addressed.hh"
55
#include "nix/util/url.hh"

src/libstore-c/nix_api_store.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#include "nix/store/path.hh"
77
#include "nix/store/store-api.hh"
8+
#include "nix/store/store-open.hh"
89
#include "nix/store/build-result.hh"
910

1011
#include "nix/store/globals.hh"
@@ -42,7 +43,7 @@ Store * nix_store_open(nix_c_context * context, const char * uri, const char ***
4243
if (!params)
4344
return new Store{nix::openStore(uri_str)};
4445

45-
nix::Store::Config::Params params_map;
46+
nix::StoreReference::Params params_map;
4647
for (size_t i = 0; params[i] != nullptr; i++) {
4748
params_map[params[i][0]] = params[i][1];
4849
}

src/libstore-test-support/include/nix/store/tests/libstore.hh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <gmock/gmock.h>
66

77
#include "nix/store/store-api.hh"
8+
#include "nix/store/store-open.hh"
89

910
namespace nix {
1011

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"scheme": "auto"
3+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"root": "/foo/bar/baz",
3+
"scheme": "auto"
4+
}

0 commit comments

Comments
 (0)