mirror of
https://github.com/NixOS/nix.dev.git
synced 2024-10-18 14:32:43 -04:00
generate index page from structured data
- refactor `default.nix` for hopefully better readability - de-noise the overview page text
This commit is contained in:
parent
7a706879c8
commit
caaa855395
124
default.nix
124
default.nix
|
@ -9,59 +9,81 @@ let
|
||||||
inherit system;
|
inherit system;
|
||||||
};
|
};
|
||||||
|
|
||||||
nix-dev = pkgs.stdenv.mkDerivation {
|
nix-dev =
|
||||||
name = "nix-dev";
|
let
|
||||||
src = ./.;
|
# Various versions of the Nix manuals, grep for (nix-manual)= to find where they are displayed
|
||||||
nativeBuildInputs = with pkgs.python310.pkgs; [
|
# FIXME: This requires human interaction to update! See ./CONTRIBUTING.md for details.
|
||||||
linkify-it-py
|
nix-releases = {
|
||||||
myst-parser
|
latest = "2.19";
|
||||||
sphinx
|
rolling = "2.18";
|
||||||
sphinx-book-theme
|
stable = "2.18";
|
||||||
sphinx-copybutton
|
prev-stable = "2.13";
|
||||||
sphinx-design
|
};
|
||||||
sphinx-notfound-page
|
nixpkgs-releases = {
|
||||||
sphinx-sitemap
|
stable = "23.11";
|
||||||
];
|
prev-stable = "23.05";
|
||||||
buildPhase = ''
|
};
|
||||||
make html
|
in
|
||||||
'';
|
pkgs.stdenv.mkDerivation {
|
||||||
installPhase =
|
name = "nix-dev";
|
||||||
let
|
src = ./.;
|
||||||
# Various versions of the Nix manuals, grep for (nix-manual)= to find where they are displayed
|
nativeBuildInputs = with pkgs.python310.pkgs; [
|
||||||
# FIXME: This requires human interaction to update! See ./CONTRIBUTING.md for details.
|
linkify-it-py
|
||||||
releases = {
|
myst-parser
|
||||||
latest = "2.19";
|
sphinx
|
||||||
rolling = "2.18";
|
sphinx-book-theme
|
||||||
stable = "2.18";
|
sphinx-copybutton
|
||||||
prev-stable = "2.13";
|
sphinx-design
|
||||||
};
|
sphinx-notfound-page
|
||||||
inputName = version: pkgs.lib.strings.replaceStrings [ "." ] [ "-" ] version;
|
sphinx-sitemap
|
||||||
src = version: inputs."nix_${inputName version}";
|
];
|
||||||
manual = version: (import (src version)).default.doc;
|
buildPhase =
|
||||||
copy = version: ''
|
let
|
||||||
cp -Rf ${manual version}/share/doc/nix/manual/* $out/manual/nix/${version}
|
nix-manual-index =
|
||||||
|
with pkgs.lib.attrsets;
|
||||||
|
let
|
||||||
|
raw = builtins.readFile ./source/reference/nix-manual.md;
|
||||||
|
nix-replacements = mapAttrsToList (release: version: "@${release}@") nix-releases;
|
||||||
|
nixpkgs-replacements = mapAttrsToList (release: version: "@nixpkgs-${release}@") nixpkgs-releases;
|
||||||
|
in
|
||||||
|
pkgs.lib.strings.replaceStrings
|
||||||
|
(nix-replacements ++ nixpkgs-replacements)
|
||||||
|
(attrValues nix-releases ++ attrValues nixpkgs-releases)
|
||||||
|
raw;
|
||||||
|
in
|
||||||
|
''
|
||||||
|
cp -f ${builtins.toFile "nix-manual.md" nix-manual-index} $TMP/nix.dev/source/reference/nix-manual.md
|
||||||
|
make html
|
||||||
'';
|
'';
|
||||||
# add upstream page redirects of the form `<from> <to> <status>`, excluding comment lines and empty
|
installPhase =
|
||||||
redirects = version: ''
|
with pkgs.lib.attrsets;
|
||||||
sed '/^#/d;/^$/d;s#^\(.*\) \(.*\) #/manual/nix/${version}\1 /manual/nix/${version}\2 #g' ${src version}/doc/manual/_redirects >> $out/_redirects
|
with pkgs.lib.strings;
|
||||||
|
let
|
||||||
|
nix-versions = with pkgs.lib; lists.unique (attrsets.attrValues nix-releases);
|
||||||
|
inputName = version: pkgs.lib.strings.replaceStrings [ "." ] [ "-" ] version;
|
||||||
|
nix-src = version: inputs."nix_${inputName version}";
|
||||||
|
nix-manual = version: (import (nix-src version)).default.doc;
|
||||||
|
copy = version: ''
|
||||||
|
cp -Rf ${nix-manual version}/share/doc/nix/manual/* $out/manual/nix/${version}
|
||||||
|
'';
|
||||||
|
# add upstream page redirects of the form `<from> <to> <status>`, excluding comment lines and empty
|
||||||
|
redirects = version: ''
|
||||||
|
sed '/^#/d;/^$/d;s#^\(.*\) \(.*\) #/manual/nix/${version}\1 /manual/nix/${version}\2 #g' ${nix-src version}/doc/manual/_redirects >> $out/_redirects
|
||||||
|
'';
|
||||||
|
shortlink = release: version: ''
|
||||||
|
echo /manual/nix/${release} /manual/nix/${version}/ 302 >> $out/_redirects
|
||||||
|
'';
|
||||||
|
in
|
||||||
|
''
|
||||||
|
mkdir -p $out
|
||||||
|
cp -R build/html/* $out/
|
||||||
|
# NOTE: the comma in the shell expansion makes it also work for singleton lists
|
||||||
|
mkdir -p $out/manual/nix/{${concatStringsSep "," nix-versions},}
|
||||||
|
${concatStringsSep "\n" (map copy nix-versions)}
|
||||||
|
${concatStringsSep "\n" (map redirects nix-versions)}
|
||||||
|
${concatStringsSep "\n" (mapAttrsToList shortlink nix-releases)}
|
||||||
'';
|
'';
|
||||||
shortlink = release: version: ''
|
};
|
||||||
echo /manual/nix/${release} /manual/nix/${version}/ 302 >> $out/_redirects
|
|
||||||
'';
|
|
||||||
versions = with pkgs.lib; lists.unique (attrsets.attrValues releases);
|
|
||||||
in
|
|
||||||
with pkgs.lib.attrsets;
|
|
||||||
with pkgs.lib.strings;
|
|
||||||
''
|
|
||||||
mkdir -p $out
|
|
||||||
cp -R build/html/* $out/
|
|
||||||
# NOTE: the comma in the shell expansion makes it also work for singleton lists
|
|
||||||
mkdir -p $out/manual/nix/{${concatStringsSep "," versions},}
|
|
||||||
${concatStringsSep "\n" (map copy versions)}
|
|
||||||
${concatStringsSep "\n" (map redirects versions)}
|
|
||||||
${concatStringsSep "\n" (mapAttrsToList shortlink releases)}
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
devmode =
|
devmode =
|
||||||
let
|
let
|
||||||
|
|
|
@ -1,35 +1,41 @@
|
||||||
(nix-manual)=
|
(nix-manual)=
|
||||||
# Nix reference manual
|
# Nix reference manual
|
||||||
|
|
||||||
|
<!--
|
||||||
|
This page is pre-processed before rendering with Sphinx. For details:
|
||||||
|
|
||||||
|
grep -n nix-manual.md default.nix
|
||||||
|
-->
|
||||||
|
|
||||||
```{toctree}
|
```{toctree}
|
||||||
:hidden:
|
:hidden:
|
||||||
|
|
||||||
Nix pre-release (development) <https://hydra.nixos.org/job/nix/master/build.x86_64-linux/latest/download>
|
Nix pre-release (development) <https://hydra.nixos.org/job/nix/master/build.x86_64-linux/latest/download>
|
||||||
Nix 2.19 (latest) <https://nix.dev/manual/nix/2.19/>
|
Nix @latest@ (latest) <https://nix.dev/manual/nix/latest/>
|
||||||
Nix 2.18 (rolling) <https://nix.dev/manual/nix/2.18/>
|
Nix @rolling@ (in rolling) <https://nix.dev/manual/nix/rolling/>
|
||||||
Nix 2.18 (stable 23.11) <https://nix.dev/manual/nix/2.18/>
|
Nix @stable@ (in stable @nixpkgs-stable@) <https://nix.dev/manual/nix/stable/>
|
||||||
Nix 2.13 (stable 23.05) <https://nix.dev/manual/nix/2.13/>
|
Nix @prev-stable@ (in stable @nixpkgs-prev-stable@) <https://nix.dev/manual/nix/prev-stable/>
|
||||||
```
|
```
|
||||||
|
|
||||||
- [Nix pre-release](https://hydra.nixos.org/job/nix/master/build.x86_64-linux/latest/download)
|
- [Nix pre-release](https://hydra.nixos.org/job/nix/master/build.x86_64-linux/latest/download)
|
||||||
|
|
||||||
Reference documentation for the latest build from the `master` branch of the [Nix repository](https://github.com/NixOS/nix)
|
Latest build from the `master` branch of the [Nix repository](https://github.com/NixOS/nix)
|
||||||
|
|
||||||
- [Nix 2.19](https://nix.dev/manual/nix/2.19/)
|
- [Nix @latest@](https://nix.dev/manual/nix/latest/)
|
||||||
|
|
||||||
Reference documentation for the latest Nix release
|
Latest Nix release
|
||||||
|
|
||||||
- [Nix 2.18](https://nix.dev/manual/nix/2.18/)
|
- [Nix @rolling@](https://nix.dev/manual/nix/rolling/)
|
||||||
|
|
||||||
Reference documentation for the Nix version shipped with the {term}`Nixpkgs` and {term}`NixOS` rolling release
|
Shipped with the {term}`Nixpkgs` and {term}`NixOS` rolling release
|
||||||
|
|
||||||
- [Nix 2.18](https://nix.dev/manual/nix/2.18/)
|
- [Nix @stable@](https://nix.dev/manual/nix/stable/)
|
||||||
|
|
||||||
Reference documentation for the Nix version shipped with the current {term}`Nixpkgs` and {term}`NixOS` stable release
|
Shipped with the current {term}`Nixpkgs` and {term}`NixOS` @nixpkgs-stable@ stable release
|
||||||
|
|
||||||
- [Nix 2.13](https://nix.dev/manual/nix/2.13/)
|
- [Nix @prev-stable@](https://nix.dev/manual/nix/prev-stable/)
|
||||||
|
|
||||||
Reference documentation for the Nix version shipped with the previous {term}`Nixpkgs` and {term}`NixOS` stable release
|
Shipped with the previous {term}`Nixpkgs` and {term}`NixOS` @nixpkgs-prev-stable@ stable release
|
||||||
|
|
||||||
:::{tip}
|
:::{tip}
|
||||||
More information on Nixpkgs and NixOS releases: [](channel-branches)
|
More information on Nixpkgs and NixOS releases: [](channel-branches)
|
||||||
|
|
Loading…
Reference in a new issue