Skip to content

Commit

Permalink
host Nix reference manual on nix.dev
Browse files Browse the repository at this point in the history
this is the most cursed setup you will see any time soon.

we're dumping the Nix manual unchanged into the build tree *after*
building. the reason is that we'd want to link to it from our table of
contents, but because Sphinx does not allow adding arbitrary files to
the build output in arbitrary locations (only `_static` works). but we
want to place the manual behind a particular URL, and the alternative of
maintaining URL rewrites (e.g. in nginx) is not accessible here because the
infrastructure is managed somewhere else.

now that the files won't appear in their desired locations at Sphinx
build time, we can't use relative links to reference them, therefore we
have to resort to pointing to the web URL the manual will appear at.
this is terrible and I'm sorry. please fix this if you have a better
idea. once we use URLs though, we have to avoid linkchecking, since
those files may not be there before deploying them.

figuring all of this out took way longer than anyone would wish.

Co-authored-by: Alejandro Sanchez Medina <alejandrosanchzmedina@gmail.com>
  • Loading branch information
fricklerhandwerk and alejandrosame committed Oct 18, 2023
1 parent 8c657ff commit 597acd7
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 10 deletions.
84 changes: 77 additions & 7 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@

inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.nix_2-13.url = "github:NixOS/nix/2.13-maintenance";

outputs = { self, nixpkgs, flake-utils}:
outputs = { self, nixpkgs, flake-utils, nix_2-13 }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
Expand All @@ -15,6 +16,7 @@
(import ./overlay.nix)
];
};
nix_2-13-doc = nix_2-13.packages.${system}.nix.doc;
in {
packages.default = pkgs.stdenv.mkDerivation {
name = "nix-dev";
Expand All @@ -33,7 +35,8 @@
make html
'';
installPhase = ''
mkdir -p $out
mkdir -p $out/manual/nix/2.13
cp -R ${nix_2-13-doc}/share/doc/nix/manual/* $out/manual/nix/2.13
cp -R build/html/* $out/
'';
};
Expand Down
5 changes: 5 additions & 0 deletions source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,11 @@
# Linkcheck fails on anchors in GH browser/file viewer, see https://github.com/sphinx-doc/sphinx/issues/11484
r"https://github\.com/.+/.+/blob/.*#.*$",
r"https://github\.com/.+/.+/tree/.*#.*$",
# XXX: we use the web URL to the manuals we host within the build output,
# because Sphinx does not have facilities to deploy arbitrary files.
# since linkchecking those URLs will fail before actually deploying them,
# we ignore them here.
r"https://nix.dev/manual/.*$",
]

# Anchors are not present in HTML
Expand Down
2 changes: 1 addition & 1 deletion source/reference/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ These sections contains collections of detailed technical descriptions.
:glob:
:maxdepth: 2
Nix Reference Manual <https://nixos.org/manual/nix/stable/>
Nix Reference Manual <https://nix.dev/manual/nix/2.13>
Nixpkgs Manual <https://nixos.org/manual/nixpkgs/stable/>
NixOS Manual <https://nixos.org/manual/nixos/stable/>
Recommended support tools <https://github.com/nix-community/awesome-nix>
Expand Down

0 comments on commit 597acd7

Please sign in to comment.