Le projet jouet mymathserver dépend de cpprestsdk qui est le point sensible à empaqueter car le code n'est pas très robuste. Pour s'en convaincre, il suffit d'aller faire un tour sur les issues GitHub.
Donc, il faut un peu tricoter avec la version de Boost.
Du côté de Guix, le paquet websocketpp est dans disponible après la bonne version de Boost. Donc on pourrait s'en sortir avec guix time-machine. Mais beaucoup de substituts ne sont plus disponibles donc il y aurait beaucoup de compilations à faire—ce qui n'est pas un problème en soi mais pas le but ici.
Bref! en plus du projet jouet mymathserver et de cpprestsdk comme dans l'article initial, j'ai "empaqueté" websocketpp et une vieille version de boost. Empaqueter est un bien grand mot puisque ce sont les vieux paquets dépoussiérés à coup de git show.
Finalement, on compare des pommes et des oranges puisque le tour d'horizon a été fait avec ce qui était facile pour Nix (2 paquets personnalisés) et donc dans une autre configuration, cela aurait été Nix qui aurait dû fournir plus de paquets personnalisés. Donc il faut s'arrêter après les 2 mêmes paquets, les 2 autres derniers sont juste là pour éviter de recompiler le monde entier.
Ceci dit, avec ces définitions, on est capable de reproduire la première partie.
Le fichier disons /tmp/test/linuxfr.scm contient les paquets personnalisés ci-dessous.
Pour tout construire, il faut faire:
guix build -L /tmp/test mymathserver
En terme de reproductibilité, si vous utilisez la time-machine :
vous devriez compiler au bit près la même chose que moi. Donc normalement, vous devriez avoir: /gnu/store/hqhsc61v4xpj1ld0dwvf8gabxr3x0dwc-mymathserver-0.1 comme résultat. Sinon, il ya une source de non-déterminisme.
Je ferai un autre commentaire pour donner l'équivalent des commandes. :-)
(define-module(linuxfr)#:use-module(guixdownload)#:use-module(guixgit-download)#:use-module(guixpackages)#:use-module(guixbuild-systemcmake);; boost#:use-module(guixbuild-systemgnu)#:use-module(gnupackages)#:use-module(gnupackagesperl)#:use-module(gnupackagespython)#:use-module(gnupackagesshells)#:use-module(gnupackagesicu4c)#:use-module(gnupackagestls)#:use-module(gnupackagescompression)#:use-module(gnupackagescheck))(define-publicmymathserver(package(name"mymathserver")(version"0.1")(source(origin(methodgit-fetch)(uri(git-reference(url"https://gitlab.com/nokomprendo/mymathserver")(commit(string-append "v"version))))(file-name(git-file-namenameversion))(sha256(base32"0vvq2z2pjdr7dm6s4d6a3ikp7lw391lk4mdlqd18rgmr2jqfhl0b"))))(build-systemcmake-build-system)(arguments'(#:tests?#f))(native-inputs`(("boost",boost-old)("cpprestsdk",cpprestsdk)("gtest",googletest)("openssl",openssl)))(synopsis"Toy example")(description"Nothing relevant")(home-page"https://gitlab.com/nokomprendo/mymathserver")(license#f)))(define-publiccpprestsdk(package(name"cpprestsdk")(version"v2.10.14")(source(origin(methodgit-fetch)(uri(git-reference(url"https://github.com/microsoft/cpprestsdk")(commitversion)))(file-name(git-file-namenameversion))(sha256(base32"0z1yblqszs7ig79l6lky02jmrs8zmpi7pnzns237p0w59pipzrvs"))))(build-systemcmake-build-system)(native-inputs`(("websocketpp",my-websocketpp)("boost",boost-old)("openssl",openssl)("zlib",zlib)))(arguments'(#:tests?#f;; Warnings not always addressed by upstream, see:;; https://github.com/microsoft/cpprestsdk/issues/724#:configure-flags'("-DWERROR=OFF")))(synopsis"C++ REST SDK by Microsoft")(description"The C++ REST SDK is a Microsoft project for cloud-basedclient-server communication in native code using a modern asynchronous C++ APIdesign. This project aims to help C++ developers connect to and interact withservices.")(home-page"https://github.com/microsoft/cpprestsdk")(license#f)));;;;;; End here. ;;; Below hack to build cpprestsdk with the correct versions;;; without rebuilding the world.;;;(define-publicmy-websocketpp(package(name"websocketpp")(version"0.8.1")(source(origin(methodgit-fetch)(uri(git-reference(url"https://github.com/zaphoyd/websocketpp.git")(commitversion)))(file-name(git-file-namenameversion))(sha256(base32"12ffczcrryh74c1xssww35ic6yiy2l2xgdd30lshiq9wnzl2brgy"))))(build-systemcmake-build-system)(native-inputs`(("boost",boost-old)("openssl",openssl)))(arguments'(#:configure-flags'("-DBUILD_TESTS=ON")#:phases(modify-phases%standard-phases(add-after'install'remove-tests(lambda*(#:keyoutputs#:allow-other-keys)(let* ((install-dir(assoc-refoutputs"out"))(bin-dir(string-append install-dir"/bin")))(delete-file-recursivelybin-dir)#t))))))(home-page"https://www.zaphoyd.com/websocketpp/")(synopsis"C++ library implementing the WebSocket protocol")(description"WebSocket++ is a C++ library that can be used to implementWebSocket functionality. The goals of the project are to provide a WebSocketimplementation that is simple, portable, flexible, lightweight, low level, andhigh performance.")(license#f)));license:bsd-3(define-publicboost-old(package(name"boost")(version"1.67.0")(source(origin(methodurl-fetch)(uri(string-append"mirror://sourceforge/boost/boost/"version"/boost_"(string-map(lambda (x)(if (eq? x#\.)#\_x))version)".tar.bz2"))(sha256(base32"1fmdlmkzsrd46wwk834jsi2ypxj68w2by0rfcg2pzrafk5rck116"))(patches'("/tmp/test/patches/boost-fix-icu-build.patch"))))(build-systemgnu-build-system)(inputs`(("icu4c",icu4c)("zlib",zlib)))(native-inputs`(("perl",perl)("python",python-2)("tcsh",tcsh)))(arguments`(#:tests?#f#:make-flags(list "threading=multi""link=shared";; Set the RUNPATH to $libdir so that the libs find each other.(string-append "linkflags=-Wl,-rpath="(assoc-ref%outputs"out")"/lib");; Boost's 'context' library is not yet supported on mips64, so;; we disable it. The 'coroutine' library depends on 'context',;; so we disable that too.,@(if (string-prefix?"mips64"(or (%current-target-system)(%current-system)))'("--without-context""--without-coroutine""--without-coroutine2")'()))#:phases(modify-phases%standard-phases(delete'bootstrap)(replace'configure(lambda*(#:keyinputsoutputs#:allow-other-keys)(let ((icu(assoc-refinputs"icu4c"))(out(assoc-refoutputs"out")))(substitute*'("libs/config/configure""libs/spirit/classic/phoenix/test/runtest.sh""tools/build/doc/bjam.qbk""tools/build/src/engine/execunix.c""tools/build/src/engine/Jambase""tools/build/src/engine/jambase.c")(("/bin/sh")(which"sh")))(setenv"SHELL"(which"sh"))(setenv"CONFIG_SHELL"(which"sh"))(invoke"./bootstrap.sh"(string-append "--prefix="out);; Auto-detection looks for ICU only in traditional;; install locations.(string-append "--with-icu="icu)"--with-toolset=gcc"))))(replace'build(lambda*(#:keymake-flags#:allow-other-keys)(apply invoke"./b2"(format#f"-j~a"(parallel-job-count))make-flags)))(replace'install(lambda*(#:keymake-flags#:allow-other-keys)(apply invoke"./b2""install"make-flags))))))(home-page"http://www.boost.org")(synopsis"Peer-reviewed portable C++ source libraries")(description"A collection of libraries intended to be widely useful, and usableacross a broad spectrum of applications.")(license#f)));; (license (license:x11-style "http://www.boost.org/LICENSE_1_0.txt";; "Some components have other similar licences."))
# Paquets pour Guix
Posté par zimoun . En réponse à la dépêche Gestion de paquets et DevOps avec Nix, tour d’horizon sur un cas concret. Évalué à 4. Dernière modification le 28 janvier 2020 à 19:08.
Le projet jouet
mymathserverdépend decpprestsdkqui est le point sensible à empaqueter car le code n'est pas très robuste. Pour s'en convaincre, il suffit d'aller faire un tour sur les issues GitHub.https://github.com/microsoft/cpprestsdk/issues
Donc, il faut un peu tricoter avec la version de Boost.
Du côté de Guix, le paquet
websocketppest dans disponible après la bonne version de Boost. Donc on pourrait s'en sortir avecguix time-machine. Mais beaucoup de substituts ne sont plus disponibles donc il y aurait beaucoup de compilations à faire—ce qui n'est pas un problème en soi mais pas le but ici.Bref! en plus du projet jouet
mymathserveret decpprestsdkcomme dans l'article initial, j'ai "empaqueté"websocketppet une vieille version deboost. Empaqueter est un bien grand mot puisque ce sont les vieux paquets dépoussiérés à coup degit show.Finalement, on compare des pommes et des oranges puisque le tour d'horizon a été fait avec ce qui était facile pour Nix (2 paquets personnalisés) et donc dans une autre configuration, cela aurait été Nix qui aurait dû fournir plus de paquets personnalisés. Donc il faut s'arrêter après les 2 mêmes paquets, les 2 autres derniers sont juste là pour éviter de recompiler le monde entier.
Ceci dit, avec ces définitions, on est capable de reproduire la première partie.
Le fichier disons
/tmp/test/linuxfr.scmcontient les paquets personnalisés ci-dessous.Pour tout construire, il faut faire:
En terme de reproductibilité, si vous utilisez la
time-machine:vous devriez compiler au bit près la même chose que moi. Donc normalement, vous devriez avoir:
/gnu/store/hqhsc61v4xpj1ld0dwvf8gabxr3x0dwc-mymathserver-0.1comme résultat. Sinon, il ya une source de non-déterminisme.Je ferai un autre commentaire pour donner l'équivalent des commandes. :-)