-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
doc: extract nixpkgs-manual into its own package
Also, use `finalAttrs` style and pass through all the helper derivations.
- Loading branch information
1 parent
8bb7777
commit 4252286
Showing
6 changed files
with
112 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,98 +1,6 @@ | ||
{ pkgs ? (import ./.. { }), nixpkgs ? { }}: | ||
let | ||
inherit (pkgs) lib callPackage; | ||
fs = lib.fileset; | ||
{ | ||
pkgs ? (import ./.. { }), | ||
nixpkgs ? { }, | ||
}: | ||
|
||
common = import ./common.nix; | ||
|
||
lib-docs = callPackage ./doc-support/lib-function-docs.nix { | ||
inherit nixpkgs; | ||
}; | ||
|
||
epub = callPackage ./doc-support/epub.nix { }; | ||
|
||
# NB: This file describes the Nixpkgs manual, which happens to use module docs infra originally developed for NixOS. | ||
optionsDoc = callPackage ./doc-support/options-doc.nix { }; | ||
|
||
pythonInterpreterTable = pkgs.callPackage ./doc-support/python-interpreter-table.nix {}; | ||
|
||
in pkgs.stdenv.mkDerivation { | ||
name = "nixpkgs-manual"; | ||
|
||
nativeBuildInputs = with pkgs; [ | ||
nixos-render-docs | ||
]; | ||
|
||
src = fs.toSource { | ||
root = ./.; | ||
fileset = fs.unions [ | ||
(fs.fileFilter (file: | ||
file.hasExt "md" | ||
|| file.hasExt "md.in" | ||
) ./.) | ||
./style.css | ||
./anchor-use.js | ||
./anchor.min.js | ||
./manpage-urls.json | ||
]; | ||
}; | ||
|
||
postPatch = '' | ||
ln -s ${optionsDoc.optionsJSON}/share/doc/nixos/options.json ./config-options.json | ||
''; | ||
|
||
buildPhase = '' | ||
substituteInPlace ./languages-frameworks/python.section.md \ | ||
--subst-var-by python-interpreter-table "$(<"${pythonInterpreterTable}")" | ||
cat \ | ||
./functions/library.md.in \ | ||
${lib-docs}/index.md \ | ||
> ./functions/library.md | ||
substitute ./manual.md.in ./manual.md \ | ||
--replace-fail '@MANUAL_VERSION@' '${pkgs.lib.version}' | ||
mkdir -p out/media | ||
mkdir -p out/highlightjs | ||
cp -t out/highlightjs \ | ||
${pkgs.documentation-highlighter}/highlight.pack.js \ | ||
${pkgs.documentation-highlighter}/LICENSE \ | ||
${pkgs.documentation-highlighter}/mono-blue.css \ | ||
${pkgs.documentation-highlighter}/loader.js | ||
cp -t out ./style.css ./anchor.min.js ./anchor-use.js | ||
nixos-render-docs manual html \ | ||
--manpage-urls ./manpage-urls.json \ | ||
--revision ${pkgs.lib.trivial.revisionWithDefault (pkgs.rev or "master")} \ | ||
--stylesheet style.css \ | ||
--stylesheet highlightjs/mono-blue.css \ | ||
--script ./highlightjs/highlight.pack.js \ | ||
--script ./highlightjs/loader.js \ | ||
--script ./anchor.min.js \ | ||
--script ./anchor-use.js \ | ||
--toc-depth 1 \ | ||
--section-toc-depth 1 \ | ||
manual.md \ | ||
out/index.html | ||
''; | ||
|
||
installPhase = '' | ||
dest="$out/${common.outputPath}" | ||
mkdir -p "$(dirname "$dest")" | ||
mv out "$dest" | ||
mv "$dest/index.html" "$dest/${common.indexPath}" | ||
cp ${epub} "$dest/nixpkgs-manual.epub" | ||
mkdir -p $out/nix-support/ | ||
echo "doc manual $dest ${common.indexPath}" >> $out/nix-support/hydra-build-products | ||
echo "doc manual $dest nixpkgs-manual.epub" >> $out/nix-support/hydra-build-products | ||
''; | ||
|
||
passthru = { | ||
inherit pythonInterpreterTable; | ||
tests.manpage-urls = callPackage ./tests/manpage-urls.nix { }; | ||
}; | ||
} | ||
pkgs.callPackage ./doc-support/package.nix { inherit nixpkgs; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# To run this derivation, `nix-build -A nixpkgs-manual.epub` | ||
{ | ||
lib, | ||
runCommand, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# To run this derivation, `nix-build -A nixpkgs-manual.optionsDoc` | ||
{ lib, nixosOptionsDoc }: | ||
|
||
let | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
{ | ||
lib, | ||
stdenvNoCC, | ||
callPackage, | ||
documentation-highlighter, | ||
nixos-render-docs, | ||
nixpkgs ? { }, | ||
}: | ||
|
||
let | ||
common = import ../common.nix; | ||
in | ||
|
||
stdenvNoCC.mkDerivation ( | ||
finalAttrs: | ||
let | ||
inherit (finalAttrs.finalPackage.optionsDoc) optionsJSON; | ||
inherit (finalAttrs.finalPackage) epub lib-docs pythonInterpreterTable; | ||
in | ||
{ | ||
name = "nixpkgs-manual"; | ||
|
||
nativeBuildInputs = [ nixos-render-docs ]; | ||
|
||
src = lib.fileset.toSource { | ||
root = ../.; | ||
fileset = lib.fileset.unions [ | ||
(lib.fileset.fileFilter (file: file.hasExt "md" || file.hasExt "md.in") ../.) | ||
../style.css | ||
../anchor-use.js | ||
../anchor.min.js | ||
../manpage-urls.json | ||
]; | ||
}; | ||
|
||
postPatch = '' | ||
ln -s ${optionsJSON}/share/doc/nixos/options.json ./config-options.json | ||
''; | ||
|
||
buildPhase = '' | ||
substituteInPlace ./languages-frameworks/python.section.md \ | ||
--subst-var-by python-interpreter-table "$(<"${pythonInterpreterTable}")" | ||
cat \ | ||
./functions/library.md.in \ | ||
${lib-docs}/index.md \ | ||
> ./functions/library.md | ||
substitute ./manual.md.in ./manual.md \ | ||
--replace-fail '@MANUAL_VERSION@' '${lib.version}' | ||
mkdir -p out/media | ||
mkdir -p out/highlightjs | ||
cp -t out/highlightjs \ | ||
${documentation-highlighter}/highlight.pack.js \ | ||
${documentation-highlighter}/LICENSE \ | ||
${documentation-highlighter}/mono-blue.css \ | ||
${documentation-highlighter}/loader.js | ||
cp -t out ./style.css ./anchor.min.js ./anchor-use.js | ||
nixos-render-docs manual html \ | ||
--manpage-urls ./manpage-urls.json \ | ||
--revision ${lib.trivial.revisionWithDefault (nixpkgs.rev or "master")} \ | ||
--stylesheet style.css \ | ||
--stylesheet highlightjs/mono-blue.css \ | ||
--script ./highlightjs/highlight.pack.js \ | ||
--script ./highlightjs/loader.js \ | ||
--script ./anchor.min.js \ | ||
--script ./anchor-use.js \ | ||
--toc-depth 1 \ | ||
--section-toc-depth 1 \ | ||
manual.md \ | ||
out/index.html | ||
''; | ||
|
||
installPhase = '' | ||
dest="$out/${common.outputPath}" | ||
mkdir -p "$(dirname "$dest")" | ||
mv out "$dest" | ||
mv "$dest/index.html" "$dest/${common.indexPath}" | ||
cp ${epub} "$dest/nixpkgs-manual.epub" | ||
mkdir -p $out/nix-support/ | ||
echo "doc manual $dest ${common.indexPath}" >> $out/nix-support/hydra-build-products | ||
echo "doc manual $dest nixpkgs-manual.epub" >> $out/nix-support/hydra-build-products | ||
''; | ||
|
||
passthru = { | ||
lib-docs = callPackage ./lib-function-docs.nix { inherit nixpkgs; }; | ||
|
||
epub = callPackage ./epub.nix { }; | ||
|
||
# NB: This file describes the Nixpkgs manual, which happens to use module docs infra originally developed for NixOS. | ||
optionsDoc = callPackage ./options-doc.nix { }; | ||
|
||
pythonInterpreterTable = callPackage ./python-interpreter-table.nix { }; | ||
|
||
tests.manpage-urls = callPackage ../tests/manpage-urls.nix { }; | ||
}; | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# To run this derivation, `nix-build -A nixpkgs-manual.tests.manpage-urls` | ||
{ | ||
lib, | ||
runCommand, | ||
|
4252286
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/suppress-warnings-for-a-derivation/49271/6