aboutsummaryrefslogtreecommitdiff
path: root/doc/manual
diff options
context:
space:
mode:
Diffstat (limited to 'doc/manual')
-rw-r--r--doc/manual/generate-builtins.jq6
-rw-r--r--doc/manual/generate-builtins.nix14
-rw-r--r--doc/manual/generate-manpage.jq44
-rw-r--r--doc/manual/generate-manpage.nix55
-rw-r--r--doc/manual/generate-options.jq16
-rw-r--r--doc/manual/generate-options.nix26
-rw-r--r--doc/manual/local.mk45
-rw-r--r--doc/manual/src/command-ref/conf-file-prefix.md2
-rw-r--r--doc/manual/src/command-ref/nix-build.md2
-rw-r--r--doc/manual/src/command-ref/nix-channel.md2
-rw-r--r--doc/manual/src/command-ref/nix-collect-garbage.md2
-rw-r--r--doc/manual/src/command-ref/nix-copy-closure.md2
-rw-r--r--doc/manual/src/command-ref/nix-daemon.md2
-rw-r--r--doc/manual/src/command-ref/nix-env.md2
-rw-r--r--doc/manual/src/command-ref/nix-hash.md2
-rw-r--r--doc/manual/src/command-ref/nix-instantiate.md2
-rw-r--r--doc/manual/src/command-ref/nix-prefetch-url.md5
-rw-r--r--doc/manual/src/command-ref/nix-shell.md2
-rw-r--r--doc/manual/src/command-ref/nix-store.md2
-rw-r--r--doc/manual/src/hacking.md16
-rw-r--r--doc/manual/src/release-notes/rl-1.7.md2
-rw-r--r--doc/manual/src/release-notes/rl-2.1.md2
-rw-r--r--doc/manual/utils.nix7
23 files changed, 149 insertions, 111 deletions
diff --git a/doc/manual/generate-builtins.jq b/doc/manual/generate-builtins.jq
deleted file mode 100644
index c38799479..000000000
--- a/doc/manual/generate-builtins.jq
+++ /dev/null
@@ -1,6 +0,0 @@
-. | to_entries | sort_by(.key) | map(
- " - `builtins." + .key + "` "
- + (.value.args | map("*" + . + "*") | join(" "))
- + " \n\n"
- + (.value.doc | split("\n") | map(" " + . + "\n") | join("")) + "\n\n"
-) | join("")
diff --git a/doc/manual/generate-builtins.nix b/doc/manual/generate-builtins.nix
new file mode 100644
index 000000000..416a7fdba
--- /dev/null
+++ b/doc/manual/generate-builtins.nix
@@ -0,0 +1,14 @@
+with builtins;
+with import ./utils.nix;
+
+builtins:
+
+concatStrings (map
+ (name:
+ let builtin = builtins.${name}; in
+ " - `builtins.${name}` " + concatStringsSep " " (map (s: "*${s}*") builtin.args)
+ + " \n\n"
+ + concatStrings (map (s: " ${s}\n") (splitLines builtin.doc)) + "\n\n"
+ )
+ (attrNames builtins))
+
diff --git a/doc/manual/generate-manpage.jq b/doc/manual/generate-manpage.jq
deleted file mode 100644
index dd632f162..000000000
--- a/doc/manual/generate-manpage.jq
+++ /dev/null
@@ -1,44 +0,0 @@
-def show_flags:
- .flags
- | map_values(select(.category != "config"))
- | to_entries
- | map(
- " - `--" + .key + "`"
- + (if .value.shortName then " / `" + .value.shortName + "`" else "" end)
- + (if .value.labels then " " + (.value.labels | map("*" + . + "*") | join(" ")) else "" end)
- + " \n"
- + " " + .value.description + "\n\n")
- | join("")
- ;
-
-def show_synopsis:
- "`" + .command + "` [*flags*...] " + (.args | map("*" + .label + "*" + (if has("arity") then "" else "..." end)) | join(" ")) + "\n\n"
- ;
-
-def show_command:
- . as $top |
- .section + " Name\n\n"
- + "`" + .command + "` - " + .def.description + "\n\n"
- + .section + " Synopsis\n\n"
- + ({"command": .command, "args": .def.args} | show_synopsis)
- + (if .def | has("doc")
- then .section + " Description\n\n" + .def.doc + "\n\n"
- else ""
- end)
- + (if (.def.flags | length) > 0 then
- .section + " Flags\n\n"
- + (.def | show_flags)
- else "" end)
- + (if (.def.examples | length) > 0 then
- .section + " Examples\n\n"
- + (.def.examples | map(.description + "\n\n```console\n" + .command + "\n```\n" ) | join("\n"))
- + "\n"
- else "" end)
- + (if .def.commands then .def.commands | to_entries | map(
- "# Subcommand `" + ($top.command + " " + .key) + "`\n\n"
- + ({"command": ($top.command + " " + .key), "section": "##", "def": .value} | show_command)
- ) | join("") else "" end)
- ;
-
-"Title: nix\n\n"
-+ ({"command": "nix", "section": "#", "def": .} | show_command)
diff --git a/doc/manual/generate-manpage.nix b/doc/manual/generate-manpage.nix
new file mode 100644
index 000000000..db266750a
--- /dev/null
+++ b/doc/manual/generate-manpage.nix
@@ -0,0 +1,55 @@
+with builtins;
+with import ./utils.nix;
+
+let
+
+ showCommand =
+ { command, section, def }:
+ "${section} Name\n\n"
+ + "`${command}` - ${def.description}\n\n"
+ + "${section} Synopsis\n\n"
+ + showSynopsis { inherit command; args = def.args; }
+ + (if def ? doc
+ then "${section} Description\n\n" + def.doc + "\n\n"
+ else "")
+ + (let s = showFlags def.flags; in
+ if s != ""
+ then "${section} Flags\n\n${s}"
+ else "")
+ + (if def.examples or [] != []
+ then
+ "${section} Examples\n\n"
+ + concatStrings (map ({ description, command }: "${description}\n\n```console\n${command}\n```\n\n") def.examples)
+ else "")
+ + (if def.commands or [] != []
+ then concatStrings (
+ map (name:
+ "# Subcommand `${command} ${name}`\n\n"
+ + showCommand { command = command + " " + name; section = "##"; def = def.commands.${name}; })
+ (attrNames def.commands))
+ else "");
+
+ showFlags = flags:
+ concatStrings
+ (map (longName:
+ let flag = flags.${longName}; in
+ if flag.category or "" != "config"
+ then
+ " - `--${longName}`"
+ + (if flag ? shortName then " / `${flag.shortName}`" else "")
+ + (if flag ? labels then " " + (concatStringsSep " " (map (s: "*${s}*") flag.labels)) else "")
+ + " \n"
+ + " " + flag.description + "\n\n"
+ else "")
+ (attrNames flags));
+
+ showSynopsis =
+ { command, args }:
+ "`${command}` [*flags*...] ${concatStringsSep " "
+ (map (arg: "*${arg.label}*" + (if arg ? arity then "" else "...")) args)}\n\n";
+
+in
+
+command:
+
+showCommand { command = "nix"; section = "#"; def = command; }
diff --git a/doc/manual/generate-options.jq b/doc/manual/generate-options.jq
deleted file mode 100644
index ccf62e8ed..000000000
--- a/doc/manual/generate-options.jq
+++ /dev/null
@@ -1,16 +0,0 @@
-. | to_entries | sort_by(.key) | map(
- " - `" + .key + "` \n\n"
- + (.value.description | split("\n") | map(" " + . + "\n") | join("")) + "\n\n"
- + " **Default:** " + (
- if .value.value == "" or .value.value == []
- then "*empty*"
- elif (.value.value | type) == "array"
- then "`" + (.value.value | join(" ")) + "`"
- else "`" + (.value.value | tostring) + "`"
- end)
- + "\n\n"
- + (if (.value.aliases | length) > 0
- then " **Deprecated alias:** " + (.value.aliases | map("`" + . + "`") | join(", ")) + "\n\n"
- else ""
- end)
-) | join("")
diff --git a/doc/manual/generate-options.nix b/doc/manual/generate-options.nix
new file mode 100644
index 000000000..3c31a4eec
--- /dev/null
+++ b/doc/manual/generate-options.nix
@@ -0,0 +1,26 @@
+with builtins;
+with import ./utils.nix;
+
+options:
+
+concatStrings (map
+ (name:
+ let option = options.${name}; in
+ " - `${name}` \n\n"
+ + concatStrings (map (s: " ${s}\n") (splitLines option.description)) + "\n\n"
+ + " **Default:** " + (
+ if option.value == "" || option.value == []
+ then "*empty*"
+ else if isBool option.value
+ then (if option.value then "`true`" else "`false`")
+ else
+ # n.b. 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.
+ (if isAttrs option.value then "`\"\"`"
+ else "`" + toString option.value + "`")) + "\n\n"
+ + (if option.aliases != []
+ then " **Deprecated alias:** " + (concatStringsSep ", " (map (s: "`${s}`") option.aliases)) + "\n\n"
+ else "")
+ )
+ (attrNames options))
diff --git a/doc/manual/local.mk b/doc/manual/local.mk
index 297a73414..7d9a1a3e8 100644
--- a/doc/manual/local.mk
+++ b/doc/manual/local.mk
@@ -15,34 +15,51 @@ clean-files += $(d)/*.1 $(d)/*.5 $(d)/*.8
dist-files += $(man-pages)
+nix-eval = $(bindir)/nix eval --experimental-features nix-command -I nix/corepkgs=corepkgs --store dummy:// --impure --raw --expr
+
$(d)/%.1: $(d)/src/command-ref/%.md
- $(trace-gen) lowdown -sT man $^ -o $@
+ @printf "Title: %s\n\n" "$$(basename $@ .1)" > $^.tmp
+ @cat $^ >> $^.tmp
+ $(trace-gen) lowdown -sT man $^.tmp -o $@
+ @rm $^.tmp
$(d)/%.8: $(d)/src/command-ref/%.md
- $(trace-gen) lowdown -sT man $^ -o $@
+ @printf "Title: %s\n\n" "$$(basename $@ .8)" > $^.tmp
+ @cat $^ >> $^.tmp
+ $(trace-gen) lowdown -sT man $^.tmp -o $@
+ @rm $^.tmp
$(d)/nix.conf.5: $(d)/src/command-ref/conf-file.md
- $(trace-gen) lowdown -sT man $^ -o $@
+ @printf "Title: %s\n\n" "$$(basename $@ .5)" > $^.tmp
+ @cat $^ >> $^.tmp
+ $(trace-gen) lowdown -sT man $^.tmp -o $@
+ @rm $^.tmp
-$(d)/src/command-ref/nix.md: $(d)/nix.json $(d)/generate-manpage.jq
- jq -r -f doc/manual/generate-manpage.jq $< > $@
+$(d)/src/command-ref/nix.md: $(d)/nix.json $(d)/generate-manpage.nix $(bindir)/nix
+ $(trace-gen) $(nix-eval) 'import doc/manual/generate-manpage.nix (builtins.fromJSON (builtins.readFile $<))' > $@.tmp
+ @mv $@.tmp $@
-$(d)/src/command-ref/conf-file.md: $(d)/conf-file.json $(d)/generate-options.jq $(d)/src/command-ref/conf-file-prefix.md
- cat doc/manual/src/command-ref/conf-file-prefix.md > $@
- jq -r -f doc/manual/generate-options.jq $< >> $@
+$(d)/src/command-ref/conf-file.md: $(d)/conf-file.json $(d)/generate-options.nix $(d)/src/command-ref/conf-file-prefix.md $(bindir)/nix
+ @cat doc/manual/src/command-ref/conf-file-prefix.md > $@.tmp
+ $(trace-gen) $(nix-eval) 'import doc/manual/generate-options.nix (builtins.fromJSON (builtins.readFile $<))' >> $@.tmp
+ @mv $@.tmp $@
$(d)/nix.json: $(bindir)/nix
- $(trace-gen) $(bindir)/nix __dump-args > $@
+ $(trace-gen) $(bindir)/nix __dump-args > $@.tmp
+ @mv $@.tmp $@
$(d)/conf-file.json: $(bindir)/nix
- $(trace-gen) env -i NIX_CONF_DIR=/dummy HOME=/dummy $(bindir)/nix show-config --json --experimental-features nix-command > $@
+ $(trace-gen) env -i NIX_CONF_DIR=/dummy HOME=/dummy NIX_SSL_CERT_FILE=/dummy/no-ca-bundle.crt $(bindir)/nix show-config --json --experimental-features nix-command > $@.tmp
+ @mv $@.tmp $@
-$(d)/src/expressions/builtins.md: $(d)/builtins.json $(d)/generate-builtins.jq $(d)/src/expressions/builtins-prefix.md
- cat doc/manual/src/expressions/builtins-prefix.md > $@
- jq -r -f doc/manual/generate-builtins.jq $< >> $@
+$(d)/src/expressions/builtins.md: $(d)/builtins.json $(d)/generate-builtins.nix $(d)/src/expressions/builtins-prefix.md $(bindir)/nix
+ @cat doc/manual/src/expressions/builtins-prefix.md > $@.tmp
+ $(trace-gen) $(nix-eval) 'import doc/manual/generate-builtins.nix (builtins.fromJSON (builtins.readFile $<))' >> $@.tmp
+ @mv $@.tmp $@
$(d)/builtins.json: $(bindir)/nix
- $(trace-gen) $(bindir)/nix __dump-builtins > $@
+ $(trace-gen) NIX_PATH=nix/corepkgs=corepkgs $(bindir)/nix __dump-builtins > $@.tmp
+ mv $@.tmp $@
# Generate the HTML manual.
install: $(docdir)/manual/index.html
diff --git a/doc/manual/src/command-ref/conf-file-prefix.md b/doc/manual/src/command-ref/conf-file-prefix.md
index 04c6cd859..9987393d2 100644
--- a/doc/manual/src/command-ref/conf-file-prefix.md
+++ b/doc/manual/src/command-ref/conf-file-prefix.md
@@ -1,5 +1,3 @@
-Title: nix.conf
-
# Name
`nix.conf` - Nix configuration file
diff --git a/doc/manual/src/command-ref/nix-build.md b/doc/manual/src/command-ref/nix-build.md
index 4bcb8db40..4565bfbc2 100644
--- a/doc/manual/src/command-ref/nix-build.md
+++ b/doc/manual/src/command-ref/nix-build.md
@@ -1,5 +1,3 @@
-Title: nix-build
-
# Name
`nix-build` - build a Nix expression
diff --git a/doc/manual/src/command-ref/nix-channel.md b/doc/manual/src/command-ref/nix-channel.md
index f0e205967..4ca12d2cc 100644
--- a/doc/manual/src/command-ref/nix-channel.md
+++ b/doc/manual/src/command-ref/nix-channel.md
@@ -1,5 +1,3 @@
-Title: nix-channel
-
# Name
`nix-channel` - manage Nix channels
diff --git a/doc/manual/src/command-ref/nix-collect-garbage.md b/doc/manual/src/command-ref/nix-collect-garbage.md
index 62a6b7ca0..296165993 100644
--- a/doc/manual/src/command-ref/nix-collect-garbage.md
+++ b/doc/manual/src/command-ref/nix-collect-garbage.md
@@ -1,5 +1,3 @@
-Title: nix-collect-garbage
-
# Name
`nix-collect-garbage` - delete unreachable store paths
diff --git a/doc/manual/src/command-ref/nix-copy-closure.md b/doc/manual/src/command-ref/nix-copy-closure.md
index 5ce320af7..dcb844a72 100644
--- a/doc/manual/src/command-ref/nix-copy-closure.md
+++ b/doc/manual/src/command-ref/nix-copy-closure.md
@@ -1,5 +1,3 @@
-Title: nix-copy-closure
-
# Name
`nix-copy-closure` - copy a closure to or from a remote machine via SSH
diff --git a/doc/manual/src/command-ref/nix-daemon.md b/doc/manual/src/command-ref/nix-daemon.md
index bd5d25026..e91cb01dd 100644
--- a/doc/manual/src/command-ref/nix-daemon.md
+++ b/doc/manual/src/command-ref/nix-daemon.md
@@ -1,5 +1,3 @@
-Title: nix-daemon
-
# Name
`nix-daemon` - Nix multi-user support daemon
diff --git a/doc/manual/src/command-ref/nix-env.md b/doc/manual/src/command-ref/nix-env.md
index ee838581b..1c23bb0ad 100644
--- a/doc/manual/src/command-ref/nix-env.md
+++ b/doc/manual/src/command-ref/nix-env.md
@@ -1,5 +1,3 @@
-Title: nix-env
-
# Name
`nix-env` - manipulate or query Nix user environments
diff --git a/doc/manual/src/command-ref/nix-hash.md b/doc/manual/src/command-ref/nix-hash.md
index d3f91f8e9..7ed82cdfc 100644
--- a/doc/manual/src/command-ref/nix-hash.md
+++ b/doc/manual/src/command-ref/nix-hash.md
@@ -1,5 +1,3 @@
-Title: nix-hash
-
# Name
`nix-hash` - compute the cryptographic hash of a path
diff --git a/doc/manual/src/command-ref/nix-instantiate.md b/doc/manual/src/command-ref/nix-instantiate.md
index d09f5ed6a..c369397b6 100644
--- a/doc/manual/src/command-ref/nix-instantiate.md
+++ b/doc/manual/src/command-ref/nix-instantiate.md
@@ -1,5 +1,3 @@
-Title: nix-instantiate
-
# Name
`nix-instantiate` - instantiate store derivations from Nix expressions
diff --git a/doc/manual/src/command-ref/nix-prefetch-url.md b/doc/manual/src/command-ref/nix-prefetch-url.md
index 1cd1063cd..78c612cd4 100644
--- a/doc/manual/src/command-ref/nix-prefetch-url.md
+++ b/doc/manual/src/command-ref/nix-prefetch-url.md
@@ -1,5 +1,3 @@
-Title: nix-prefetch-url
-
# Name
`nix-prefetch-url` - copy a file from a URL into the store and print its hash
@@ -51,6 +49,9 @@ Nix store is also printed.
result to the Nix store. The resulting hash can be used with
functions such as Nixpkgs’s `fetchzip` or `fetchFromGitHub`.
+ - `--executable`
+ Set the executable bit on the downloaded file.
+
- `--name` *name*
Override the name of the file in the Nix store. By default, this is
`hash-basename`, where *basename* is the last component of *url*.
diff --git a/doc/manual/src/command-ref/nix-shell.md b/doc/manual/src/command-ref/nix-shell.md
index fc42a202a..45a5ff08c 100644
--- a/doc/manual/src/command-ref/nix-shell.md
+++ b/doc/manual/src/command-ref/nix-shell.md
@@ -1,5 +1,3 @@
-Title: nix-shell
-
# Name
`nix-shell` - start an interactive shell based on a Nix expression
diff --git a/doc/manual/src/command-ref/nix-store.md b/doc/manual/src/command-ref/nix-store.md
index 4680339e4..827adbd05 100644
--- a/doc/manual/src/command-ref/nix-store.md
+++ b/doc/manual/src/command-ref/nix-store.md
@@ -1,5 +1,3 @@
-Title: nix-store
-
# Name
`nix-store` - manipulate or query the Nix store
diff --git a/doc/manual/src/hacking.md b/doc/manual/src/hacking.md
index 9049e42bb..2a1e55e5b 100644
--- a/doc/manual/src/hacking.md
+++ b/doc/manual/src/hacking.md
@@ -39,17 +39,17 @@ To build Nix itself in this shell:
```console
[nix-shell]$ ./bootstrap.sh
-[nix-shell]$ ./configure $configureFlags
+[nix-shell]$ ./configure $configureFlags --prefix=$(pwd)/outputs/out
[nix-shell]$ make -j $NIX_BUILD_CORES
```
-To install it in `$(pwd)/inst` and test it:
+To install it in `$(pwd)/outputs` and test it:
```console
[nix-shell]$ make install
-[nix-shell]$ make installcheck
-[nix-shell]$ ./inst/bin/nix --version
-nix (Nix) 2.4
+[nix-shell]$ make installcheck -j $NIX_BUILD_CORES
+[nix-shell]$ ./outputs/out/bin/nix --version
+nix (Nix) 3.0
```
To run a functional test:
@@ -58,6 +58,12 @@ To run a functional test:
make tests/test-name-should-auto-complete.sh.test
```
+To run the unit-tests for C++ code:
+
+```
+make check
+```
+
If you have a flakes-enabled Nix you can replace:
```console
diff --git a/doc/manual/src/release-notes/rl-1.7.md b/doc/manual/src/release-notes/rl-1.7.md
index 8d49ae54e..fb18e797d 100644
--- a/doc/manual/src/release-notes/rl-1.7.md
+++ b/doc/manual/src/release-notes/rl-1.7.md
@@ -117,7 +117,7 @@ features:
- The binary tarball installer has been improved. You can now install
Nix by running:
- $ bash <(curl https://nixos.org/nix/install)
+ $ bash <(curl -L https://nixos.org/nix/install)
- More evaluation errors include position information. For instance,
selecting a missing attribute will print something like
diff --git a/doc/manual/src/release-notes/rl-2.1.md b/doc/manual/src/release-notes/rl-2.1.md
index b88834c83..a9592657b 100644
--- a/doc/manual/src/release-notes/rl-2.1.md
+++ b/doc/manual/src/release-notes/rl-2.1.md
@@ -10,7 +10,7 @@ in certain situations. In addition, it has the following new features:
- The Nix installer now supports performing a Multi-User
installation for Linux computers which are running systemd. You
can select a Multi-User installation by passing the `--daemon`
- flag to the installer: `sh <(curl https://nixos.org/nix/install)
+ flag to the installer: `sh <(curl -L https://nixos.org/nix/install)
--daemon`.
The multi-user installer cannot handle systems with SELinux. If
diff --git a/doc/manual/utils.nix b/doc/manual/utils.nix
new file mode 100644
index 000000000..50150bf3e
--- /dev/null
+++ b/doc/manual/utils.nix
@@ -0,0 +1,7 @@
+with builtins;
+
+{
+ splitLines = s: filter (x: !isList x) (split "\n" s);
+
+ concatStrings = concatStringsSep "";
+}