From c2ee47693da386c9f93497f249b2c98e15ec8b20 Mon Sep 17 00:00:00 2001
From: volth <volth@webmaster.ms>
Date: Sun, 26 Nov 2017 07:10:49 +0000
Subject: [PATCH 1/3] varnish: 5.1.3 -> 5.2.1

---
 pkgs/servers/varnish/default.nix | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pkgs/servers/varnish/default.nix b/pkgs/servers/varnish/default.nix
index 468cc86d8893..9efb4e4dfe5a 100644
--- a/pkgs/servers/varnish/default.nix
+++ b/pkgs/servers/varnish/default.nix
@@ -2,12 +2,12 @@
 , python, pythonPackages, makeWrapper }:
 
 stdenv.mkDerivation rec {
-  version = "5.1.3";
+  version = "5.2.1";
   name = "varnish-${version}";
 
   src = fetchurl {
-    url = "http://repo.varnish-cache.org/source/${name}.tar.gz";
-    sha256 = "0km50hzjzi1kq85lr3hq519nrp261wb91ixq48vhyd41llycjfbl";
+    url = "http://varnish-cache.org/_downloads/${name}.tgz";
+    sha256 = "1cqlj12m426c1lak1hr1fx5zcfsjjvka3hfirz47hvy1g2fjqidq";
   };
 
   nativeBuildInputs = [ pkgconfig ];
@@ -32,6 +32,6 @@ stdenv.mkDerivation rec {
     homepage = https://www.varnish-cache.org;
     license = licenses.bsd2;
     maintainers = with maintainers; [ garbas fpletz ];
-    platforms = platforms.linux ++ platforms.darwin;
+    platforms = platforms.unix;
   };
 }

From e1ab684780655d7b6e8e7299f7c0d8a1ce63590c Mon Sep 17 00:00:00 2001
From: volth <volth@webmaster.ms>
Date: Sun, 26 Nov 2017 07:12:51 +0000
Subject: [PATCH 2/3] mark varnish-rtstatus broken (it has not ported to
 varnish 5.2 yet)

---
 pkgs/servers/varnish/rtstatus.nix | 1 +
 1 file changed, 1 insertion(+)

diff --git a/pkgs/servers/varnish/rtstatus.nix b/pkgs/servers/varnish/rtstatus.nix
index 1efa6d5e7989..e92559f038d8 100644
--- a/pkgs/servers/varnish/rtstatus.nix
+++ b/pkgs/servers/varnish/rtstatus.nix
@@ -17,5 +17,6 @@ stdenv.mkDerivation rec {
     description = "Varnish realtime status page";
     homepage = https://github.com/varnish/libvmod-rtstatus;
     inherit (varnish.meta) license platforms maintainers;
+    broken = true; # it has not ported to varnish 5.2 yet (5.1 is ok)
   };
 }

From f52fcbae20ecf9b9941fa9fd2fc7ea1f7419a578 Mon Sep 17 00:00:00 2001
From: volth <volth@webmaster.ms>
Date: Sun, 26 Nov 2017 11:51:29 +0000
Subject: [PATCH 3/3] varnish-modules: remove references to varnish.dev

---
 pkgs/servers/varnish/modules.nix | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/pkgs/servers/varnish/modules.nix b/pkgs/servers/varnish/modules.nix
index c37fae4ba3d2..8327b2ca5166 100644
--- a/pkgs/servers/varnish/modules.nix
+++ b/pkgs/servers/varnish/modules.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, pkgconfig, varnish, python, docutils }:
+{ stdenv, fetchurl, pkgconfig, varnish, python, docutils, removeReferencesTo }:
 
 stdenv.mkDerivation rec {
   version = "0.10.2";
@@ -9,9 +9,11 @@ stdenv.mkDerivation rec {
     sha256 = "0inw76pm8kcidh0lq7gm3c3bh8v6yps0z7j6ar617b8wf730w1im";
   };
 
-  nativeBuildInputs = [ pkgconfig docutils ];
+  nativeBuildInputs = [ pkgconfig docutils removeReferencesTo ];
   buildInputs = [ varnish python ];
 
+  postInstall = "find $out -type f -exec remove-references-to -t ${varnish.dev} '{}' +"; # varnish.dev captured only as __FILE__ in assert messages
+
   meta = with stdenv.lib; {
     description = "Collection of Varnish Cache modules (vmods) by Varnish Software";
     homepage = https://github.com/varnish/varnish-modules;