From 374a3bdf5b014d84b6ea57e80af52c5bc2d73f35 Mon Sep 17 00:00:00 2001
From: Graham Christensen <graham@grahamc.com>
Date: Tue, 1 May 2018 18:03:25 -0400
Subject: [PATCH] nixos docs: makefile for formatting

---
 nixos/doc/manual/Makefile  | 20 ++++++++++++++++++--
 nixos/doc/manual/shell.nix |  8 ++++++++
 2 files changed, 26 insertions(+), 2 deletions(-)
 create mode 100644 nixos/doc/manual/shell.nix

diff --git a/nixos/doc/manual/Makefile b/nixos/doc/manual/Makefile
index b15fbaa270fc..4993976ae57e 100644
--- a/nixos/doc/manual/Makefile
+++ b/nixos/doc/manual/Makefile
@@ -1,6 +1,22 @@
-debug:
+.PHONY: all
+all: manual-combined.xml format
+
+.PHONY: debug
+debug: generated manual-combined.xml
+
+manual-combined.xml: generated *.xml
+	rm ./manual-combined.xml
 	nix-shell --packages xmloscopy \
-		--run 'xmloscopy --docbook5 ./manual.xml ./manual-combined.xml'
+		--run "xmloscopy --docbook5 ./manual.xml ./manual-combined.xml"
+
+.PHONY: format
+format:
+	find . -iname '*.xml' -type f -print0 | xargs -0 -I{} -n1 \
+		xmlformat --config-file "../xmlformat.conf" -i {}
+
+.PHONY: clean
+clean:
+	rm -f manual-combined.xml generated
 
 generated: ./options-to-docbook.xsl
 	nix-build ../../release.nix \
diff --git a/nixos/doc/manual/shell.nix b/nixos/doc/manual/shell.nix
new file mode 100644
index 000000000000..7f8422b4ec11
--- /dev/null
+++ b/nixos/doc/manual/shell.nix
@@ -0,0 +1,8 @@
+let
+  pkgs = import ../../.. { };
+in
+pkgs.mkShell {
+  name = "nixos-manual";
+
+  buildInputs = with pkgs; [ xmlformat jing xmloscopy ];
+}