mirror of
https://github.com/NixOS/nix.dev.git
synced 2024-10-18 14:32:43 -04:00
rework the way redirects are built
This commit is contained in:
parent
caaa855395
commit
3ffb8d8227
|
@ -30,31 +30,29 @@ The following manual steps are required:
|
||||||
- Regularly update the inputs to use the latest versions of the Nix release branches with `nix shell --run "niv update"`
|
- Regularly update the inputs to use the latest versions of the Nix release branches with `nix shell --run "niv update"`
|
||||||
|
|
||||||
To avoid long build times, make sure Nix can be fetched from the cache.
|
To avoid long build times, make sure Nix can be fetched from the cache.
|
||||||
If it doesn't, find the latest commit that is [built by Hydra](https://hydra.nixos.org/project/nix). For example, to pin Nix 2.18:
|
If it doesn't, find the latest commit that is [built by Hydra](https://hydra.nixos.org/project/nix). For example, to update the latest Nix release to 2.20:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
niv update nix_2-18 -r f5f4de6a550327b4b1a06123c2e450f1b92c73b6
|
niv update nix-stable -b 2.20-maintenance -r 7599d4bbed3c188c72b547fc08c7b022e7d1c54f
|
||||||
```
|
```
|
||||||
|
|
||||||
- On each new Nix release:
|
- On each new Nix release, update the `nix-latest` to the corresponding release branch:
|
||||||
|
|
||||||
1. Add the latest version in [`default.nix`](./default.nix).
|
|
||||||
For example, to add Nix 2.19:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
niv add nixos/nix -n nix_2-19 -b 2.19-maintenance
|
|
||||||
```
|
|
||||||
|
|
||||||
2. Reference the latest version in [`source/reference/nix-manual.md`](./source/reference/nix-manual.md).
|
|
||||||
|
|
||||||
- If an unstable or stable release of Nixpkgs adopt a new version of Nix, update the corresponding references here.
|
|
||||||
|
|
||||||
Also update URLs to the the Nix manual to the version used by Nixpkgs unstable.
|
|
||||||
For example, if one wants to move from 2.18 to 2.19:
|
|
||||||
```bash
|
```bash
|
||||||
sed -i 's#https://nix.dev/manual/nix/2.18/#https://nix.dev/manual/nix/2.19/#g' $(ls **/*.md)
|
niv update nix-latest -b 2.20-maintenance
|
||||||
```
|
```
|
||||||
|
|
||||||
|
- On each new Nixpkgs release, update `nixpkgs-stable` and `nixpkgs-prev-stable` and the corresponding Nix versions:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
niv update nixpkgs-stable -b nixos-24.05
|
||||||
|
niv update nix-stable -b 2.19-maintenance
|
||||||
|
niv update nixpkgs-prev-stable -b nixos-23.11
|
||||||
|
niv update nix-prev-stable -b 2.18-maintenance
|
||||||
|
```
|
||||||
|
|
||||||
|
It would be nice to have *efficient* automatic updates.
|
||||||
|
|
||||||
## Contributor guides
|
## Contributor guides
|
||||||
|
|
||||||
Please read [Contributing Documentation](https://nix.dev/contributing/documentation).
|
Please read [Contributing Documentation](https://nix.dev/contributing/documentation).
|
||||||
|
|
88
default.nix
88
default.nix
|
@ -3,26 +3,30 @@
|
||||||
,
|
,
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
pkgs = import inputs.nixpkgs {
|
pkgs = import inputs.nixpkgs-prev-stable {
|
||||||
config = { };
|
config = { };
|
||||||
overlays = [ (import ./overlay.nix) ];
|
overlays = [ (import ./overlay.nix) ];
|
||||||
inherit system;
|
inherit system;
|
||||||
};
|
};
|
||||||
|
lib = pkgs.lib;
|
||||||
|
|
||||||
nix-dev =
|
nix-dev =
|
||||||
let
|
let
|
||||||
# Various versions of the Nix manuals, grep for (nix-manual)= to find where they are displayed
|
# Various versions of the Nix manuals, grep for (nix-manual)= to find where they are displayed.
|
||||||
# FIXME: This requires human interaction to update! See ./CONTRIBUTING.md for details.
|
# FIXME: This requires human interaction to update! See ./CONTRIBUTING.md for details.
|
||||||
nix-releases = {
|
releases = rec {
|
||||||
latest = "2.19";
|
nixpkgs-rolling = import inputs.nixpkgs-rolling { } // { inherit (nixpkgs-rolling.lib) version; };
|
||||||
rolling = "2.18";
|
nixpkgs-stable = import inputs.nixpkgs-stable { } // { inherit (nixpkgs-stable.lib) version; };
|
||||||
stable = "2.18";
|
nixpkgs-prev-stable = import inputs.nixpkgs-prev-stable { } // { inherit (nixpkgs-prev-stable.lib) version; };
|
||||||
prev-stable = "2.13";
|
nix-latest = (import inputs.nix-latest).default;
|
||||||
};
|
# TODO: to further simplify this and get Nix from Nixpkgs with all required files present,
|
||||||
nixpkgs-releases = {
|
# make a patch release of Nix after https://github.com/NixOS/nix/pull/9949 lands,
|
||||||
stable = "23.11";
|
# and bump the respective version in the respective Nixpkgs `release-*` branch.
|
||||||
prev-stable = "23.05";
|
nix-rolling = (import inputs.nix-rolling).default;
|
||||||
|
nix-stable = (import inputs.nix-stable).default;
|
||||||
|
nix-prev-stable = (import inputs.nix-prev-stable).default;
|
||||||
};
|
};
|
||||||
|
version = package: lib.versions.majorMinor package.version;
|
||||||
in
|
in
|
||||||
pkgs.stdenv.mkDerivation {
|
pkgs.stdenv.mkDerivation {
|
||||||
name = "nix-dev";
|
name = "nix-dev";
|
||||||
|
@ -40,47 +44,57 @@ let
|
||||||
buildPhase =
|
buildPhase =
|
||||||
let
|
let
|
||||||
nix-manual-index =
|
nix-manual-index =
|
||||||
with pkgs.lib.attrsets;
|
with lib.attrsets;
|
||||||
let
|
with lib.strings;
|
||||||
raw = builtins.readFile ./source/reference/nix-manual.md;
|
replaceStrings
|
||||||
nix-replacements = mapAttrsToList (release: version: "@${release}@") nix-releases;
|
(mapAttrsToList (release: _: "@${release}@") releases)
|
||||||
nixpkgs-replacements = mapAttrsToList (release: version: "@nixpkgs-${release}@") nixpkgs-releases;
|
(mapAttrsToList (_: package: version package) releases)
|
||||||
in
|
(builtins.readFile ./source/reference/nix-manual.md);
|
||||||
pkgs.lib.strings.replaceStrings
|
|
||||||
(nix-replacements ++ nixpkgs-replacements)
|
|
||||||
(attrValues nix-releases ++ attrValues nixpkgs-releases)
|
|
||||||
raw;
|
|
||||||
in
|
in
|
||||||
''
|
''
|
||||||
cp -f ${builtins.toFile "nix-manual.md" nix-manual-index} $TMP/nix.dev/source/reference/nix-manual.md
|
cp -f ${builtins.toFile "nix-manual.md" nix-manual-index} $TMP/nix.dev/source/reference/nix-manual.md
|
||||||
make html
|
make html
|
||||||
'';
|
'';
|
||||||
installPhase =
|
installPhase =
|
||||||
with pkgs.lib.attrsets;
|
with lib.attrsets;
|
||||||
with pkgs.lib.strings;
|
with lib.strings;
|
||||||
let
|
let
|
||||||
nix-versions = with pkgs.lib; lists.unique (attrsets.attrValues nix-releases);
|
nix-releases =
|
||||||
inputName = version: pkgs.lib.strings.replaceStrings [ "." ] [ "-" ] version;
|
let
|
||||||
nix-src = version: inputs."nix_${inputName version}";
|
package = name: elemAt (splitString "-" name) 0;
|
||||||
nix-manual = version: (import (nix-src version)).default.doc;
|
release = name: elemAt (splitString "-" name) 1;
|
||||||
copy = version: ''
|
filtered = filterAttrs (name: value: (package name) == "nix") releases;
|
||||||
cp -Rf ${nix-manual version}/share/doc/nix/manual/* $out/manual/nix/${version}
|
in
|
||||||
|
mapAttrs' (name: value: { name = release name; inherit value; }) filtered;
|
||||||
|
# the same Nix version could appear in multiple Nixpkgs releases,
|
||||||
|
# but we want to copy each exactly once.
|
||||||
|
unique-version =
|
||||||
|
let
|
||||||
|
version-exists = p: ps: elem (version p) (map (x: version x) ps);
|
||||||
|
in
|
||||||
|
lib.lists.foldl' (acc: elem: if version-exists elem acc then acc else acc ++ [ elem ]) [ ];
|
||||||
|
copy = nix: ''
|
||||||
|
cp -Rf ${nix.doc}/share/doc/nix/manual/* $out/manual/nix/${version nix}
|
||||||
'';
|
'';
|
||||||
# add upstream page redirects of the form `<from> <to> <status>`, excluding comment lines and empty
|
# add upstream page redirects of the form `<from> <to> <status>`, excluding comments and empty lines
|
||||||
redirects = version: ''
|
# TODO: once https://github.com/NixOS/nix/pull/9949 lands, bump the source and use:
|
||||||
sed '/^#/d;/^$/d;s#^\(.*\) \(.*\) #/manual/nix/${version}\1 /manual/nix/${version}\2 #g' ${nix-src version}/doc/manual/_redirects >> $out/_redirects
|
# ${nix.doc}/share/doc/nix/manual/_redirects
|
||||||
|
# also remove the then unnecessary file from the root directory of the manual:
|
||||||
|
# rm $out/manual/nix/${version nix}/_redirects
|
||||||
|
redirects = nix: ''
|
||||||
|
sed '/^#/d;/^$/d;s#^\(.*\) \(.*\) #/manual/nix/${version nix}\1 /manual/nix/${version nix}\2 #g' ${nix.src}/doc/manual/_redirects >> $out/_redirects
|
||||||
'';
|
'';
|
||||||
shortlink = release: version: ''
|
shortlink = release: nix: ''
|
||||||
echo /manual/nix/${release} /manual/nix/${version}/ 302 >> $out/_redirects
|
echo /nix/manual/${release} /nix/manual/${nix.version}/ 302 >> $out/_redirects
|
||||||
'';
|
'';
|
||||||
in
|
in
|
||||||
''
|
''
|
||||||
mkdir -p $out
|
mkdir -p $out
|
||||||
cp -R build/html/* $out/
|
cp -R build/html/* $out/
|
||||||
# NOTE: the comma in the shell expansion makes it also work for singleton lists
|
# NOTE: the comma in the shell expansion makes it also work for singleton lists
|
||||||
mkdir -p $out/manual/nix/{${concatStringsSep "," nix-versions},}
|
mkdir -p $out/manual/nix/{${concatStringsSep "," (mapAttrsToList (_: nix: version nix) nix-releases)},}
|
||||||
${concatStringsSep "\n" (map copy nix-versions)}
|
${concatStringsSep "\n" (map copy (unique-version (attrValues nix-releases)))}
|
||||||
${concatStringsSep "\n" (map redirects nix-versions)}
|
${concatStringsSep "\n" (map redirects (unique-version (attrValues nix-releases)))}
|
||||||
${concatStringsSep "\n" (mapAttrsToList shortlink nix-releases)}
|
${concatStringsSep "\n" (mapAttrsToList shortlink nix-releases)}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"nix_2-13": {
|
"nix-prev-stable": {
|
||||||
"branch": "2.13-maintenance",
|
"branch": "2.13-maintenance",
|
||||||
"description": "Nix, the purely functional package manager",
|
"description": "Nix, the purely functional package manager",
|
||||||
"homepage": "https://nixos.org/",
|
"homepage": "https://nixos.org/",
|
||||||
|
@ -11,7 +11,7 @@
|
||||||
"url": "https://github.com/nixos/nix/archive/25f2dfc6e41d8c30e7abc443a7b262e34e49253b.tar.gz",
|
"url": "https://github.com/nixos/nix/archive/25f2dfc6e41d8c30e7abc443a7b262e34e49253b.tar.gz",
|
||||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||||
},
|
},
|
||||||
"nix_2-18": {
|
"nix-rolling": {
|
||||||
"branch": "2.18-maintenance",
|
"branch": "2.18-maintenance",
|
||||||
"description": "Nix, the purely functional package manager",
|
"description": "Nix, the purely functional package manager",
|
||||||
"homepage": "https://nixos.org/",
|
"homepage": "https://nixos.org/",
|
||||||
|
@ -23,7 +23,7 @@
|
||||||
"url": "https://github.com/nixos/nix/archive/60eb80593f3a18aebc7672ad7007cb23c14db061.tar.gz",
|
"url": "https://github.com/nixos/nix/archive/60eb80593f3a18aebc7672ad7007cb23c14db061.tar.gz",
|
||||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||||
},
|
},
|
||||||
"nix_2-19": {
|
"nix-latest": {
|
||||||
"branch": "2.19-maintenance",
|
"branch": "2.19-maintenance",
|
||||||
"description": "Nix, the purely functional package manager",
|
"description": "Nix, the purely functional package manager",
|
||||||
"homepage": "https://nixos.org/",
|
"homepage": "https://nixos.org/",
|
||||||
|
@ -35,7 +35,19 @@
|
||||||
"url": "https://github.com/nixos/nix/archive/dc09e6193bffcab37d3d43107eae9464395ab51d.tar.gz",
|
"url": "https://github.com/nixos/nix/archive/dc09e6193bffcab37d3d43107eae9464395ab51d.tar.gz",
|
||||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nix-stable": {
|
||||||
|
"branch": "2.18-maintenance",
|
||||||
|
"description": "Nix, the purely functional package manager",
|
||||||
|
"homepage": "https://nixos.org/",
|
||||||
|
"owner": "nixos",
|
||||||
|
"repo": "nix",
|
||||||
|
"rev": "60eb80593f3a18aebc7672ad7007cb23c14db061",
|
||||||
|
"sha256": "0nyssab6skn9qd7mz4v0y3ycnhck7is6agm0i26l1anrgs90x37l",
|
||||||
|
"type": "tarball",
|
||||||
|
"url": "https://github.com/nixos/nix/archive/60eb80593f3a18aebc7672ad7007cb23c14db061.tar.gz",
|
||||||
|
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||||
|
},
|
||||||
|
"nixpkgs-prev-stable": {
|
||||||
"branch": "nixos-23.05",
|
"branch": "nixos-23.05",
|
||||||
"description": "Nix Packages collection & NixOS",
|
"description": "Nix Packages collection & NixOS",
|
||||||
"homepage": "",
|
"homepage": "",
|
||||||
|
@ -47,6 +59,30 @@
|
||||||
"url": "https://github.com/NixOS/nixpkgs/archive/898cb2064b6e98b8c5499f37e81adbdf2925f7c5.tar.gz",
|
"url": "https://github.com/NixOS/nixpkgs/archive/898cb2064b6e98b8c5499f37e81adbdf2925f7c5.tar.gz",
|
||||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||||
},
|
},
|
||||||
|
"nixpkgs-rolling": {
|
||||||
|
"branch": "nixpkgs-unstable",
|
||||||
|
"description": "Nix Packages collection & NixOS",
|
||||||
|
"homepage": "",
|
||||||
|
"owner": "nixos",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "8cc79aa39bbc6eaedaf286ae655b224c71e02907",
|
||||||
|
"sha256": "08yj32spm74bqnwq7wyaxzqjw3dc67bb3myx1baix506as54jr3y",
|
||||||
|
"type": "tarball",
|
||||||
|
"url": "https://github.com/nixos/nixpkgs/archive/8cc79aa39bbc6eaedaf286ae655b224c71e02907.tar.gz",
|
||||||
|
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||||
|
},
|
||||||
|
"nixpkgs-stable": {
|
||||||
|
"branch": "nixos-23.11",
|
||||||
|
"description": "Nix Packages collection & NixOS",
|
||||||
|
"homepage": "",
|
||||||
|
"owner": "nixos",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "9f2ee8c91ac42da3ae6c6a1d21555f283458247e",
|
||||||
|
"sha256": "0imgfxzq7d7l6fcgnzzjvv6ch560svcm8s8bx8vqyvf60w24ma1d",
|
||||||
|
"type": "tarball",
|
||||||
|
"url": "https://github.com/nixos/nixpkgs/archive/9f2ee8c91ac42da3ae6c6a1d21555f283458247e.tar.gz",
|
||||||
|
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||||
|
},
|
||||||
"poetry2nix": {
|
"poetry2nix": {
|
||||||
"branch": "master",
|
"branch": "master",
|
||||||
"description": "Convert poetry projects to nix automagically [maintainer=@adisbladis] ",
|
"description": "Convert poetry projects to nix automagically [maintainer=@adisbladis] ",
|
||||||
|
|
|
@ -11,29 +11,29 @@ This page is pre-processed before rendering with Sphinx. For details:
|
||||||
: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 @latest@ (latest) <https://nix.dev/manual/nix/latest/>
|
Nix @nix-latest@ (latest) <https://nix.dev/manual/nix/latest/>
|
||||||
Nix @rolling@ (in rolling) <https://nix.dev/manual/nix/rolling/>
|
Nix @nix-rolling@ (in Nixpkgs rolling) <https://nix.dev/manual/nix/rolling/>
|
||||||
Nix @stable@ (in stable @nixpkgs-stable@) <https://nix.dev/manual/nix/stable/>
|
Nix @nix-stable@ (in Nixpkgs @nixpkgs-stable@) <https://nix.dev/manual/nix/stable/>
|
||||||
Nix @prev-stable@ (in stable @nixpkgs-prev-stable@) <https://nix.dev/manual/nix/prev-stable/>
|
Nix @nix-prev-stable@ (in Nixpkgs @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)
|
||||||
|
|
||||||
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 @latest@](https://nix.dev/manual/nix/latest/)
|
- [Nix @nix-latest@](https://nix.dev/manual/nix/latest/)
|
||||||
|
|
||||||
Latest Nix release
|
Latest Nix release
|
||||||
|
|
||||||
- [Nix @rolling@](https://nix.dev/manual/nix/rolling/)
|
- [Nix @nix-rolling@](https://nix.dev/manual/nix/rolling/)
|
||||||
|
|
||||||
Shipped with the {term}`Nixpkgs` and {term}`NixOS` rolling release
|
Shipped with the {term}`Nixpkgs` and {term}`NixOS` rolling release
|
||||||
|
|
||||||
- [Nix @stable@](https://nix.dev/manual/nix/stable/)
|
- [Nix @nix-stable@](https://nix.dev/manual/nix/stable/)
|
||||||
|
|
||||||
Shipped with the current {term}`Nixpkgs` and {term}`NixOS` @nixpkgs-stable@ stable release
|
Shipped with the current {term}`Nixpkgs` and {term}`NixOS` @nixpkgs-stable@ stable release
|
||||||
|
|
||||||
- [Nix @prev-stable@](https://nix.dev/manual/nix/prev-stable/)
|
- [Nix @nix-prev-stable@](https://nix.dev/manual/nix/prev-stable/)
|
||||||
|
|
||||||
Shipped with the previous {term}`Nixpkgs` and {term}`NixOS` @nixpkgs-prev-stable@ stable release
|
Shipped with the previous {term}`Nixpkgs` and {term}`NixOS` @nixpkgs-prev-stable@ stable release
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue