guix.scm 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. (use-modules (guix)
  2. (guix build-system cmake)
  3. (guix build-system gnu)
  4. (guix gexp)
  5. (guix git)
  6. (guix git-download)
  7. ((guix licenses) #:prefix license:)
  8. (guix packages)
  9. (gnu packages autotools)
  10. (gnu packages base)
  11. (gnu packages bash)
  12. (gnu packages gawk)
  13. (gnu packages glib)
  14. (gnu packages guile)
  15. (gnu packages guile-xyz)
  16. (gnu packages icu4c)
  17. (gnu packages llvm)
  18. (gnu packages ninja)
  19. (gnu packages pkg-config)
  20. (gnu packages perl)
  21. (gnu packages python)
  22. (gnu packages texinfo)
  23. (gnu packages version-control))
  24. (define guile-next-next
  25. (let ((commit "d7cf5bf373392a18e9a4de06f751eae3d66ce1af")
  26. (revision "1"))
  27. (package
  28. (inherit guile-next)
  29. (version (git-version "3.0.9" revision commit))
  30. (source
  31. (origin
  32. (method git-fetch)
  33. (uri (git-reference
  34. (url "https://git.savannah.gnu.org/git/guile.git")
  35. (commit commit)))
  36. (file-name (git-file-name "guile" version))
  37. (sha256
  38. (base32 "05irlc0q7jlx5n5c7xm3cd35azgwyngkdzf46ngs1alnlxibc6kh")))))))
  39. (define gn
  40. (let ((commit "991530ce394efb58fcd848195469022fa17ae126")
  41. (revision "1"))
  42. (package
  43. (name "gn")
  44. (version (git-version "0" revision commit))
  45. (source
  46. (origin
  47. (method git-fetch)
  48. (uri (git-reference
  49. (url "https://gn.googlesource.com/gn.git")
  50. (commit commit)))
  51. (file-name (git-file-name name version))
  52. (sha256
  53. (base32 "1zpbaspb2mncbsabps8n1iwzc67nhr79ndc9dnqxx1w1qfvaldg2"))))
  54. (build-system gnu-build-system)
  55. (arguments
  56. (list #:tests? #f
  57. #:phases
  58. #~(modify-phases %standard-phases
  59. (replace 'configure
  60. (lambda _
  61. ;; The build system inspects the git history and
  62. ;; parses the output of "git describe" and
  63. ;; assumes that the current state of the repo is
  64. ;; at least one commit past the "initial-commit"
  65. ;; tag. Oof!
  66. (invoke "git" "init")
  67. (invoke "git" "config" "user.name" "Guix")
  68. (invoke "git" "config" "user.email" "guix@guix.gnu.org")
  69. (invoke "git" "add" "README.md")
  70. (invoke "git" "commit" "-m" "Initial commit.")
  71. (invoke "git" "tag" "--annotate" "--message=Initial commit."
  72. "initial-commit")
  73. (invoke "git" "add" "LICENSE")
  74. (invoke "git" "commit" "-m" "Second commit.")
  75. (invoke "./build/gen.py")))
  76. (replace 'build
  77. (lambda _
  78. (invoke "ninja" "-C" "out")))
  79. (replace 'install
  80. (lambda* (#:key outputs #:allow-other-keys)
  81. (let* ((out (assoc-ref outputs "out"))
  82. (bin (string-append out "/bin")))
  83. (mkdir-p bin)
  84. (install-file "out/gn" bin)))))))
  85. (native-inputs (list clang git ninja python))
  86. (home-page "https://gn.googlesource.com/gn/")
  87. (synopsis "Google's Ninja wrapper")
  88. (description "GN is Google's wrapper around the Ninja build system.")
  89. (license license:bsd-3))))
  90. (define-syntax-rule (define-chromium-origin name path commit-sha hash)
  91. (define name
  92. (let ((commit commit-sha))
  93. (origin
  94. (method git-fetch)
  95. (uri (git-reference
  96. (url (string-append "https://chromium.googlesource.com/"
  97. path
  98. ".git"))
  99. (commit commit)))
  100. (file-name (git-file-name (symbol->string 'name) "0"))
  101. (sha256
  102. (base32 hash))))))
  103. ;; Based on the dependencies listed in the DEPS file in the v8 repo.
  104. (define-chromium-origin depot-tools
  105. "chromium/tools/depot_tools"
  106. "4c1d6d90bc4326377ce670b74735029db9acde6a"
  107. "1ydr05wdc52brzvpmj5gyyxf18fqiw7yfw691ia1c49b48a77y1p")
  108. (define-chromium-origin buildtools
  109. "chromium/src/buildtools"
  110. "ece39eb658cb3e839b5b63d5e311d72252047969"
  111. "190kb66r1pcl7m2ha89irv06ls17y3fw0jfz3bdgfrvbbsrgx71m")
  112. (define-chromium-origin chromium-build
  113. "chromium/src/build"
  114. "1f9a9ca7591f832a64ca2433efaf3d6f4ea4c0ec"
  115. "0950v5an04c223ld4l5pfw5wlrmmwcdgghr6nnq9acyb1g7585vh")
  116. (define-chromium-origin icu
  117. "chromium/deps/icu"
  118. "985b9a6f70e13f3db741fed121e4dcc3046ad494"
  119. "13rzzajqc4q1w4v9w7jx8bsmcbklngv7sa2lk2vcf22lvigkpnp9")
  120. (define-chromium-origin zlib
  121. "chromium/src/third_party/zlib"
  122. "3f0af7f1d5ca6bb9d247f40b861346627c3032a1"
  123. "0m4spq3670mkjsm9yl3ysz63zd1gqjd2dyzxd3l35nb03y1pr2jk")
  124. (define-chromium-origin googletest
  125. "external/github.com/google/googletest"
  126. "af29db7ec28d6df1c7f0f745186884091e602e07"
  127. "0f7g4v435xh830npqnczl851fac19hhmzqmvda2qs3fxrmq6712m")
  128. (define-chromium-origin trace-event
  129. "chromium/src/base/trace_event/common"
  130. "29ac73db520575590c3aceb0a6f1f58dda8934f6"
  131. "1c25i8gyz3z36gp192g3cshaj6rd6yxi6m7j8mhw7spaarprzq12")
  132. (define-chromium-origin jinja2
  133. "chromium/src/third_party/jinja2"
  134. "515dd10de9bf63040045902a4a310d2ba25213a0"
  135. "0gh8xpnbl9lq82ggxpv0q7a67pvcdmcrl7r8z3hk9awdjq4dbvvy")
  136. (define-chromium-origin markupsafe
  137. "chromium/src/third_party/markupsafe"
  138. "006709ba3ed87660a17bd4548c45663628f5ed85"
  139. "1ql3sdwjwc0b19hbz4v55m81sf3capl9xc5ya9nq1l7kclj72m06")
  140. (define-chromium-origin abseil-cpp
  141. "chromium/src/third_party/abseil-cpp"
  142. "7207ed23d56aa19796ffd08b8203f7af7f3b5f29"
  143. "1db5mh7j0im0wkn3hppq8zipr35lyx97h88xcj1n9kfkm1rwhd2l")
  144. ;; V8 uses the gold linker, so we need to wrap it in order for the
  145. ;; Guix runpath magic to work.
  146. (define ldwrapper-gold
  147. (make-ld-wrapper "gold-ldwrapper"
  148. #:binutils binutils-gold
  149. #:linker "ld.gold"))
  150. (define v8
  151. (let ((commit "155ea5ca7e6e04c6126cbc6e52183c3f24ba697e")
  152. (revision "1"))
  153. (package
  154. (name "v8")
  155. (version (git-version "11.7" revision commit))
  156. (source
  157. (origin
  158. (method git-fetch)
  159. (uri (git-reference
  160. (url "https://chromium.googlesource.com/v8/v8.git")
  161. (commit commit)))
  162. (file-name (git-file-name name version))
  163. (sha256
  164. (base32 "1sw8sb48cajamkzn86q0i4r0dvv10pxn15s4r79q0jsmzq7z4sag"))))
  165. (build-system gnu-build-system)
  166. (arguments
  167. (list #:tests? #f
  168. #:phases
  169. #~(modify-phases %standard-phases
  170. (add-before 'patch-source-shebangs 'install-depot-tools
  171. (lambda _
  172. ;; Install all the necessary submodules. The
  173. ;; DEPS file specifies many more than this but
  174. ;; these seem to the minimal set required for
  175. ;; what we're doing.
  176. (copy-recursively #$chromium-build "build")
  177. (copy-recursively #$buildtools "buildtools")
  178. (copy-recursively #$trace-event "base/trace_event/common")
  179. (copy-recursively #$depot-tools "third_party/depot_tools")
  180. (copy-recursively #$icu "third_party/icu")
  181. (copy-recursively #$zlib "third_party/zlib")
  182. (copy-recursively #$googletest "third_party/googletest/src")
  183. (copy-recursively #$jinja2 "third_party/jinja2")
  184. (copy-recursively #$markupsafe "third_party/markupsafe")
  185. (copy-recursively #$abseil-cpp "third_party/abseil-cpp")
  186. ;; Install Google's ninja wrapper executable.
  187. (install-file (string-append #$gn "/bin/gn")
  188. "buildtools/linux64")
  189. ;; Build fails if this file doesn't exist.
  190. (call-with-output-file "build/config/gclient_args.gni"
  191. (lambda (port) #t))
  192. ;; depot_tools need to be on PATH.
  193. (setenv "PATH"
  194. (string-append (getcwd)
  195. "/third_party/depot_tools:"
  196. (getenv "PATH")))))
  197. (replace 'configure
  198. (lambda _
  199. (define args
  200. ;; These flags are taken from the built-in
  201. ;; x64.release config:
  202. '("is_component_build = false"
  203. "is_debug = false"
  204. "target_cpu = \"x64\""
  205. "v8_enable_sandbox = true"
  206. "use_goma = false"
  207. "v8_enable_backtrace = true"
  208. "v8_enable_disassembler = true"
  209. "v8_enable_object_print = true"
  210. "v8_enable_verify_heap = true"
  211. "dcheck_always_on = false"
  212. ;; These flags are our custom ones:
  213. "is_official_build = false"
  214. ;; Build with GCC.
  215. "is_clang = false"
  216. ;; Don't use Google's libc++.
  217. "use_custom_libcxx = false"
  218. ;; Don't try to download a whole Debian
  219. ;; image, please. Thanks!
  220. "use_sysroot = false"
  221. ;; The build fails due to some warnings when
  222. ;; this flag is enabled.
  223. "treat_warnings_as_errors = false"))
  224. ;; There are some "fatal" messages that don't
  225. ;; actually appear to be fatal if this isn't a
  226. ;; git repo, but we just initialize one to be
  227. ;; safe.
  228. (invoke "git" "init")
  229. ;; Bootstrap the build system.
  230. (invoke "gn" "gen" "out/x64"
  231. (string-append "--args="
  232. (string-join args " ")))))
  233. (replace 'build
  234. (lambda _
  235. (invoke "ninja" "-C" "out/x64" "d8")))
  236. (replace 'install
  237. (lambda* (#:key outputs #:allow-other-keys)
  238. (let* ((out (assoc-ref outputs "out"))
  239. (bin (string-append out "/bin")))
  240. (mkdir-p bin)
  241. (install-file "out/x64/d8" bin)
  242. (install-file "out/x64/mksnapshot" bin)
  243. (install-file "out/x64/torque" bin)
  244. ;; d8 won't start without this.
  245. (install-file "out/x64/snapshot_blob.bin" bin))))
  246. ;; TODO: Runpath stuff isn't working properly even
  247. ;; though I'm using a wrapped linker!
  248. (delete 'validate-runpath))))
  249. (native-inputs (list git ldwrapper-gold ninja perl pkg-config python))
  250. (inputs (list glib))
  251. (home-page "https://v8.dev")
  252. (synopsis "V8 JavaScript/WASM engine.")
  253. (description "You should have had a V8.")
  254. (license license:bsd-3))))
  255. (package
  256. (name "guile-hoot")
  257. (version "0.1.0-git")
  258. (source (git-checkout (url (dirname (current-filename)))))
  259. (build-system gnu-build-system)
  260. (arguments
  261. '(#:make-flags '("GUILE_AUTO_COMPILE=0")))
  262. (native-inputs
  263. (list autoconf automake guile-syntax-highlight pkg-config texinfo))
  264. (inputs
  265. (list guile-next-next v8))
  266. (synopsis "WASM compiler for Guile Scheme")
  267. (description "Guile-hoot is an ahead-of-time WebAssembly compiler for GNU Guile.")
  268. (home-page "https://spritely.institute")
  269. (license (list license:asl2.0 license:lgpl3+)))