about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDmitry Bogatov <git#v1@kaction.cc>2022-05-08 17:36:26 -0400
committerDmitry Bogatov <git#v1@kaction.cc>2022-05-11 21:38:04 -0400
commitaa9eb4509c2bb0c258f84d3d465096888c1e0565 (patch)
treed6551b32619a4cc85171a7a5e488094379da7d28
parentc92ef7a135ddce27b294fe11b970f0d21bc9a152 (diff)
nginx-doc-unstable: init at 2022-05-05
Build documentation of nginx (which is maintained separately from webserver
itself) and make it available both as "nginx-doc" attribute and as "doc" output
of "nginx" derivation.
-rw-r--r--pkgs/data/documentation/nginx-doc/default.nix40
-rw-r--r--pkgs/data/documentation/nginx-doc/exclude-google-analytics.patch (renamed from pkgs/servers/http/nginx/nginx-doc.patch)0
-rw-r--r--pkgs/servers/http/nginx/generic.nix44
-rw-r--r--pkgs/top-level/all-packages.nix2
4 files changed, 45 insertions, 41 deletions
diff --git a/pkgs/data/documentation/nginx-doc/default.nix b/pkgs/data/documentation/nginx-doc/default.nix
new file mode 100644
index 0000000000000..c367912d6f982
--- /dev/null
+++ b/pkgs/data/documentation/nginx-doc/default.nix
@@ -0,0 +1,40 @@
+{ lib, stdenv, libxml2, libxslt, fetchhg }:
+
+# Upstream maintains documentation (sources of https://nginx.org) in separate
+# mercurial repository, which do not correspond to particular git commit, but at
+# least has "introduced in version X.Y" comments.
+#
+# In other words, documentation does not necessary matches capabilities of
+# $out/bin/nginx, but we have no better options.
+stdenv.mkDerivation {
+  pname = "nginx-doc-unstable";
+  version = "2022-05-05";
+  src = fetchhg {
+    url = "https://hg.nginx.org/nginx.org";
+    rev = "a3aee2697d4e";
+    sha256 = "029n4mnmjw94h01qalmjgf1c2h3h7wm798xv5knk3padxiy4m28b";
+  };
+  patches = [ ./exclude-google-analytics.patch ];
+  nativeBuildInputs = [ libxslt libxml2 ];
+
+  # Generated documentation is not local-friendly, since it assumes that link to directory
+  # is the same as link to index.html in that directory, which is not how browsers behave
+  # with local filesystem.
+  #
+  # TODO: patch all relative links that do not end with .html.
+
+  # /en subdirectory must exist, relative links expect it.
+  installPhase = ''
+    mkdir -p $out/share/doc/nginx
+    mv libxslt/en $out/share/doc/nginx
+  '';
+
+  meta = with lib; {
+    description = "A reverse proxy and lightweight webserver (documentation)";
+    homepage    = "https://nginx.org/";
+    license     = licenses.bsd2;
+    platforms   = platforms.all;
+    priority    = 6;
+    maintainers = with maintainers; [ kaction ];
+  };
+}
diff --git a/pkgs/servers/http/nginx/nginx-doc.patch b/pkgs/data/documentation/nginx-doc/exclude-google-analytics.patch
index c2f3f520c3d10..c2f3f520c3d10 100644
--- a/pkgs/servers/http/nginx/nginx-doc.patch
+++ b/pkgs/data/documentation/nginx-doc/exclude-google-analytics.patch
diff --git a/pkgs/servers/http/nginx/generic.nix b/pkgs/servers/http/nginx/generic.nix
index 7bd7aaab68149..e189a7d2fdff6 100644
--- a/pkgs/servers/http/nginx/generic.nix
+++ b/pkgs/servers/http/nginx/generic.nix
@@ -1,5 +1,5 @@
-{ lib, stdenv, fetchurl, fetchpatch, openssl, zlib, pcre, libxml2, libxslt
-, fetchhg
+outer@{ lib, stdenv, fetchurl, fetchpatch, openssl, zlib, pcre, libxml2, libxslt
+, nginx-doc
 
 , nixosTests
 , substituteAll, gd, geoip, perl
@@ -17,19 +17,6 @@
 , nginxVersion ? version
 , src ? null # defaults to upstream nginx ${version}
 , sha256 ? null # when not specifying src
-
-# Upstream maintains documentation (sources of https://nginx.org) in separate
-# mercurial repository, which do not correspond to particular git commit, but at
-# least has "introduced in version X.Y" comments.
-#
-# In other words, documentation does not necessary matches capabilities of
-# $out/bin/nginx, but we have no better options.
-, srcDoc ? fetchhg {
-    url = "https://hg.nginx.org/nginx.org";
-    sha256 = "029n4mnmjw94h01qalmjgf1c2h3h7wm798xv5knk3padxiy4m28b";
-    rev = "a3aee2697d4e";
-  }
-, extraPatchesDoc ? [ ./nginx-doc.patch ]
 , configureFlags ? []
 , buildInputs ? []
 , extraPatches ? []
@@ -52,31 +39,6 @@ let
         if supports nginxVersion then mod.${attrPath} or []
         else throw "Module at ${toString mod.src} does not support nginx version ${nginxVersion}!");
 
-  # Output of this derivation is copied into $doc of resulting nginx to save on
-  # building time, since we have multiple nginx versions, but only one version
-  # of documentation.
-  #
-  # As such, this derivation never appears in user profile, so its name and
-  # compliance to conventions is not important.
-  documentation = stdenv.mkDerivation {
-    name = "nginx-doc";
-    src = srcDoc;
-    patches = extraPatchesDoc;
-    nativeBuildInputs = [ libxslt libxml2 ];
-
-    # Generated documentation is not local-friendly, since it assumes that link to directory
-    # is the same as link to index.html in that directory, which is not how browsers behave
-    # with local filesystem.
-    #
-    # TODO: patch all relative links that do not end with .html.
-
-    # /en subdirectory must exist, relative links expect it.
-    installPhase = ''
-      mkdir -p $out/share/doc/nginx
-      mv libxslt/en $out/share/doc/nginx
-    '';
-  };
-
 in
 
 stdenv.mkDerivation {
@@ -193,7 +155,7 @@ stdenv.mkDerivation {
 
   preInstall = ''
     mkdir -p $doc
-    cp -r ${documentation}/* $doc
+    cp -r ${nginx-doc}/* $doc
   '';
 
   postInstall = if postInstall != null then postInstall else ''
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 377656e0d2f84..28075971a8cdf 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -21984,6 +21984,8 @@ with pkgs;
 
   nginx = nginxStable;
 
+  nginx-doc = callPackage ../data/documentation/nginx-doc { };
+
   nginxQuic = callPackage ../servers/http/nginx/quic.nix {
     zlib = zlib-ng.override { withZlibCompat = true; };
     withPerl = false;