diff --git a/doc/default.nix b/doc/default.nix
index fe6fd477348b..7aa5760b02f7 100644
--- a/doc/default.nix
+++ b/doc/default.nix
@@ -10,47 +10,7 @@ let
inherit nixpkgs;
};
- epub = pkgs.runCommand "manual.epub" {
- nativeBuildInputs = with pkgs; [ libxslt zip ];
-
- epub = ''
-
-
- Nixpkgs Manual
- Version ${pkgs.lib.version}
-
-
- Temporarily unavailable
-
- The Nixpkgs manual is currently not available in EPUB format,
- please use the HTML manual
- instead.
-
-
- If you've used the EPUB manual in the past and it has been useful to you, please
- let us know.
-
-
-
- '';
-
- passAsFile = [ "epub" ];
- } ''
- mkdir scratch
- xsltproc \
- --param chapter.autolabel 0 \
- --nonet \
- --output scratch/ \
- ${pkgs.docbook_xsl_ns}/xml/xsl/docbook/epub/docbook.xsl \
- $epubPath
-
- echo "application/epub+zip" > mimetype
- zip -0Xq -b "$TMPDIR" "$out" mimetype
- cd scratch && zip -Xr9D -b "$TMPDIR" "$out" *
- '';
+ epub = callPackage ./doc-support/epub.nix { };
# NB: This file describes the Nixpkgs manual, which happens to use module
# docs infra originally developed for NixOS.
diff --git a/doc/doc-support/epub.nix b/doc/doc-support/epub.nix
new file mode 100644
index 000000000000..b916d3579880
--- /dev/null
+++ b/doc/doc-support/epub.nix
@@ -0,0 +1,53 @@
+{
+ lib,
+ runCommand,
+ docbook_xsl_ns,
+ libxslt,
+ zip,
+}:
+runCommand "manual.epub"
+ {
+ nativeBuildInputs = [
+ libxslt
+ zip
+ ];
+
+ epub = ''
+
+
+ Nixpkgs Manual
+ Version ${lib.version}
+
+
+ Temporarily unavailable
+
+ The Nixpkgs manual is currently not available in EPUB format,
+ please use the HTML manual
+ instead.
+
+
+ If you've used the EPUB manual in the past and it has been useful to you, please
+ let us know.
+
+
+
+ '';
+
+ passAsFile = [ "epub" ];
+ }
+ ''
+ mkdir scratch
+ xsltproc \
+ --param chapter.autolabel 0 \
+ --nonet \
+ --output scratch/ \
+ ${docbook_xsl_ns}/xml/xsl/docbook/epub/docbook.xsl \
+ $epubPath
+
+ echo "application/epub+zip" > mimetype
+ zip -0Xq -b "$TMPDIR" "$out" mimetype
+ cd scratch && zip -Xr9D -b "$TMPDIR" "$out" *
+ ''