all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH] gnu: Add varnish.
@ 2016-11-27 10:34 Marius Bakke
  2016-11-27 15:11 ` Ricardo Wurmus
  0 siblings, 1 reply; 4+ messages in thread
From: Marius Bakke @ 2016-11-27 10:34 UTC (permalink / raw)
  To: guix-devel; +Cc: Marius Bakke

* gnu/packages/web.scm (varnish): New variable.
---
 gnu/packages/web.scm | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 79 insertions(+)

diff --git a/gnu/packages/web.scm b/gnu/packages/web.scm
index 753a816..b1313ee 100644
--- a/gnu/packages/web.scm
+++ b/gnu/packages/web.scm
@@ -49,6 +49,7 @@
   #:use-module (guix build-system python)
   #:use-module (gnu packages)
   #:use-module (gnu packages apr)
+  #:use-module (gnu packages base)
   #:use-module (gnu packages documentation)
   #:use-module (gnu packages docbook)
   #:use-module (gnu packages autotools)
@@ -58,14 +59,17 @@
   #:use-module (gnu packages bison)
   #:use-module (gnu packages flex)
   #:use-module (gnu packages mit-krb5)
+  #:use-module (gnu packages gcc)
   #:use-module (gnu packages gd)
   #:use-module (gnu packages gettext)
   #:use-module (gnu packages glib)
   #:use-module (gnu packages gnome)
   #:use-module (gnu packages gperf)
+  #:use-module (gnu packages graphviz)
   #:use-module (gnu packages gtk)
   #:use-module (gnu packages icu4c)
   #:use-module (gnu packages image)
+  #:use-module (gnu packages jemalloc)
   #:use-module (gnu packages lua)
   #:use-module (gnu packages ncurses)
   #:use-module (gnu packages base)
@@ -77,6 +81,7 @@
   #:use-module (gnu packages xml)
   #:use-module (gnu packages curl)
   #:use-module (gnu packages perl)
+  #:use-module (gnu packages readline)
   #:use-module (gnu packages texinfo)
   #:use-module (gnu packages textutils)
   #:use-module (gnu packages tls)
@@ -3867,3 +3872,77 @@ useful for users behind restrictive firewalls.  As long as Web traffic is
 allowed, even through a HTTP-only proxy, httptunnel can be combined with other
 tools like SSH (Secure Shell) to reach the outside world.")
     (license l:gpl2+)))
+
+(define-public varnish
+  (package
+    (name "varnish")
+    (version "5.0.0")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "https://repo.varnish-cache.org/source/varnish-"
+                                  version ".tar.gz"))
+              (sha256
+               (base32
+                "0jizha1mwqk42zmkrh80y07vfl78mg1d9pp5w83qla4xn9ras0ai"))))
+    (build-system gnu-build-system)
+    (arguments
+     `(#:configure-flags (list (string-append "LDFLAGS=-Wl,-rpath=" %output "/lib")
+                               ;; Use absolute path of GCC so it's found at runtime.
+                               (string-append "PTHREAD_CC="
+                                              (assoc-ref %build-inputs "gcc")
+                                              "/bin/gcc")
+                               "--localstatedir=/var")
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'patch-/bin/sh
+           (lambda _
+             (substitute* '("bin/varnishtest/vtc_varnish.c"
+                            "bin/varnishtest/vtc_process.c"
+                            "bin/varnishd/mgt/mgt_vcc.c")
+               (("/bin/sh") (which "sh")))
+             #t))
+         (add-after 'configure 'patch-Makefile
+           (lambda _
+             (substitute* "Makefile"
+               ;; Do not create /var/varnish during install.
+               (("^install-data-am: install-data-local") "install-data-am: "))
+             #t))
+         (add-after 'install 'wrap-binary
+           (lambda* (#:key inputs outputs #:allow-other-keys)
+             (let* ((out (assoc-ref outputs "out"))
+                    (varnishd (string-append out "/sbin/varnishd"))
+                    (PATH (string-append (assoc-ref inputs "binutils") "/bin"))
+                    (LIBRARY_PATH (string-append (assoc-ref inputs "glibc") "/lib")))
+               ;; Add binutils to PATH so gcc finds the 'as' executable.
+               (wrap-program varnishd
+                 `("PATH" ":" prefix (,PATH)))
+               ;; Without this, we get an error such as "ld: cannot find crti.o"
+               ;; when compiling VCL.
+               (wrap-program varnishd
+                 `("LIBRARY_PATH" ":" prefix (,LIBRARY_PATH)))
+               #t))))))
+    (native-inputs
+     `(("pkg-config" ,pkg-config)
+       ("rst2man" ,python-docutils)))
+    (inputs
+     `(("binutils" ,binutils)
+       ("gcc" ,gcc)
+       ("glibc" ,glibc/linux)
+       ("jemalloc" ,jemalloc)
+       ("ncurses" ,ncurses)
+       ("pcre" ,pcre)
+       ("python" ,python-wrapper)
+       ("readline" ,readline)))
+    (home-page "https://www.varnish-cache.org/")
+    (synopsis "High-performance caching HTTP reverse proxy")
+    (description
+     "Varnish is a web application accelerator.  It acts as a caching
+reverse proxy and load balancer.  You install it in front of any server
+that speaks HTTP and configure it to cache the contents through an
+extensive configuration language.")
+    (license (list l:bsd-2           ; Main distribution.
+                   l:zlib            ; lib/libvgz/*
+                   l:public-domain   ; bin/varnishncsa/as64.c, include/miniobj.h
+                   l:bsd-3           ; include/vqueue.h, lib/libvarnishcompat/daemon.c
+                   l:expat           ; doc/html/_static/underscore.js
+                   l:gpl2+))))       ; doc/html/_static/jquery.js is dual MIT/GPL2+
-- 
2.10.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] gnu: Add varnish.
  2016-11-27 10:34 [PATCH] gnu: Add varnish Marius Bakke
@ 2016-11-27 15:11 ` Ricardo Wurmus
  2016-11-27 20:24   ` Marius Bakke
  0 siblings, 1 reply; 4+ messages in thread
From: Ricardo Wurmus @ 2016-11-27 15:11 UTC (permalink / raw)
  To: Marius Bakke; +Cc: guix-devel

Marius Bakke <mbakke@fastmail.com> writes:

> * gnu/packages/web.scm (varnish): New variable.

[…]

> +         (add-after 'install 'wrap-binary
> +           (lambda* (#:key inputs outputs #:allow-other-keys)
> +             (let* ((out (assoc-ref outputs "out"))
> +                    (varnishd (string-append out "/sbin/varnishd"))
> +                    (PATH (string-append (assoc-ref inputs "binutils") "/bin"))
> +                    (LIBRARY_PATH (string-append (assoc-ref inputs "glibc") "/lib")))
> +               ;; Add binutils to PATH so gcc finds the 'as' executable.
> +               (wrap-program varnishd
> +                 `("PATH" ":" prefix (,PATH)))
> +               ;; Without this, we get an error such as "ld: cannot find crti.o"
> +               ;; when compiling VCL.
> +               (wrap-program varnishd
> +                 `("LIBRARY_PATH" ":" prefix (,LIBRARY_PATH)))
> +               #t))))))

What is VCL?  Is it always compiled from scratch at runtime?

> +    (inputs
> +     `(("binutils" ,binutils)
> +       ("gcc" ,gcc)
> +       ("glibc" ,glibc/linux)

These three inputs are implicitly available as native inputs when using
the gnu-build-system.  Should varnish get a gcc-toolchain as a runtime
input instead of these three separate inputs?

> +       ("jemalloc" ,jemalloc)
> +       ("ncurses" ,ncurses)
> +       ("pcre" ,pcre)
> +       ("python" ,python-wrapper)
> +       ("readline" ,readline)))
> +    (home-page "https://www.varnish-cache.org/")
> +    (synopsis "High-performance caching HTTP reverse proxy")
> +    (description
> +     "Varnish is a web application accelerator.  It acts as a caching
> +reverse proxy and load balancer.  You install it in front of any server
> +that speaks HTTP and configure it to cache the contents through an
> +extensive configuration language.")
> +    (license (list l:bsd-2           ; Main distribution.
> +                   l:zlib            ; lib/libvgz/*
> +                   l:public-domain   ; bin/varnishncsa/as64.c, include/miniobj.h
> +                   l:bsd-3           ; include/vqueue.h, lib/libvarnishcompat/daemon.c
> +                   l:expat           ; doc/html/_static/underscore.js
> +                   l:gpl2+))))       ; doc/html/_static/jquery.js is dual MIT/GPL2+

Very nice!

-- 
Ricardo

GPG: BCA6 89B6 3655 3801 C3C6  2150 197A 5888 235F ACAC
http://elephly.net

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] gnu: Add varnish.
  2016-11-27 15:11 ` Ricardo Wurmus
@ 2016-11-27 20:24   ` Marius Bakke
  2016-12-01  9:02     ` Ricardo Wurmus
  0 siblings, 1 reply; 4+ messages in thread
From: Marius Bakke @ 2016-11-27 20:24 UTC (permalink / raw)
  To: Ricardo Wurmus; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 2124 bytes --]

Ricardo Wurmus <rekado@elephly.net> writes:

>> +         (add-after 'install 'wrap-binary
>> +           (lambda* (#:key inputs outputs #:allow-other-keys)
>> +             (let* ((out (assoc-ref outputs "out"))
>> +                    (varnishd (string-append out "/sbin/varnishd"))
>> +                    (PATH (string-append (assoc-ref inputs "binutils") "/bin"))
>> +                    (LIBRARY_PATH (string-append (assoc-ref inputs "glibc") "/lib")))
>> +               ;; Add binutils to PATH so gcc finds the 'as' executable.
>> +               (wrap-program varnishd
>> +                 `("PATH" ":" prefix (,PATH)))
>> +               ;; Without this, we get an error such as "ld: cannot find crti.o"
>> +               ;; when compiling VCL.
>> +               (wrap-program varnishd
>> +                 `("LIBRARY_PATH" ":" prefix (,LIBRARY_PATH)))
>> +               #t))))))
>
> What is VCL?  Is it always compiled from scratch at runtime?

VCL is the Varnish Configuration Language. The configuration file is
compiled at startup and when loading other configs at runtime. It is
also possible to have inline C code in the VCL.

>
>> +    (inputs
>> +     `(("binutils" ,binutils)
>> +       ("gcc" ,gcc)
>> +       ("glibc" ,glibc/linux)
>
> These three inputs are implicitly available as native inputs when using
> the gnu-build-system.  Should varnish get a gcc-toolchain as a runtime
> input instead of these three separate inputs?

How would this work? Importing (gnu packages commencement) in web.scm
causes a bunch of "unbound variable" errors, probably due to conflicting
package names.

The 'as' requirement is actually from gcc, which should preferably be
compiled with '--with-as=<absolute-path-of-binutils-as>' (but does not
currently have binutils as input). I was surprised it used 'ld', which
probably works as a side effect after wrapping the binutils PATH.

The "LIBRARY_PATH" hack should possibly be fixed in binutils as well.

A custom toolchain sounds like a cleaner approach than these two
workarounds since those quirks can be worked out there, but not sure how
to go about making it.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] gnu: Add varnish.
  2016-11-27 20:24   ` Marius Bakke
@ 2016-12-01  9:02     ` Ricardo Wurmus
  0 siblings, 0 replies; 4+ messages in thread
From: Ricardo Wurmus @ 2016-12-01  9:02 UTC (permalink / raw)
  To: Marius Bakke; +Cc: guix-devel


Marius Bakke <mbakke@fastmail.com> writes:

> Ricardo Wurmus <rekado@elephly.net> writes:
>
>>> +         (add-after 'install 'wrap-binary
>>> +           (lambda* (#:key inputs outputs #:allow-other-keys)
>>> +             (let* ((out (assoc-ref outputs "out"))
>>> +                    (varnishd (string-append out "/sbin/varnishd"))
>>> +                    (PATH (string-append (assoc-ref inputs "binutils") "/bin"))
>>> +                    (LIBRARY_PATH (string-append (assoc-ref inputs "glibc") "/lib")))
>>> +               ;; Add binutils to PATH so gcc finds the 'as' executable.
>>> +               (wrap-program varnishd
>>> +                 `("PATH" ":" prefix (,PATH)))
>>> +               ;; Without this, we get an error such as "ld: cannot find crti.o"
>>> +               ;; when compiling VCL.
>>> +               (wrap-program varnishd
>>> +                 `("LIBRARY_PATH" ":" prefix (,LIBRARY_PATH)))
>>> +               #t))))))
>>
>> What is VCL?  Is it always compiled from scratch at runtime?
>
> VCL is the Varnish Configuration Language. The configuration file is
> compiled at startup and when loading other configs at runtime. It is
> also possible to have inline C code in the VCL.
>
>>
>>> +    (inputs
>>> +     `(("binutils" ,binutils)
>>> +       ("gcc" ,gcc)
>>> +       ("glibc" ,glibc/linux)
>>
>> These three inputs are implicitly available as native inputs when using
>> the gnu-build-system.  Should varnish get a gcc-toolchain as a runtime
>> input instead of these three separate inputs?
>
> How would this work? Importing (gnu packages commencement) in web.scm
> causes a bunch of "unbound variable" errors, probably due to conflicting
> package names.
>
> The 'as' requirement is actually from gcc, which should preferably be
> compiled with '--with-as=<absolute-path-of-binutils-as>' (but does not
> currently have binutils as input). I was surprised it used 'ld', which
> probably works as a side effect after wrapping the binutils PATH.
>
> The "LIBRARY_PATH" hack should possibly be fixed in binutils as well.
>
> A custom toolchain sounds like a cleaner approach than these two
> workarounds since those quirks can be worked out there, but not sure how
> to go about making it.

Okay, thanks for explaining this.  About the problems with “as” and
“binutils” could you please also send a bug report to bug-guix@gnu.org?

-- 
Ricardo

GPG: BCA6 89B6 3655 3801 C3C6  2150 197A 5888 235F ACAC
http://elephly.net

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-12-01  9:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-27 10:34 [PATCH] gnu: Add varnish Marius Bakke
2016-11-27 15:11 ` Ricardo Wurmus
2016-11-27 20:24   ` Marius Bakke
2016-12-01  9:02     ` Ricardo Wurmus

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.