From 6c14851943fe55da9df88a502d1e1fe2271d9666 Mon Sep 17 00:00:00 2001 From: Ryan Mulligan Date: Tue, 22 Dec 2020 21:56:46 -0800 Subject: [PATCH] nixos/doc: add md-to-db.sh, convert "Building Your Own NixOS CD" to CommonMark --- .github/workflows/nixos-manual.yml | 20 +++++++++++ .../development/building-nixos.chapter.md | 18 ++++++++++ .../doc/manual/development/building-nixos.xml | 33 ------------------- nixos/doc/manual/development/development.xml | 2 +- nixos/doc/manual/from_md/README.md | 5 +++ .../development/building-nixos.chapter.xml | 33 +++++++++++++++++++ nixos/doc/manual/md-to-db.sh | 32 ++++++++++++++++++ 7 files changed, 109 insertions(+), 34 deletions(-) create mode 100644 .github/workflows/nixos-manual.yml create mode 100644 nixos/doc/manual/development/building-nixos.chapter.md delete mode 100644 nixos/doc/manual/development/building-nixos.xml create mode 100644 nixos/doc/manual/from_md/README.md create mode 100644 nixos/doc/manual/from_md/development/building-nixos.chapter.xml create mode 100755 nixos/doc/manual/md-to-db.sh diff --git a/.github/workflows/nixos-manual.yml b/.github/workflows/nixos-manual.yml new file mode 100644 index 00000000000..101cd3906be --- /dev/null +++ b/.github/workflows/nixos-manual.yml @@ -0,0 +1,20 @@ +name: NixOS manual checks + +on: + pull_request: + branches-ignore: + - 'release-**' + paths: + - 'nixos/**/*.xml' + - 'nixos/**/*.md' + +jobs: + tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: cachix/install-nix-action@v12 + - name: Check DocBook files generated from Markdown are consistent + run: | + nixos/doc/manual/md-to-db.sh + git diff --exit-code diff --git a/nixos/doc/manual/development/building-nixos.chapter.md b/nixos/doc/manual/development/building-nixos.chapter.md new file mode 100644 index 00000000000..699a75f4115 --- /dev/null +++ b/nixos/doc/manual/development/building-nixos.chapter.md @@ -0,0 +1,18 @@ +# Building Your Own NixOS CD {#sec-building-cd} +Building a NixOS CD is as easy as configuring your own computer. The idea is to use another module which will replace your `configuration.nix` to configure the system that would be installed on the CD. + +Default CD/DVD configurations are available inside `nixos/modules/installer/cd-dvd` + +```ShellSession +$ git clone https://github.com/NixOS/nixpkgs.git +$ cd nixpkgs/nixos +$ nix-build -A config.system.build.isoImage -I nixos-config=modules/installer/cd-dvd/installation-cd-minimal.nix default.nix +``` + +Before burning your CD/DVD, you can check the content of the image by mounting anywhere like suggested by the following command: + +```ShellSession +# mount -o loop -t iso9660 ./result/iso/cd.iso /mnt/iso +``` + +If you want to customize your NixOS CD in more detail, or generate other kinds of images, you might want to check out [nixos-generators](https://github.com/nix-community/nixos-generators). This can also be a good starting point when you want to use Nix to build a 'minimal' image that doesn't include a NixOS installation. diff --git a/nixos/doc/manual/development/building-nixos.xml b/nixos/doc/manual/development/building-nixos.xml deleted file mode 100644 index d58b6354d1d..00000000000 --- a/nixos/doc/manual/development/building-nixos.xml +++ /dev/null @@ -1,33 +0,0 @@ - - Building Your Own NixOS CD - - Building a NixOS CD is as easy as configuring your own computer. The idea is - to use another module which will replace your - configuration.nix to configure the system that would be - installed on the CD. - - - Default CD/DVD configurations are available inside - nixos/modules/installer/cd-dvd. - -$ git clone https://github.com/NixOS/nixpkgs.git -$ cd nixpkgs/nixos -$ nix-build -A config.system.build.isoImage -I nixos-config=modules/installer/cd-dvd/installation-cd-minimal.nix default.nix - - - Before burning your CD/DVD, you can check the content of the image by - mounting anywhere like suggested by the following command: - -# mount -o loop -t iso9660 ./result/iso/cd.iso /mnt/iso - - - If you want to customize your NixOS CD in more detail, or generate other kinds - of images, you might want to check out nixos-generators. This can also be a good starting point when you want to use Nix to build a - 'minimal' image that doesn't include a NixOS installation. - - diff --git a/nixos/doc/manual/development/development.xml b/nixos/doc/manual/development/development.xml index 43f511b3e96..78763a73505 100644 --- a/nixos/doc/manual/development/development.xml +++ b/nixos/doc/manual/development/development.xml @@ -13,7 +13,7 @@ - + diff --git a/nixos/doc/manual/from_md/README.md b/nixos/doc/manual/from_md/README.md new file mode 100644 index 00000000000..cc6d08ca0a1 --- /dev/null +++ b/nixos/doc/manual/from_md/README.md @@ -0,0 +1,5 @@ +This directory is temporarily needed while we transition the manual to CommonMark. It stores the output of the ../md-to-db.sh script that converts CommonMark files back to DocBook. + +We are choosing to convert the Markdown to DocBook at authoring time instead of manual building time, because we do not want the pandoc toolchain to become part of the NixOS closure. + +Do not edit the DocBook files inside this directory or its subdirectories. Instead, edit the corresponding .md file in the normal manual directories, and run ../md-to-db.sh to update the file here. diff --git a/nixos/doc/manual/from_md/development/building-nixos.chapter.xml b/nixos/doc/manual/from_md/development/building-nixos.chapter.xml new file mode 100644 index 00000000000..ceb744447da --- /dev/null +++ b/nixos/doc/manual/from_md/development/building-nixos.chapter.xml @@ -0,0 +1,33 @@ + + Building Your Own NixOS CD + + Building a NixOS CD is as easy as configuring your own computer. The + idea is to use another module which will replace your + configuration.nix to configure the system that + would be installed on the CD. + + + Default CD/DVD configurations are available inside + nixos/modules/installer/cd-dvd + + +$ git clone https://github.com/NixOS/nixpkgs.git +$ cd nixpkgs/nixos +$ nix-build -A config.system.build.isoImage -I nixos-config=modules/installer/cd-dvd/installation-cd-minimal.nix default.nix + + + Before burning your CD/DVD, you can check the content of the image + by mounting anywhere like suggested by the following command: + + +# mount -o loop -t iso9660 ./result/iso/cd.iso /mnt/iso</screen> + + + If you want to customize your NixOS CD in more detail, or generate + other kinds of images, you might want to check out + nixos-generators. + This can also be a good starting point when you want to use Nix to + build a minimal image that doesn’t include a NixOS + installation. + + diff --git a/nixos/doc/manual/md-to-db.sh b/nixos/doc/manual/md-to-db.sh new file mode 100755 index 00000000000..a29d981d457 --- /dev/null +++ b/nixos/doc/manual/md-to-db.sh @@ -0,0 +1,32 @@ +#! /usr/bin/env nix-shell +#! nix-shell -I nixpkgs=channel:nixpkgs-unstable -i bash -p pandoc + +# This script is temporarily needed while we transition the manual to +# CommonMark. It converts the .md files in the regular manual folder +# into DocBook files in the from_md folder. + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +pushd $DIR + +OUT="$DIR/from_md" +mapfile -t MD_FILES < <(find . -type f -regex '.*\.md$') + +for mf in ${MD_FILES[*]}; do + mkdir -p $(dirname "$OUT/$mf") + if [ "${mf: -11}" == ".section.md" ]; then + pandoc "$mf" -t docbook \ + --extract-media=media \ + -f markdown+smart \ + | cat > "$OUT/${mf%".section.md"}.section.xml" + fi + + if [ "${mf: -11}" == ".chapter.md" ]; then + pandoc "$mf" -t docbook \ + --top-level-division=chapter \ + --extract-media=media \ + -f markdown+smart \ + | cat > "$OUT/${mf%".chapter.md"}.chapter.xml" + fi +done + +popd