Mirai's Miscellaneous Misadventures

M45 / meta / guix.scm

1(use-modules
2	(guix packages)
3	(guix build-system meson)
4	((guix licenses) #:prefix license:)
5	(guix utils)
6	(gnu packages llvm)
7	(guix gexp)
8	(guix profiles)
9)
10
11; todo: remove when (or if) <https://github.com/mesonbuild/meson/pull/11862> is merged and lands on Guix
12(use-modules (gnu packages build-tools) (guix git-download))
13(define wasm-meson
14	(package/inherit meson
15		(source
16			(origin
17				(method git-fetch)
18				(uri
19					(git-reference
20						(url "https://github.com/mesonbuild/meson")
21						(commit "41eee7a7b5d633e6a89a132d172a6dc5ed8d90df")
22					)
23				)
24				(sha256 (base32 "0sxhli4hrl62kf6g5jd9rixwcr6y622dgmlxii9l5kqjdyjvgva7"))
25			)
26		)
27	)
28)
29
30(define mimimi
31	(package
32		(name "mimimi")
33		(version "MXX")
34		(license license:agpl3+)
35		(synopsis "a platforming game")
36		(description synopsis)
37		(home-page #f)
38		(source (local-file ".." "mimimi-source" #:recursive? #t))
39		(build-system meson-build-system)
40		(arguments
41			'(
42				#:build-type "release"
43				#:phases
44					(modify-phases %standard-phases
45						(add-before 'configure 'patch-mimimi
46							(lambda _
47								(if (file-exists? "meta/patches.tar")
48									(invoke "tar" "--strip-components=1" "-xf" "meta/patches.tar")
49								)
50								(if (directory-exists? "meta/patches")
51									(copy-recursively "meta/patches" ".")
52								)
53								(if (file-exists? "meta/patches.txt")
54									(invoke "patch" "-p1" "-i" "meta/patches.txt")
55								)
56							)
57						)
58					)
59			)
60		)
61	)
62)
63
64(define mimimi-wasm
65	(package/inherit mimimi
66		(name "mimimi-wasm")
67		(native-inputs (modify-inputs (package-native-inputs mimimi) (append clang-toolchain lld)))
68		(arguments
69			(substitute-keyword-arguments (package-arguments mimimi)
70				((#:meson meson #f) wasm-meson)
71				((#:configure-flags flags #~'()) #~(cons* "--cross-file=meta/wasm32.txt" "-Dengines=wasm" #$flags))
72				((#:phases phases #~%standard-phases)
73					#~(modify-phases #$phases
74						(replace 'configure
75							(lambda* (#:key outputs configure-flags build-type #:allow-other-keys)
76								(let*
77									(
78										(out (assoc-ref outputs "out"))
79										(args `(,(string-append "--prefix=" out) ,(string-append "--buildtype=" build-type) ,@configure-flags "../build"))
80									)
81									(apply invoke "meson" "setup" args)
82									(chdir "../build")
83								)
84							)
85						)
86					)
87				)
88			)
89		)
90	)
91)
92
93(packages->manifest (list mimimi mimimi-wasm))