summary refs log tree commit diff
diff options
context:
space:
mode:
authorRyan Mulligan <ryan@ryantm.com>2020-12-22 21:56:46 -0800
committerJonathan Ringer <jonringer@users.noreply.github.com>2021-05-22 18:14:49 -0700
commit6c14851943fe55da9df88a502d1e1fe2271d9666 (patch)
tree3508d24c58f5a5402650446aaae471f2243c24b4
parentff1ded3e2047268a55d3443459cda01cf9242e45 (diff)
downloadnixpkgs-6c14851943fe55da9df88a502d1e1fe2271d9666.tar
nixpkgs-6c14851943fe55da9df88a502d1e1fe2271d9666.tar.gz
nixpkgs-6c14851943fe55da9df88a502d1e1fe2271d9666.tar.bz2
nixpkgs-6c14851943fe55da9df88a502d1e1fe2271d9666.tar.lz
nixpkgs-6c14851943fe55da9df88a502d1e1fe2271d9666.tar.xz
nixpkgs-6c14851943fe55da9df88a502d1e1fe2271d9666.tar.zst
nixpkgs-6c14851943fe55da9df88a502d1e1fe2271d9666.zip
nixos/doc: add md-to-db.sh, convert "Building Your Own NixOS CD" to CommonMark
-rw-r--r--.github/workflows/nixos-manual.yml20
-rw-r--r--nixos/doc/manual/development/building-nixos.chapter.md18
-rw-r--r--nixos/doc/manual/development/building-nixos.xml33
-rw-r--r--nixos/doc/manual/development/development.xml2
-rw-r--r--nixos/doc/manual/from_md/README.md5
-rw-r--r--nixos/doc/manual/from_md/development/building-nixos.chapter.xml33
-rwxr-xr-xnixos/doc/manual/md-to-db.sh32
7 files changed, 109 insertions, 34 deletions
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</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](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 @@
-<chapter xmlns="http://docbook.org/ns/docbook"
-        xmlns:xlink="http://www.w3.org/1999/xlink"
-        xmlns:xi="http://www.w3.org/2001/XInclude"
-        version="5.0"
-        xml:id="sec-building-cd">
- <title>Building Your Own NixOS CD</title>
- <para>
-  Building a NixOS CD is as easy as configuring your own computer. The idea is
-  to use another module which will replace your
-  <filename>configuration.nix</filename> to configure the system that would be
-  installed on the CD.
- </para>
- <para>
-  Default CD/DVD configurations are available inside
-  <filename>nixos/modules/installer/cd-dvd</filename>.
-<screen>
-<prompt>$ </prompt>git clone https://github.com/NixOS/nixpkgs.git
-<prompt>$ </prompt>cd nixpkgs/nixos
-<prompt>$ </prompt>nix-build -A config.system.build.isoImage -I nixos-config=modules/installer/cd-dvd/installation-cd-minimal.nix default.nix</screen>
- </para>
- <para>
-  Before burning your CD/DVD, you can check the content of the image by
-  mounting anywhere like suggested by the following command:
-<screen>
-<prompt># </prompt>mount -o loop -t iso9660 ./result/iso/cd.iso /mnt/iso</screen>
- </para>
- <para>
- If you want to customize your NixOS CD in more detail, or generate other kinds
- of images, you might want to check out <link
- xlink:href="https://github.com/nix-community/nixos-generators">nixos-generators</link>. 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.
- </para>
-</chapter>
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 @@
  <xi:include href="writing-modules.xml" />
  <xi:include href="building-parts.xml" />
  <xi:include href="writing-documentation.xml" />
- <xi:include href="building-nixos.xml" />
+ <xi:include href="../from_md/development/building-nixos.chapter.xml" />
  <xi:include href="nixos-tests.xml" />
  <xi:include href="testing-installer.xml" />
  <xi:include href="releases.xml" />
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 @@
+<chapter xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-building-cd">
+  <title>Building Your Own NixOS CD</title>
+  <para>
+    Building a NixOS CD is as easy as configuring your own computer. The
+    idea is to use another module which will replace your
+    <literal>configuration.nix</literal> to configure the system that
+    would be installed on the CD.
+  </para>
+  <para>
+    Default CD/DVD configurations are available inside
+    <literal>nixos/modules/installer/cd-dvd</literal>
+  </para>
+  <programlisting>
+$ 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
+</programlisting>
+  <para>
+    Before burning your CD/DVD, you can check the content of the image
+    by mounting anywhere like suggested by the following command:
+  </para>
+  <programlisting>
+# mount -o loop -t iso9660 ./result/iso/cd.iso /mnt/iso&lt;/screen&gt;
+</programlisting>
+  <para>
+    If you want to customize your NixOS CD in more detail, or generate
+    other kinds of images, you might want to check out
+    <link xlink:href="https://github.com/nix-community/nixos-generators">nixos-generators</link>.
+    This can also be a good starting point when you want to use Nix to
+    build a <quote>minimal</quote> image that doesn’t include a NixOS
+    installation.
+  </para>
+</chapter>
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