2019-09-11 19:43:19 +00:00
|
|
|
;;; GNU Guix --- Functional package management for GNU
|
|
|
|
;;; Copyright © 2019 Carl Dong <contact@carldong.me>
|
|
|
|
;;;
|
|
|
|
;;; This file is part of GNU Guix.
|
|
|
|
;;;
|
|
|
|
;;; GNU Guix is free software; you can redistribute it and/or modify it
|
|
|
|
;;; under the terms of the GNU General Public License as published by
|
|
|
|
;;; the Free Software Foundation; either version 3 of the License, or (at
|
|
|
|
;;; your option) any later version.
|
|
|
|
;;;
|
|
|
|
;;; GNU Guix is distributed in the hope that it will be useful, but
|
|
|
|
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;;; GNU General Public License for more details.
|
|
|
|
;;;
|
|
|
|
;;; You should have received a copy of the GNU General Public License
|
|
|
|
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
(define-module (gnu packages installers)
|
|
|
|
#:use-module ((guix licenses) #:prefix license:)
|
|
|
|
#:use-module (gnu packages)
|
|
|
|
#:use-module (gnu packages compression)
|
|
|
|
#:use-module (gnu packages cross-base)
|
|
|
|
#:use-module (gnu packages python-xyz)
|
|
|
|
#:use-module (guix packages)
|
|
|
|
#:use-module (guix download)
|
|
|
|
#:use-module (guix build-system scons)
|
|
|
|
#:use-module (guix utils))
|
|
|
|
|
2019-10-11 15:46:03 +00:00
|
|
|
(define (make-nsis machine target-arch nsis-target-type)
|
2019-10-22 15:09:46 +00:00
|
|
|
(let* ((triplet (string-append machine "-" "w64-mingw32"))
|
|
|
|
(xbinutils (cross-binutils triplet))
|
|
|
|
(xlibc (cross-libc triplet))
|
|
|
|
(xgcc (cross-gcc triplet #:libc xlibc)))
|
2019-09-11 19:43:19 +00:00
|
|
|
(package
|
|
|
|
(name (string-append "nsis-" machine))
|
2020-03-11 15:11:34 +00:00
|
|
|
(version "3.05")
|
2019-09-11 19:43:19 +00:00
|
|
|
(source (origin
|
|
|
|
(method url-fetch)
|
|
|
|
(uri (string-append "http://prdownloads.sourceforge.net/nsis/nsis-"
|
|
|
|
version "-src.tar.bz2"))
|
|
|
|
(sha256
|
|
|
|
(base32
|
2020-03-11 15:11:34 +00:00
|
|
|
"1sbwx5vzpddharkb7nj4q5z3i5fbg4lan63ng738cw4hmc4v7qdn"))
|
2021-05-29 05:28:10 +00:00
|
|
|
(patches (search-patches "nsis-env-passthru.patch"
|
|
|
|
"nsis-source-date-epoch.patch"))))
|
2019-09-11 19:43:19 +00:00
|
|
|
(build-system scons-build-system)
|
2019-10-22 15:09:46 +00:00
|
|
|
(native-inputs `(("xgcc" ,xgcc)
|
|
|
|
("xbinutils" ,xbinutils)
|
|
|
|
("mingw-w64" ,xlibc)))
|
2021-12-13 16:18:24 +00:00
|
|
|
(inputs (list zlib))
|
2019-09-11 19:43:19 +00:00
|
|
|
(arguments
|
|
|
|
`(#:scons ,scons-python2
|
|
|
|
#:modules ((srfi srfi-1)
|
2019-10-22 15:09:46 +00:00
|
|
|
(srfi srfi-26)
|
2019-09-11 19:43:19 +00:00
|
|
|
(guix build utils)
|
|
|
|
(guix build scons-build-system))
|
|
|
|
#:tests? #f
|
|
|
|
#:scons-flags `("UNICODE=yes"
|
|
|
|
"SKIPUTILS=MakeLangId,Makensisw,NSIS Menu,SubStart,zip2exe"
|
|
|
|
"SKIPDOC=COPYING"
|
|
|
|
"STRIP_CP=no"
|
|
|
|
,(string-append "PREFIX=" %output)
|
|
|
|
,(string-append "TARGET_ARCH=" ,target-arch)
|
|
|
|
,(string-append "XGCC_W32_PREFIX=" ,triplet "-")
|
|
|
|
,(string-append "PREFIX_PLUGINAPI_INC=" (assoc-ref %build-inputs "mingw-w64") "/include/")
|
|
|
|
,(string-append "PREFIX_PLUGINAPI_LIB=" (assoc-ref %build-inputs "mingw-w64") "/lib/"))
|
|
|
|
#:build-targets '("makensis"
|
|
|
|
"stubs"
|
|
|
|
"plugins"
|
|
|
|
"utils")
|
|
|
|
#:install-targets '("install-stubs"
|
|
|
|
"install-plugins"
|
|
|
|
"install-data"
|
|
|
|
"install-utils"
|
|
|
|
"install-compiler"
|
|
|
|
"install-conf")
|
|
|
|
#:phases (modify-phases %standard-phases
|
|
|
|
(add-before 'build 'fix-env
|
|
|
|
(lambda _
|
|
|
|
(define* (filter-delimited-string delimited-string predicate #:optional (delimiter #\:))
|
|
|
|
;; Given a DELIMITED-STRING delimited by DELIMITER,
|
|
|
|
;; only keep items that satisfy PREDICATE
|
|
|
|
(string-join
|
|
|
|
(filter predicate (string-split delimited-string delimiter))
|
|
|
|
(string delimiter)))
|
|
|
|
(define (mingw-path? path)
|
|
|
|
(string-prefix? (assoc-ref %build-inputs "mingw-w64") path))
|
|
|
|
(for-each
|
|
|
|
(lambda (env-name)
|
|
|
|
(let ((env-val (getenv env-name)))
|
|
|
|
;; Remove all mingw-w64 paths from env vars meant
|
|
|
|
;; for native toolchain
|
|
|
|
(setenv env-name
|
|
|
|
(filter-delimited-string env-val (negate mingw-path?)))
|
2021-02-03 20:21:31 +00:00
|
|
|
;; Add the removed paths back into CROSS_-prefixed
|
|
|
|
;; version of env vars
|
2019-09-11 19:43:19 +00:00
|
|
|
(setenv (string-append "CROSS_" env-name)
|
|
|
|
(filter-delimited-string env-val mingw-path?))))
|
2021-02-03 20:21:31 +00:00
|
|
|
'("C_INCLUDE_PATH" "CPLUS_INCLUDE_PATH" "LIBRARY_PATH"))
|
2019-10-22 15:09:46 +00:00
|
|
|
;; Hack to place mingw-w64 path at the end of search
|
|
|
|
;; paths. Could probably use a specfile and dirafter
|
2021-02-03 20:21:31 +00:00
|
|
|
(setenv "CROSS_C_INCLUDE_PATH"
|
|
|
|
(string-join
|
|
|
|
`(,@(map (cut string-append
|
|
|
|
(assoc-ref %build-inputs "xgcc")
|
|
|
|
"/lib/gcc/" ,triplet "/"
|
|
|
|
,(package-version xgcc) <>)
|
|
|
|
'("/include"
|
|
|
|
"/include-fixed"))
|
|
|
|
,(getenv "CROSS_C_INCLUDE_PATH"))
|
|
|
|
":"))
|
2019-10-22 15:09:46 +00:00
|
|
|
(setenv "CROSS_CPLUS_INCLUDE_PATH"
|
|
|
|
(string-join
|
|
|
|
`(,@(map (cut string-append (assoc-ref %build-inputs "xgcc") <>)
|
|
|
|
`("/include/c++"
|
|
|
|
,(string-append "/include/c++/" ,triplet)
|
|
|
|
"/include/c++/backward"
|
|
|
|
,@(map (cut string-append "/lib/gcc/" ,triplet "/" ,(package-version xgcc) <>)
|
|
|
|
'("/include"
|
|
|
|
"/include-fixed"))))
|
2021-02-03 20:21:31 +00:00
|
|
|
,(getenv "CROSS_CPLUS_INCLUDE_PATH"))
|
2019-10-22 15:09:46 +00:00
|
|
|
":"))))
|
2019-09-11 19:43:19 +00:00
|
|
|
(add-before 'build 'fix-target-detection
|
|
|
|
(lambda _
|
2021-02-03 20:21:31 +00:00
|
|
|
;; NSIS target detection is screwed up, manually change
|
|
|
|
;; it ourselves
|
2019-09-11 19:43:19 +00:00
|
|
|
(substitute* "Source/build.cpp" (("m_target_type=TARGET_X86ANSI")
|
|
|
|
(string-append "m_target_type=" ,nsis-target-type))))))))
|
2022-01-28 10:18:09 +00:00
|
|
|
(home-page "https://nsis.sourceforge.io/Main_Page")
|
2022-01-28 10:19:33 +00:00
|
|
|
(synopsis "System to create Windows installers")
|
2019-09-11 19:43:19 +00:00
|
|
|
(description
|
2022-01-28 10:19:33 +00:00
|
|
|
"NSIS (Nullsoft Scriptable Install System) is a system to create
|
|
|
|
Windows installers. It is designed to be as small and flexible as possible
|
|
|
|
and is therefore very suitable for internet distribution.")
|
2019-09-11 19:43:19 +00:00
|
|
|
(license (license:non-copyleft "file://COPYING"
|
|
|
|
"See COPYING in the distribution.")))))
|
|
|
|
|
|
|
|
(define-public nsis-x86_64
|
|
|
|
(make-nsis "x86_64" "amd64" "TARGET_AMD64"))
|
|
|
|
|
|
|
|
(define-public nsis-i686
|
|
|
|
(make-nsis "i686" "x86" "TARGET_X86UNICODE"))
|