2019-11-06 23:15:43 +03:00
|
|
|
{
|
|
|
|
pkgs ? import ./pkgs.nix
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2019-11-09 03:36:05 +03:00
|
|
|
inherit (pkgs) stdenv mobile-nixos-process-doc rsync;
|
2019-11-06 23:15:43 +03:00
|
|
|
|
|
|
|
# Styles, built from a preprocessor.
|
|
|
|
styles = pkgs.callPackage ./_support/styles { };
|
|
|
|
|
|
|
|
# Asciidoc source for the devices section.
|
|
|
|
devices = pkgs.callPackage ./_support/devices { };
|
2020-04-07 00:57:58 +03:00
|
|
|
|
|
|
|
# Asciidoc source for the options section.
|
|
|
|
options = pkgs.callPackage ./_support/options { };
|
2019-11-06 23:15:43 +03:00
|
|
|
in
|
|
|
|
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
name = "mobile-nixos-docs";
|
|
|
|
src = ./.;
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
mobile-nixos-process-doc
|
2019-11-09 03:36:05 +03:00
|
|
|
rsync
|
2019-11-06 23:15:43 +03:00
|
|
|
];
|
|
|
|
|
|
|
|
buildPhase = ''
|
2020-02-05 01:18:43 +03:00
|
|
|
export LANG=C.UTF-8
|
|
|
|
|
2019-11-06 23:15:43 +03:00
|
|
|
# Removes the internal notes.
|
|
|
|
rm -f README.md
|
|
|
|
|
|
|
|
# Replace it in-place with the repo README.
|
2019-11-12 00:46:05 +03:00
|
|
|
cat >> README.adoc <<EOF
|
2019-11-12 23:32:12 +03:00
|
|
|
= README.adoc
|
2019-11-06 23:15:43 +03:00
|
|
|
include::_support/common.inc[]
|
|
|
|
|
|
|
|
EOF
|
2020-05-05 02:44:02 +03:00
|
|
|
tail -n +4 ${../README.adoc} >> README.adoc
|
2019-11-06 23:15:43 +03:00
|
|
|
|
2020-04-30 00:10:35 +03:00
|
|
|
# The title needs to be first
|
|
|
|
head -n1 ${../CONTRIBUTING.adoc} > contributing.adoc
|
|
|
|
|
|
|
|
# Then we're adding our common stuff
|
|
|
|
cat >> contributing.adoc <<EOF
|
|
|
|
include::_support/common.inc[]
|
|
|
|
EOF
|
|
|
|
|
|
|
|
# Then continuing with the file.
|
|
|
|
tail -n +2 ${../CONTRIBUTING.adoc} >> contributing.adoc
|
|
|
|
|
2019-11-12 23:32:12 +03:00
|
|
|
if [ ! -e index.adoc ]; then
|
|
|
|
cat >> index.adoc <<EOF
|
|
|
|
= Main Page
|
|
|
|
include::_support/common.inc[]
|
|
|
|
|
|
|
|
This is a local build of the Mobile NixOS documentation.
|
|
|
|
|
|
|
|
The full site is at https://mobile.nixos.org/.
|
|
|
|
|
|
|
|
EOF
|
|
|
|
fi
|
|
|
|
|
2019-11-06 23:15:43 +03:00
|
|
|
# Copies the generated asciidoc source for the devices.
|
|
|
|
cp -prf ${devices}/devices devices
|
|
|
|
|
2020-04-07 00:57:58 +03:00
|
|
|
# Copies the generated asciidoc source for the options.
|
|
|
|
cp -prf ${options}/options options
|
|
|
|
|
2019-11-06 23:15:43 +03:00
|
|
|
# Use our pipeline to process the docs.
|
|
|
|
process-doc "**/*.adoc" "**/*.md" \
|
|
|
|
--styles-dir="${styles}" \
|
|
|
|
--output-dir="$out"
|
2021-02-23 22:16:08 +03:00
|
|
|
'';
|
2019-11-09 03:36:05 +03:00
|
|
|
|
2021-02-23 22:16:08 +03:00
|
|
|
installPhase = ''
|
2020-03-04 01:19:25 +03:00
|
|
|
rsync --prune-empty-dirs --verbose --archive \
|
2020-05-15 00:10:34 +03:00
|
|
|
--exclude="*.src.svg" \
|
|
|
|
--include="*.svg" \
|
2020-03-04 01:19:25 +03:00
|
|
|
--include="*.jpeg" \
|
|
|
|
--include="*.png" \
|
|
|
|
--include="*/" --exclude="*" . $out/
|
2019-11-06 23:15:43 +03:00
|
|
|
|
2021-02-23 22:16:08 +03:00
|
|
|
(
|
|
|
|
cd $out
|
|
|
|
if grep -RIi "$NIX_BUILD_TOP"; then
|
|
|
|
echo "error: References to $NIX_BUILD_TOP found in output:"
|
|
|
|
grep -RIi "$NIX_BUILD_TOP"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
)
|
|
|
|
'';
|
2019-11-06 23:15:43 +03:00
|
|
|
}
|