Skip to content

Commit 4781e7f

Browse files
Document each store type on its own page
This makes for more useful manual table of contents, that displays the information at a glance. The `nix help-stores` command is kept as-is, even though it will show up in the manual with the same information as these pages due to the way it is written as a "`--help`-style" command. Deciding what to do with that command is left for a later PR. This change also lists all store types at the top of the respective overview page. Co-authored-by: John Ericson <[email protected]
1 parent 0301b8f commit 4781e7f

19 files changed

+157
-49
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ perl/Makefile.config
2222
/doc/manual/xp-features.json
2323
/doc/manual/src/SUMMARY.md
2424
/doc/manual/src/SUMMARY-rl-next.md
25+
/doc/manual/src/store/types/*
26+
!/doc/manual/src/store/types/index.md.in
2527
/doc/manual/src/command-ref/new-cli
2628
/doc/manual/src/command-ref/conf-file.md
2729
/doc/manual/src/command-ref/experimental-features-shortlist.md

doc/manual/generate-manpage.nix

Lines changed: 49 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ let
5151
5252
${maybeSubcommands}
5353
54-
${maybeStoreDocs}
54+
${maybeProse}
5555
5656
${maybeOptions}
5757
'';
@@ -91,25 +91,55 @@ let
9191
* [`${command} ${name}`](./${appendName filename name}.md) - ${subcmd.description}
9292
'';
9393

94-
# FIXME: this is a hack.
95-
# store parameters should not be part of command documentation to begin
96-
# with, but instead be rendered on separate pages.
97-
maybeStoreDocs = optionalString (details ? doc)
98-
(replaceStrings [ "@stores@" ] [ (showStoreDocs inlineHTML commandInfo.stores) ] details.doc);
99-
100-
maybeOptions = let
101-
allVisibleOptions = filterAttrs
102-
(_: o: ! o.hiddenCategory)
103-
(details.flags // toplevel.flags);
104-
in optionalString (allVisibleOptions != {}) ''
105-
# Options
106-
107-
${showOptions inlineHTML allVisibleOptions}
94+
maybeProse =
95+
# FIXME: this is a horrible hack to keep `nix help-stores` working.
96+
# the correct answer to this is to remove that command and replace it
97+
# by statically generated manpages or the output of something like `nix
98+
# store info <store type>`.
99+
let
100+
help-stores = ''
101+
${index}
108102
109-
> **Note**
110-
>
111-
> See [`man nix.conf`](@docroot@/command-ref/conf-file.md#command-line-flags) for overriding configuration settings with command line flags.
112-
'';
103+
${allStores}
104+
'';
105+
index = replaceStrings
106+
[ "@store-types@" ] [ storesOverview ]
107+
details.doc;
108+
storesOverview =
109+
let
110+
showEntry = store:
111+
"- [${store.name}](#${store.slug})";
112+
in
113+
concatStringsSep "\n" (map showEntry storesList) + "\n";
114+
allStores = concatStringsSep "\n" (attrValues storePages);
115+
storePages = listToAttrs
116+
(map (s: { name = s.filename; value = s.page; }) storesList);
117+
storesList = showStoreDocs {
118+
storeInfo = commandInfo.stores;
119+
inherit inlineHTML;
120+
};
121+
in
122+
optionalString (details ? doc) (
123+
if match "@store-types@" details.doc != [ ]
124+
then help-stores
125+
else details.doc
126+
);
127+
128+
maybeOptions =
129+
let
130+
allVisibleOptions = filterAttrs
131+
(_: o: ! o.hiddenCategory)
132+
(details.flags // toplevel.flags);
133+
in
134+
optionalString (allVisibleOptions != { }) ''
135+
# Options
136+
137+
${showOptions inlineHTML allVisibleOptions}
138+
139+
> **Note**
140+
>
141+
> See [`man nix.conf`](@docroot@/command-ref/conf-file.md#command-line-flags) for overriding configuration settings with command line flags.
142+
'';
113143

114144
showOptions = inlineHTML: allOptions:
115145
let

doc/manual/generate-store-info.nix

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
let
2-
inherit (builtins) attrValues mapAttrs;
3-
inherit (import <nix/utils.nix>) concatStrings optionalString squash;
2+
inherit (builtins) attrNames listToAttrs concatStringsSep readFile replaceStrings;
3+
inherit (import <nix/utils.nix>) optionalString filterAttrs trim squash toLower unique indent;
44
showSettings = import <nix/generate-settings.nix>;
55
in
66

7-
inlineHTML: storesInfo:
7+
{
8+
# data structure describing all stores and their parameters
9+
storeInfo,
10+
# whether to add inline HTML tags
11+
# `lowdown` does not eat those for one of the output modes
12+
inlineHTML,
13+
}:
814

915
let
1016

11-
showStore = name: { settings, doc, experimentalFeature }:
17+
showStore = { name, slug }: { settings, doc, experimentalFeature }:
1218
let
1319
result = squash ''
1420
# ${name}
@@ -22,9 +28,6 @@ let
2228
${showSettings { prefix = "store-${slug}"; inherit inlineHTML; } settings}
2329
'';
2430

25-
# markdown doesn't like spaces in URLs
26-
slug = builtins.replaceStrings [ " " ] [ "-" ] name;
27-
2831
experimentalFeatureNote = optionalString (experimentalFeature != null) ''
2932
> **Warning**
3033
>
@@ -42,4 +45,13 @@ let
4245
'';
4346
in result;
4447

45-
in concatStrings (attrValues (mapAttrs showStore storesInfo))
48+
storesList = map
49+
(name: rec {
50+
inherit name;
51+
slug = replaceStrings [ " " ] [ "-" ] (toLower name);
52+
filename = "${slug}.md";
53+
page = showStore { inherit name slug; } storeInfo.${name};
54+
})
55+
(attrNames storeInfo);
56+
57+
in storesList
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
let
2+
inherit (builtins) attrNames listToAttrs concatStringsSep readFile replaceStrings;
3+
showSettings = import <nix/generate-settings.nix>;
4+
showStoreDocs = import <nix/generate-store-info.nix>;
5+
in
6+
7+
storeInfo:
8+
9+
let
10+
storesList = showStoreDocs {
11+
inherit storeInfo;
12+
inlineHTML = true;
13+
};
14+
15+
index =
16+
let
17+
showEntry = store:
18+
"- [${store.name}](./${store.filename})";
19+
in
20+
concatStringsSep "\n" (map showEntry storesList);
21+
22+
"index.md" = replaceStrings
23+
[ "@store-types@" ] [ index ]
24+
(readFile ./src/store/types/index.md.in);
25+
26+
tableOfContents =
27+
let
28+
showEntry = store:
29+
" - [${store.name}](store/types/${store.filename})";
30+
in
31+
concatStringsSep "\n" (map showEntry storesList) + "\n";
32+
33+
"SUMMARY.md" = tableOfContents;
34+
35+
storePages = listToAttrs
36+
(map (s: { name = s.filename; value = s.page; }) storesList);
37+
38+
in
39+
storePages // { inherit "index.md" "SUMMARY.md"; }

doc/manual/generate-xp-features.nix

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@ let
88
99
${doc}
1010
'';
11-
in xps: (concatStringsSep "\n" (attrValues (mapAttrs showExperimentalFeature xps)))
11+
in
12+
13+
xps: (concatStringsSep "\n" (attrValues (mapAttrs showExperimentalFeature xps)))

doc/manual/local.mk

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,17 @@ $(d)/nix-profiles.5: $(d)/src/command-ref/files/profiles.md
9797
$(trace-gen) lowdown -sT man --nroff-nolinks -M section=5 $^.tmp -o $@
9898
@rm $^.tmp
9999

100-
$(d)/src/SUMMARY.md: $(d)/src/SUMMARY.md.in $(d)/src/SUMMARY-rl-next.md $(d)/src/command-ref/new-cli $(d)/src/contributing/experimental-feature-descriptions.md
100+
$(d)/src/SUMMARY.md: $(d)/src/SUMMARY.md.in $(d)/src/SUMMARY-rl-next.md $(d)/src/store/types $(d)/src/command-ref/new-cli $(d)/src/contributing/experimental-feature-descriptions.md
101101
@cp $< $@
102102
@$(call process-includes,$@,$@)
103103

104+
$(d)/src/store/types: $(d)/nix.json $(d)/utils.nix $(d)/generate-store-info.nix $(d)/generate-store-types.nix $(d)/src/store/types/index.md.in $(doc_nix)
105+
@# FIXME: build out of tree!
106+
@rm -rf $@.tmp
107+
$(trace-gen) $(nix-eval) --write-to $@.tmp --expr 'import doc/manual/generate-store-types.nix (builtins.fromJSON (builtins.readFile $<)).stores'
108+
@# do not destroy existing contents
109+
@mv $@.tmp/* $@/
110+
104111
$(d)/src/command-ref/new-cli: $(d)/nix.json $(d)/utils.nix $(d)/generate-manpage.nix $(d)/generate-settings.nix $(d)/generate-store-info.nix $(doc_nix)
105112
@rm -rf $@ $@.tmp
106113
$(trace-gen) $(nix-eval) --write-to $@.tmp --expr 'import doc/manual/generate-manpage.nix true (builtins.readFile $<)'
@@ -200,7 +207,7 @@ doc/manual/generated/man1/nix3-manpages: $(d)/src/command-ref/new-cli
200207
# `@docroot@` is to be preserved for documenting the mechanism
201208
# FIXME: maybe contributing guides should live right next to the code
202209
# instead of in the manual
203-
$(docdir)/manual/index.html: $(MANUAL_SRCS) $(d)/book.toml $(d)/anchors.jq $(d)/custom.css $(d)/src/SUMMARY.md $(d)/src/command-ref/new-cli $(d)/src/contributing/experimental-feature-descriptions.md $(d)/src/command-ref/conf-file.md $(d)/src/language/builtins.md $(d)/src/language/builtin-constants.md $(d)/src/release-notes/rl-next.md
210+
$(docdir)/manual/index.html: $(MANUAL_SRCS) $(d)/book.toml $(d)/anchors.jq $(d)/custom.css $(d)/src/SUMMARY.md $(d)/src/store/types $(d)/src/command-ref/new-cli $(d)/src/contributing/experimental-feature-descriptions.md $(d)/src/command-ref/conf-file.md $(d)/src/language/builtins.md $(d)/src/language/builtin-constants.md $(d)/src/release-notes/rl-next.md
204211
$(trace-gen) \
205212
tmp="$$(mktemp -d)"; \
206213
cp -r doc/manual "$$tmp"; \

doc/manual/src/SUMMARY.md.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
- [File System Object](store/file-system-object.md)
2121
- [Store Object](store/store-object.md)
2222
- [Store Path](store/store-path.md)
23+
- [Store Types](store/types/index.md)
24+
{{#include ./store/types/SUMMARY.md}}
2325
- [Nix Language](language/index.md)
2426
- [Data Types](language/values.md)
2527
- [Language Constructs](language/constructs.md)

doc/manual/src/contributing/cli-guideline.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ This leads to the following guidelines:
426426
### Examples
427427
428428
429-
This is bad, because all keys must be assumed to be store implementations:
429+
This is bad, because all keys must be assumed to be store types:
430430
431431
```json
432432
{

doc/manual/src/store/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
The *Nix store* is an abstraction to store immutable file system data (such as software packages) that can have dependencies on other such data.
44

5-
There are multiple implementations of Nix stores with different capabilities, such as the actual filesystem (`/nix/store`) or binary caches.
5+
There are [multiple types of Nix stores](./types/index.md) with different capabilities, such as the default one on the [local filesystem](./types/local-store.md) (`/nix/store`) or [binary caches](./types/http-binary-cache-store.md).

doc/manual/src/store/types/index.md.in

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
Nix supports different types of stores. These are described below.
1+
Nix supports different types of stores:
2+
3+
@store-types@
24

35
## Store URL format
46

@@ -39,4 +41,3 @@ store as follows:
3941

4042
* Otherwise, use the [local store](#local-store) `/nix/store`.
4143

42-
@stores@

0 commit comments

Comments
 (0)