gnu: ruby-pandoc-ruby: Use pandoc instead of ghc-pandoc.
[jackhill/guix/guix.git] / gnu / packages / installers.scm
CommitLineData
e214a220
CD
1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2019 Carl Dong <contact@carldong.me>
3;;;
4;;; This file is part of GNU Guix.
5;;;
6;;; GNU Guix is free software; you can redistribute it and/or modify it
7;;; under the terms of the GNU General Public License as published by
8;;; the Free Software Foundation; either version 3 of the License, or (at
9;;; your option) any later version.
10;;;
11;;; GNU Guix is distributed in the hope that it will be useful, but
12;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14;;; GNU General Public License for more details.
15;;;
16;;; You should have received a copy of the GNU General Public License
17;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
18
19(define-module (gnu packages installers)
20 #:use-module ((guix licenses) #:prefix license:)
21 #:use-module (gnu packages)
22 #:use-module (gnu packages compression)
23 #:use-module (gnu packages cross-base)
24 #:use-module (gnu packages python-xyz)
25 #:use-module (guix packages)
26 #:use-module (guix download)
27 #:use-module (guix build-system scons)
28 #:use-module (guix utils))
29
a7d03e96 30(define (make-nsis machine target-arch nsis-target-type)
21486743
CD
31 (let* ((triplet (string-append machine "-" "w64-mingw32"))
32 (xbinutils (cross-binutils triplet))
33 (xlibc (cross-libc triplet))
34 (xgcc (cross-gcc triplet #:libc xlibc)))
e214a220
CD
35 (package
36 (name (string-append "nsis-" machine))
cdf00cf7 37 (version "3.05")
e214a220
CD
38 (source (origin
39 (method url-fetch)
40 (uri (string-append "http://prdownloads.sourceforge.net/nsis/nsis-"
41 version "-src.tar.bz2"))
42 (sha256
43 (base32
cdf00cf7 44 "1sbwx5vzpddharkb7nj4q5z3i5fbg4lan63ng738cw4hmc4v7qdn"))
e214a220
CD
45 (patches (search-patches "nsis-env-passthru.patch"))))
46 (build-system scons-build-system)
21486743
CD
47 (native-inputs `(("xgcc" ,xgcc)
48 ("xbinutils" ,xbinutils)
49 ("mingw-w64" ,xlibc)))
e214a220
CD
50 (inputs `(("zlib" ,zlib)))
51 (arguments
52 `(#:scons ,scons-python2
53 #:modules ((srfi srfi-1)
21486743 54 (srfi srfi-26)
e214a220
CD
55 (guix build utils)
56 (guix build scons-build-system))
57 #:tests? #f
58 #:scons-flags `("UNICODE=yes"
59 "SKIPUTILS=MakeLangId,Makensisw,NSIS Menu,SubStart,zip2exe"
60 "SKIPDOC=COPYING"
61 "STRIP_CP=no"
62 ,(string-append "PREFIX=" %output)
63 ,(string-append "TARGET_ARCH=" ,target-arch)
64 ,(string-append "XGCC_W32_PREFIX=" ,triplet "-")
65 ,(string-append "PREFIX_PLUGINAPI_INC=" (assoc-ref %build-inputs "mingw-w64") "/include/")
66 ,(string-append "PREFIX_PLUGINAPI_LIB=" (assoc-ref %build-inputs "mingw-w64") "/lib/"))
67 #:build-targets '("makensis"
68 "stubs"
69 "plugins"
70 "utils")
71 #:install-targets '("install-stubs"
72 "install-plugins"
73 "install-data"
74 "install-utils"
75 "install-compiler"
76 "install-conf")
77 #:phases (modify-phases %standard-phases
78 (add-before 'build 'fix-env
79 (lambda _
80 (define* (filter-delimited-string delimited-string predicate #:optional (delimiter #\:))
81 ;; Given a DELIMITED-STRING delimited by DELIMITER,
82 ;; only keep items that satisfy PREDICATE
83 (string-join
84 (filter predicate (string-split delimited-string delimiter))
85 (string delimiter)))
86 (define (mingw-path? path)
87 (string-prefix? (assoc-ref %build-inputs "mingw-w64") path))
88 (for-each
89 (lambda (env-name)
90 (let ((env-val (getenv env-name)))
91 ;; Remove all mingw-w64 paths from env vars meant
92 ;; for native toolchain
93 (setenv env-name
94 (filter-delimited-string env-val (negate mingw-path?)))
95 ;; Add the removed paths back into
96 ;; CROSS_-prefixed version of env vars
97 (setenv (string-append "CROSS_" env-name)
98 (filter-delimited-string env-val mingw-path?))))
21486743
CD
99 '("CPATH" "LIBRARY_PATH"))
100 ;; Hack to place mingw-w64 path at the end of search
101 ;; paths. Could probably use a specfile and dirafter
102 (setenv "CROSS_CPLUS_INCLUDE_PATH"
103 (string-join
104 `(,@(map (cut string-append (assoc-ref %build-inputs "xgcc") <>)
105 `("/include/c++"
106 ,(string-append "/include/c++/" ,triplet)
107 "/include/c++/backward"
108 ,@(map (cut string-append "/lib/gcc/" ,triplet "/" ,(package-version xgcc) <>)
109 '("/include"
110 "/include-fixed"))))
111 ,(getenv "CROSS_CPATH"))
112 ":"))))
e214a220
CD
113 (add-before 'build 'fix-target-detection
114 (lambda _
115 ;; NSIS target detection is screwed up, manually
116 ;; change it ourselves
117 (substitute* "Source/build.cpp" (("m_target_type=TARGET_X86ANSI")
118 (string-append "m_target_type=" ,nsis-target-type))))))))
119 (home-page "http://nsis.sourceforge.net/")
120 (synopsis "A professional open source system to create Windows installers")
121 (description
122 "NSIS (Nullsoft Scriptable Install System) is a professional open
123source system to create Windows installers. It is designed to be as small and
124flexible as possible and is therefore very suitable for internet
125distribution.")
126 (license (license:non-copyleft "file://COPYING"
127 "See COPYING in the distribution.")))))
128
129(define-public nsis-x86_64
130 (make-nsis "x86_64" "amd64" "TARGET_AMD64"))
131
132(define-public nsis-i686
133 (make-nsis "i686" "x86" "TARGET_X86UNICODE"))