guix-env.scm: build gnunet with hardening.
[oweals/gnunet.git] / guix-env.scm
1 ;;; This file is part of GNUnet.
2 ;;; Copyright (C) 2016 GNUnet e.V.
3 ;;;
4 ;;; GNUnet is free software; you can redistribute it and/or modify
5 ;;; it under the terms of the GNU General Public License as published
6 ;;; by the Free Software Foundation; either version 3, or (at your
7 ;;; option) any later version.
8 ;;;
9 ;;; GNUnet is distributed in the hope that it will be useful, but
10 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
11 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 ;;; General Public License for more details.
13 ;;;
14 ;;; You should have received a copy of the GNU General Public License
15 ;;; along with GNUnet; see the file COPYING.  If not, write to the
16 ;;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 ;;; Boston, MA 02110-1301, USA.
18 ;;;
19 ;;;
20 ;;; Author: N. Gillmann <ngillmann@runbox.com>
21 ;;;
22 ;;; Parts borrowed here from pubstrate:
23 ;;; Pubstrate is distributed in the hope that it will be useful, but
24 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
25 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
26 ;;; General Public License for more details.
27 ;;;
28 ;;; You should have received a copy of the GNU General Public License
29 ;;; along with Pubstrate.  If not, see <http://www.gnu.org/licenses/>.
30 ;;;
31 ;;; Parts borrowed here from guile-sdl2:
32 ;;; Guile-sdl2 is distributed in the hope that it will be useful, but
33 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
34 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
35 ;;; General Public License for more details.
36 ;;;
37 ;;; You should have received a copy of the GNU Lesser General Public
38 ;;; License along with guile-sdl2.  If not, see
39 ;;; <http://www.gnu.org/licenses/>.
40
41 ;; Guix package for GNUnet development
42 ;;
43 ;; INSTALL
44 ;;
45 ;; To build and install the package in the user environment, use:
46 ;;
47 ;; .. to be documented
48 ;;
49 ;; BUILD ONLY
50 ;;
51 ;; Precondition for using this file is that you run Guix and have a
52 ;; development setup for this setup, which involves a version of Guile in
53 ;; your PATH.
54 ;;
55 ;; Simply run "guix build -f guix-env.scm"
56 ;;
57 ;; We'd like to provide advanced functions such as guix environment specific
58 ;; gnunet-svn package, but this is subject to tests right now.
59
60 (use-modules
61  (ice-9 popen)
62  (ice-9 match)
63  (ice-9 rdelim)
64  (guix packages)
65  (guix build-system gnu)
66  (guix gexp)
67  ((guix build utils) #:select (with-directory-excursion))
68  (gnu packages)
69  (gnu packages base)
70  (gnu packages gnunet)
71  (gnu packages file)
72  (gnu packages aidc)
73  (gnu packages autotools)
74  (gnu packages compression)
75  (gnu packages curl)
76  (gnu packages geeqie)
77  (gnu packages gettext)
78  (gnu packages glib)
79  (gnu packages gnome)
80  (gnu packages gnupg)
81  (gnu packages groff)
82  (gnu packages gtk)
83  (gnu packages guile)
84  (gnu packages gstreamer)
85  (gnu packages gnuzilla)
86  (gnu packages libidn)
87  (gnu packages linux)
88  (gnu packages image)
89  (gnu packages libunistring)
90  (gnu packages maths)
91  (gnu packages multiprecision)
92  (gnu packages pkg-config)
93  (gnu packages perl)
94  (gnu packages pulseaudio)
95  (gnu packages python)
96  (gnu packages databases)
97  (gnu packages tls)
98  (gnu packages tex)
99  (gnu packages video)
100  (gnu packages web)
101  (gnu packages xiph)
102  (gnu packages backup)
103  ((guix licenses) #:prefix license:))
104
105 (define %source-dir (dirname (current-filename)))
106
107 (define git-file?
108   (let* ((pipe (with-directory-excursion %source-dir
109                  (open-pipe* OPEN_READ "git" "ls-files")))
110          (files (let loop ((lines '()))
111                   (match (read-line pipe)
112                     ((? eof-object?)
113                      (reverse lines))
114                     (line
115                      (loop (cons line lines))))))
116          (status (close-pipe pipe)))
117     (lambda (file stat)
118       (match (stat:type stat)
119         ('directory #t)
120         ((or 'regular 'symlink)
121          (any (cut string-suffix? <> file) files))
122         (_ #f)))))
123
124 (define gnunet-git
125   (package
126     (name "gnunet-git")
127     (version (string-append "0.10.1-" "dev"))
128     (source
129      (local-file %source-dir
130                  #:recursive? #t))
131                  ;;#:select? git-file?)) ; XXX: FIXME.
132     (build-system gnu-build-system)
133     (inputs
134      `(("glpk" ,glpk)
135        ("gnurl" ,gnurl)
136        ("gstreamer" ,gstreamer)
137        ("gst-plugins-base" ,gst-plugins-base)
138        ("gnutls" ,gnutls)
139        ("libextractor" ,libextractor)
140        ("libgcrypt" ,libgcrypt)
141        ("libidn" ,libidn)
142        ("libmicrohttpd" ,libmicrohttpd)
143        ("libltdl" ,libltdl)
144        ("libunistring" ,libunistring)
145        ("openssl" ,openssl)
146        ("opus" ,opus)
147        ("pulseaudio" ,pulseaudio)
148        ("sqlite" ,sqlite)
149        ("postgresql" ,postgresql)
150        ("mysql" ,mysql)
151        ("zlib" ,zlib)
152        ("perl" ,perl)
153        ("python" ,python) ; tests and gnunet-qr
154        ("jansson" ,jansson)
155        ("nss" ,nss)
156        ("gmp" ,gmp)
157        ("bluez" ,bluez) ; for optional bluetooth feature
158        ("glib" ,glib)
159        ;; There are currently no binary substitutes for texlive on
160        ;; hydra.gnu.org or its mirrors due to its size. Uncomment if you need it.
161        ;;("texlive-minimal" ,texlive-minimal) ; optional.
162        ("libogg" ,libogg)))
163     (native-inputs
164      `(("pkg-config" ,pkg-config)
165        ("autoconf" ,autoconf)
166        ("automake" ,automake)
167        ("gnu-gettext" ,gnu-gettext)
168        ("libtool" ,libtool)))
169     ;; TODO:  To make use of out:debug, which carries the symbols,
170     ;; this file needs to fixed.
171     (outputs '("out" "debug"))
172     (arguments
173      `(#:configure-flags
174        (list (string-append "--with-nssdir=" %output "/lib")
175              "--enable-experimental"
176              ;; These appear to be "broken" on Guix, needs debugging.
177              "--enable-gcc-hardening"
178              "--enable-linker-hardening"
179              "--enable-logging=verbose"
180              "--enable-poisoning"
181              "CFLAGS=-ggdb -O0")
182        ;;#:parallel-tests? #f ; parallel building seems to fail
183        ;;#:tests? #f ; fail: test_gnunet_statistics.py
184        #:phases
185        ;; swap check and install phases and set paths to installed bin
186        (modify-phases %standard-phases
187          (add-after 'unpack 'patch-bin-sh
188            (lambda _
189              (substitute* "bootstrap"
190                (("contrib/pogen.sh") "sh contrib/pogen.sh"))
191              (for-each (lambda (f) (chmod f #o755))
192                        (find-files "po" ""))
193              #t))
194          (add-after 'patch-bin-sh 'bootstrap
195            (lambda _
196              (zero? (system* "sh" "bootstrap"))))
197          (delete 'check))))
198     ;; XXX: https://gnunet.org/bugs/view.php?id=4619
199     ;; (add-after 'install 'set-path-for-check
200     ;;   (lambda* (#:key outputs #:allow-other-keys)
201     ;;     (let* ((out (assoc-ref outputs "out"))
202     ;;            (bin (string-append out "/bin"))
203     ;;            (lib (string-append out "/lib")))
204     ;;       (setenv "GNUNET_PREFIX" lib)
205     ;;       (setenv "PATH" (string-append (getenv "PATH") ":" bin))
206     ;;       (zero? (system* "make" "check"))))))))
207     (synopsis "Secure, decentralized, peer-to-peer networking framework")
208     (description
209      "GNUnet is a framework for secure peer-to-peer networking.  The
210 high-level goal is to provide a strong foundation of free software for a
211 global, distributed network that provides security and privacy.  GNUnet in
212 that sense aims to replace the current internet protocol stack.  Along with
213 an application for secure publication of files, it has grown to include all
214 kinds of basic applications for the foundation of a GNU internet.")
215     (license license:gpl3+)
216     (home-page "https://gnunet.org/")))
217
218 gnunet-git