projects/guix·blob javascript-team · refs

111 lines · 4.7 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2024 Noé Lopez <[email protected]>
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 appimage)
20 #:use-module ((guix licenses) #:prefix license:)
21 #:use-module (gnu packages base)
22 #:use-module (gnu packages c)
23 #:use-module (gnu packages compression)
24 #:use-module (gnu packages file-systems)
25 #:use-module (gnu packages linux)
26 #:use-module (gnu packages pkg-config)
27 #:use-module (gnu packages)
28 #:use-module (guix build-system gnu)
29 #:use-module (guix gexp)
30 #:use-module (guix git-download)
31 #:use-module (guix packages)
32 #:use-module (guix utils))
33
34(define-public appimage-type2-runtime
35 (let ((revision "1")
36 ;; No releases, just the latest commit.
37 (commit "caf24f9f712084686bfc24a70b75e50df0aefb9c"))
38 (package
39 (name "appimage-type2-runtime")
40 (version (git-version "continuous" revision commit))
41 (source
42 (origin
43 (method git-fetch)
44 (uri (git-reference
45 (url "https://github.com/AppImage/type2-runtime")
46 (commit commit)))
47 (file-name (git-file-name name version))
48 (sha256
49 (base32 "17z0byws3dp375wcyq5xwy5npqy7hslqw21n677dp38z4f940nzv"))))
50 (build-system gnu-build-system)
51 (arguments
52 (list
53 #:tests? #f ; No tests
54 #:make-flags
55 #~(list "-Csrc/runtime" "runtime"
56 (string-append "CC=" #$(cc-for-target))
57 (string-append
58 "CFLAGS=" "-I" #$(this-package-input "fuse") "/include/fuse3/"
59 " -DGIT_COMMIT='\"" "guix-" #$version "\"'"
60 " -D_FILE_OFFSET_BITS=64"
61 " -static"
62 " -Wno-int-conversion"))
63 #:modules
64 `((guix build gnu-build-system)
65 (guix build utils)
66 (ice-9 binary-ports))
67 #:phases
68 #~(modify-phases %standard-phases
69 (add-after 'unpack 'use-pkgconfig-flags
70 (lambda _
71 (substitute* "src/runtime/Makefile"
72 (("-lmimalloc")
73 "$(pkg-config --cflags mimalloc)"))))
74 (delete 'configure)
75 (replace 'install
76 (lambda _
77 (install-file "src/runtime/runtime"
78 (string-append #$output "/bin"))))
79 ;; Must be after all elf reliant phases. Used to identify the
80 ;; executable as an AppImage as per the specification.
81 (add-after 'make-dynamic-linker-cache 'set-magic-bytes
82 (lambda _
83 (let ((port (open (string-append #$output
84 "/bin/runtime")
85 (logior O_WRONLY))))
86 (seek port 8 SEEK_SET)
87 (put-bytevector port #vu8(#x41 #x49 #x02))
88 (close-port port)))))
89 #:disallowed-references
90 (list (this-package-input "squashfuse-for-appimage")
91 (this-package-input "fuse")
92 (gexp-input (this-package-input "zstd") "static")
93 (gexp-input (this-package-input "zlib") "static"))))
94 (native-inputs (list pkg-config))
95 ;; Only needed at build time.
96 (inputs (list `(,fuse "out")
97 `(,fuse "static")
98 mimalloc
99 squashfuse-for-appimage
100 `(,zstd "static")
101 `(,zlib "static")))
102 (synopsis "Runtime for executing AppImages")
103 (description "The runtime is the executable part of every AppImage. It mounts
104the payload via @acronym{FUSE} and executes the entrypoint, allowing users to run
105applications in a portable manner without the need for installation. This runtime
106ensures that the AppImage can access its bundled libraries and resources seamlessly,
107providing a consistent environment across different Linux distributions. In the
108absence of @acronym{FUSE}, the AppImage can still be started using the
109@option{--appimage-extract-and-run} flag.")
110 (home-page "https://github.com/AppImage/type2-runtime")
111 (license license:expat))))