Skip to content

Instantly share code, notes, and snippets.

@nothingmuch
Created July 25, 2020 21:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nothingmuch/44d0ad0408c338ec3ca327bef5d66444 to your computer and use it in GitHub Desktop.
Save nothingmuch/44d0ad0408c338ec3ca327bef5d66444 to your computer and use it in GitHub Desktop.
(define-public c-lightning
(package
(name "c-lightning")
(version "0.9.0rc3")
(source
(origin
(method git-fetch)
(uri (git-reference
(url "https://github.com/ElementsProject/lightning.git")
(commit (string-append "v" version))
(recursive? #t)))
(sha256
(base32
;; should be 19pp28h7n07ybix0j7xwk7fqpsmzs0d1dnqiagasrhwr5g70q3sy
"08spadqk4ic3cz7wl2slndc216axj6h4pgd1rcmzdviwj7bs4f24"))))
(build-system gnu-build-system)
(arguments
`(#:phases
(modify-phases %standard-phases
(add-after 'bootstrap 'bootstrap-external
(lambda _
;; bootstrap external source to ensure generated scripts are
;; patched during standard phase
(with-directory-excursion "external/libwally-core"
(invoke (which "bash") "./tools/autogen.sh"))
;; and prevent it from being rerun during build phase
(substitute* "external/Makefile"
(("&& ./tools/autogen.sh &&") "&&"))))
(add-before 'configure 'patch-source-files-some-more
(lambda _
(substitute* "configure"
(("\\$\\(which \\$p\\)") "$(command -v)"))
;; version is normally set using git describe
(substitute* "Makefile"
(("VERSION=.*") ,(string-append "VERSION=v" version)))
#t))
;; c-lightning has a custom ./configure script, these are just the
;; relevant parts of the gnu-build-system configure phase
(replace 'configure
(lambda* (#:key build target native-inputs inputs outputs
(configure-flags '()) out-of-source?
#:allow-other-keys)
(let* ((prefix (assoc-ref outputs "out"))
(bash (which "bash"))
(flags `(,(string-append "--prefix=" prefix)
"CC=gcc"
,@configure-flags))
(abs-srcdir (getcwd))
(srcdir (if out-of-source?
(string-append "../" (basename abs-srcdir))
".")))
(format #t "source directory: ~s (relative from build: ~s)~%"
abs-srcdir srcdir)
(if out-of-source?
(begin
(mkdir "../build")
(chdir "../build")))
(format #t "build directory: ~s~%" (getcwd))
(format #t "configure flags: ~s~%" flags)
;; required for libwally configuration
(if build (setenv "BUILD" build))
(setenv "CONFIG_SHELL" bash)
(setenv "PYTHON_VERSION" "3")
(apply invoke bash
(string-append srcdir "/configure")
flags))))
;; many python packages required for integration tests
(delete 'check))))
(native-inputs
`(("autoconf" ,autoconf)
("automake" ,automake)
("libtool" ,libtool)
("python" ,python)
("python-mako" ,python-mako)))
(inputs
`(("gmp" ,gmp)
("sqlite" ,sqlite)
("zlib" ,zlib)
("libsodium" ,libsodium)))
(synopsis "a Lightning Network implementation in C ")
(description "c-lightning is a standard compliant implementation of the
Lightning Network protocol. The Lightning Network is a scalability solution for
Bitcoin, enabling secure and instant transfer of funds between any two parties
for any amount.")
(home-page "https://github.com/ElementsProject/lightning")
(license (list license:expat license:cc0 license:lgpl2.1 license:lgpl3))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment