Red Nose Hacker

Do me a favor : hack for good :-)

#kata #tdd #testdrivendevelopment #guile #scheme #emacs #screencast

Guile Logo

Objectif de cette session : Continuer de s'exercer avec String rotations.
Illustrer un ré-usinage des tests et utiliser un peu plus les outils à disposition dans Emacs !

Bon screencast !

Je place le code à la suite pour ceux que ça intéresse :

(define-module (kata-3)
  #:use-module (srfi srfi-64))

(module-define! (resolve-module '(srfi srfi-64))
		'test-log-to-file #t)

(define EMPTY_STRING "")
(define DUMMY_1CHAR_STRING "a")

(define (rotations str)
  `(,str))

(test-begin "test-suite")

(define test-case-descriptions
  `(["empty-string" (,EMPTY_STRING) ,EMPTY_STRING]
    ["one-char-string" (,DUMMY_1CHAR_STRING) ,DUMMY_1CHAR_STRING]
    ["two-char-string" ("ab" "ba") "ab"]))

(define (test-equal-batch triples)
  (map (lambda (triple)
	 (let ([test-name (car triple)]
	       [expected-value (car (cdr triple))]
	       [effective-value (car (cddr triple))])
	   (test-equal test-name
	     expected-value
	     (rotations effective-value))))
       triples))

(test-equal-batch test-case-descriptions)

(test-end "test-suite")

Merci beaucoup d'avoir regardé ce screencast !

N'hésites pas à me donner ton avis, proposer une idée d'amélioration, laisser un commentaire, ou poser une question via :E-mail: jeremy AT korwin-zmijowski DOT frMastodon: @jeko@framapiaf.orgPeertube: @jeko@video.tedomum.netTwitter: @JeremyKorwin

Abonnes-toi pour ne pas manquer les prochains articles et épisodes:blog via Mastodon @jeko@write.as et RSSscreencast via Peertube @jeko@video.tedomum.net et RSS

Et encore plus important, partages le screencast et dis à tes amis que c'est le meilleur screencast de l'histoire du logiciel libre ! Sans dec'

Logo Guix

This serie of blog posts is an invitation to see how one can learn how to package software for Guix without prior knowledge about Guix or even software packaging. I show you what resources I need and how I use them. My method is driven by doing. The commands execution rhythms my iterations and its return guides the code to produce and the use of external resources (documentation, source code, community).

At the end of this serie, I would have packaged a simple piece of free software : ac-geiser, an extension of Emacs that brings a hint of self-completion to Geiser when I hack with the Guile language.

History :

In the Guix repository you've cloned in the first article of this serie, do the following :

$ git pull
$ guix environment --pure guix
[dev]$ ./bootstrap && ./configure --localstatedir=/var && make

You now have an up-to-date stuff.

I retrieve the last commands executed (the first one to create a package definition, the second to build the package according to the definition) :

$ echo '(use-modules (guix packages) (guix build-system emacs) (guix licenses) (guix git-download)) (package (name "") (version "") (source (origin (uri (git-reference (url "") (commit ""))) (method git-fetch) sha256)) (build-system emacs-build-system) (synopsis "") (description "") (license bsd-3) (home-page ""))' > /tmp/dummy-package-definition.scm
$ ./pre-inst-env guix build -f /tmp/dummy-package-definition.scm
/tmp/dummy-package-definition.scm:1:112: error: sha256: invalid field specifier

I have no idea how to specify the sha256 field. So I request documentation on this subject. Unfortunately, I can't find much information on how to use sha256, or how to define a bytevector in base 32 format. So I looked at the hello package example in the documentation to unlock me (it's the wildcard of the session). I can now change my definition accordingly.

$ echo '(use-modules (guix packages) (guix build-system emacs) (guix licenses) (guix git-download)) (package (name "") (version "") (source (origin (uri (git-reference (url "") (commit ""))) (method git-fetch) (sha256 (base32 "")))) (build-system emacs-build-system) (synopsis "") (description "") (license bsd-3) (home-page ""))' > /tmp/dummy-package-definition.scm
$ guix build -f /tmp/dummy-package-definition.scm
guix build: error: derivation `/gnu/store/diif4n2lx6s5g9qxrvpc9pshfyypwa6k-git-checkout.drv' has incorrect output `/gnu/store/7ygy97wz9d1zcbz3k2kg1ga9g389bd7b-git-checkout', should be `/gnu/store/0fd9p27axy1jdw7fv29fa8i3sa0vajbl-git-checkout'

This time, I don't use the pre-inst-env script as it seems to be broken for me (see my thread on the mailing list). Will see if I can fix it later... Anyway, here the Guix return message tells me Guix made a step forward to the build process. But it is not very explicit about what is missing or wrong. In the mailing list thread previously mentionned, Julien Lepiller said I have to specifiy a non-empty hash for the package (the base32 field). So let's specify it ! First, compute the expected hash with the help of the documentation !

$ cd /tmp
$ git clone https://github.com/xiaohanyu/ac-geiser.git
Clonage dans 'ac-geiser'...
remote: Enumerating objects: 20, done.
remote: Total 20 (delta 0), reused 0 (delta 0), pack-reused 20
Dépaquetage des objets: 100% (20/20), 148.08 Kio | 746.00 Kio/s, fait.
$ cd ac-geiser/
$ guix hash -rx .
0h2kakb4f5hgzf5l2kpqngalcmc4402lkg1pvs88c8z4rqp2vfvz

Now it is time to complete the package definition. I take this opportunity to fill all the fields I can (I want to create the package for ac-geiser).

$ echo \
'(use-modules 
   (guix packages)
   (guix build-system emacs)
   (guix licenses) 
   (guix git-download)) 
 (package 
   (name "emacs-ac-geiser") 
   (version "0.1") 
   (source 
     (origin 
       (uri (git-reference 
              (url "https://github.com/xiaohanyu/ac-geiser.git") 
              (commit "502d18a8a0bd4b5fdd495a99299ba2a632c5cd9a"))) 
       (method git-fetch) 
       (sha256 (base32 "0h2kakb4f5hgzf5l2kpqngalcmc4402lkg1pvs88c8z4rqp2vfvz"))))
   (build-system emacs-build-system) 
   (synopsis "Auto-complete backend for geiser")
   (description "Provides one auto-complete source for Scheme projects using geiser.")
   (license bsd-3) 
   (home-page "https://github.com/xiaohanyu/ac-geiser"))'\
> /tmp/dummy-package-definition.scm
$ guix build -f /tmp/dummy-package-definition.scm
[...]

With this, guix build is finally working ! The traces on console are too long to be fully copied here (so I created a Gist). It finishes with an error reported in a log :

[...]
Cannot open load file: No such file or directory, geiser
[...]

That make sense considering ac-geiser requires both geiser and auto-complete but I never specified it. In the documentation I found there are fields dedicated to this purpose. One fit exactly : propagated-inputs. Both geiser and auto-complete have their own Guix package. The commandsguix show emacs-geiser and guix show emacs-auto-complete tell me their are defined in the file gnu/packages/emacs-xyz.scm. So I edit my definition (not so dummy anymore) to bring them into it. I store it under /tmp/emacs-ac-geiser.scm :

(use-modules
 (guix packages)
 (guix build-system emacs)
 (guix licenses)
 (guix git-download)
 (gnu packages emacs-xyz))

(package
 (name "emacs-ac-geiser")
 (version "0.1")
 (source
  (origin
   (uri (git-reference
	 (url "https://github.com/xiaohanyu/ac-geiser.git")
	 (commit "502d18a8a0bd4b5fdd495a99299ba2a632c5cd9a")))
   (method git-fetch)
   (sha256 (base32 "0h2kakb4f5hgzf5l2kpqngalcmc4402lkg1pvs88c8z4rqp2vfvz"))))
 (build-system emacs-build-system)
 (propagated-inputs `(("geiser" ,emacs-geiser)
		      ("auto-complete" ,emacs-auto-complete)))
 (synopsis "Auto-complete backend for geiser")
 (description "Provides one auto-complete source for Scheme projects using geiser.")
 (license bsd-3)
 (home-page "https://github.com/xiaohanyu/ac-geiser"))

Et voilà !

$ guix build -f /tmp/emacs-ac-geiser.scm
[...]
construction de /gnu/store/2yz7ax3h5qwjg0i24kb65p5l8r8n5vh6-emacs-ac-geiser-0.1.drv réussie
/gnu/store/hp2jli29jchkdi50klzydrxqk72r3n2w-emacs-ac-geiser-0.1

Guix successfuly build the package according to my definition ! Yay \o/

It is a good place to stop. Next one will be for submitting the package to the Guix Project ! My first contribution ?!

Thank you so much for reading this article !

Don't hesitate to give me your opinion, leave a comment, or ask a question via :E-mail: jeremy AT korwin-zmijowski DOT frMastodon: @jeko@framapiaf.orgPeertube: @jeko@video.tedomum.netTwitter: @JeremyKorwin

Also, please subscribe so you don't miss the next ones :blog via Mastodon @jeko@write.as et RSSscreencast via Peertube @jeko@video.tedomum.net et RSS

And most importantly, share the blog and tell your friends it's the best blog in the history of Free Software! No shit!

#guix #package #english

Logo Guix

This serie of blog posts is an invitation to see how one can learn how to package software for Guix without prior knowledge about Guix or even software packaging. I show you what resources I need and how I use them. My method is driven by doing. The commands execution rhythms my iterations and its return guides the code to produce and the use of external resources (documentation, source code, community).

At the end of this serie, I would have packaged a simple piece of free software : ac-geiser, an extension of Emacs that brings a hint of self-completion to Geiser when I hack with the Guile language.

History :

In the Guix repository you've cloned in the first article of this serie, do the following :

$ git pull
$ guix environment --pure guix
[dev]$ ./bootstrap && ./configure --localstatedir=/var && make
$ exit

You now have an up-to-date stuff.

I retrieve the last commands executed (the first one to create a package definition, the second to build the package according to the definition):

$ echo '(use-modules (guix packages) (guix build-system emacs) (guix licenses)) (package (name "") (version "") (source origin) (build-system emacs-build-system) (synopsis "") (description "") (license bsd-3) (home-page ""))' > /tmp/dummy-package-definition.scm
$ ./pre-inst-env guix build -f /tmp/dummy-package-definition.scm
guix build: error: origin: source expression failed to match any pattern

Guix tells the following portion of the definition is problematic (source origin). I look at what the documentation explains about it... Effectively, origin is an object and not a symbol (as I specified it). I modify the definition to match with it :

$ echo '(use-modules (guix packages) (guix build-system emacs) (guix licenses)) (package (name "") (version "") (source (origin)) (build-system emacs-build-system) (synopsis "") (description "") (license bsd-3) (home-page ""))' > /tmp/dummy-package-definition.scm
$ ./pre-inst-env guix build -f /tmp/dummy-package-definition.scm
/tmp/dummy-package-definition.scm:1:112: error: (origin): missing field initializers (uri method sha256)

Guix tells me that the origin object consists of, at least, three required fields: (uri method sha256). I'm going to pass them to origin and see what Guix tells me :

$ echo '(use-modules (guix packages) (guix build-system emacs) (guix licenses)) (package (name "") (version "") (source (origin uri method sha256)) (build-system emacs-build-system) (synopsis "") (description "") (license bsd-3) (home-page ""))' > /tmp/dummy-package-definition.scm
$ ./pre-inst-env guix build -f /tmp/dummy-package-definition.scm
/tmp/dummy-package-definition.scm:1:112: error: uri: invalid field specifier

uri is not specified. I can see in the documentation this field is a string. Let's try this :

$ echo '(use-modules (guix packages) (guix build-system emacs) (guix licenses)) (package (name "") (version "") (source (origin (uri "") method sha256)) (build-system emacs-build-system) (synopsis "") (description "") (license bsd-3) (home-page ""))' > /tmp/dummy-package-definition.scm
$ ./pre-inst-env guix build -f /tmp/dummy-package-definition.scm
/tmp/dummy-package-definition.scm:1:112: error: method: invalid field specifier

Bingo, now I can move on to the second field: method. The documetation tells me that this is a procedure that will retrieve the sources of the software either from a URL or from a git repository. In my case, it will be a git repository. What the documentation also tells me is that for a git repository, uri must be a git-reference object and not a string as I specified in the previous step. I'll take it back before moving on to method.

$ echo '(use-modules (guix packages) (guix build-system emacs) (guix licenses)) (package (name "") (version "") (source (origin (uri (git-reference (url "") (commit ""))) method sha256)) (build-system emacs-build-system) (synopsis "") (description "") (license bsd-3) (home-page ""))' > /tmp/dummy-package-definition.scm
$ ./pre-inst-env guix build -f /tmp/dummy-package-definition.scm
/tmp/dummy-package-definition.scm:1:112: error: method: invalid field specifier

The construction of my uri field seems to suit Guix. Now, I will take care of the method field. The documentation tells me that method, in order to get the source of a program via git must be set to git-fetch from (guix git-download) module :

$ echo '(use-modules (guix packages) (guix build-system emacs) (guix licenses) (guix git-download)) (package (name "") (version "") (source (origin (uri (git-reference (url "") (commit ""))) (method git-fetch) sha256)) (build-system emacs-build-system) (synopsis "") (description "") (license bsd-3) (home-page ""))' > /tmp/dummy-package-definition.scm
$ ./pre-inst-env guix build -f /tmp/dummy-package-definition.scm
/tmp/dummy-package-definition.scm:1:112: error: sha256: invalid field specifier

Cool, the method field specification is OK for Guix.

But I'll stop here for today. I'll look into it in a future article. Here is the definition at this point:

(use-modules
 (guix packages)
 (guix build-system emacs)
 (guix licenses)
 (guix git-download))

(package
 (name "")
 (version "")
 (source
  (origin
   (uri (git-reference (url "") (commit "")))
   (method git-fetch) sha256))
 (build-system emacs-build-system)
 (synopsis "")
 (description "")
 (license bsd-3)
 (home-page ""))

Thank you so much for reading this article !

Don't hesitate to give me your opinion, leave a comment, or ask a question via :E-mail: jeremy AT korwin-zmijowski DOT frMastodon: @jeko@framapiaf.orgPeertube: @jeko@video.tedomum.netTwitter: @JeremyKorwin

Also, please subscribe so you don't miss the next ones :blog via Mastodon @jeko@write.as et RSSscreencast via Peertube @jeko@video.tedomum.net et RSS

And most importantly, share the blog and tell your friends it's the best blog in the history of Free Software! No shit!

#guix #package #english

Logo Guix

This serie of blog posts is an invitation to see how one can learn how to package software for Guix without prior knowledge about Guix or even software packaging. I show you what resources I need and how I use them. My method is driven by doing. The commands execution rhythms my iterations and its return guides the code to produce and the use of external resources (documentation, source code, community).

At the end of this serie, I would have packaged a simple piece of free software : ac-geiser, an extension of Emacs that brings a hint of self-completion to Geiser when I hack with the Guile language.

History :

In the Guix repository you've cloned in the first article of this serie, do the following :

$ git pull
$ guix environment --pure guix
[dev]$ ./bootstrap && ./configure --localstatedir=/var && make

You now have an up-to-date stuff.

I retrieve the last commands executed (the first one to create a package definition, the second to build the package according to the definition):

$ echo '(use-modules (guix packages) (guix build-system emacs)) (package (name "") (version "") (source origin) (build-system emacs-build-system) (synopsis "") (description "") license home-page)' > /tmp/dummy-package-definition.scm
$ ./pre-inst-env guix build -f /tmp/dummy-package-definition.scm
/tmp/dummy-package-definition.scm:1:56: error: license: invalid field specifier

So I stopped at the license field.

In the documentation, I find little information about how to specify the license field. I could see in the example given for the hello software the value gpl3+, but, for the moment, I'm looking for something closer to a null value, or the value that directly suits my case. I could try to tinker around (e.g. try bsd3) until I find the right value, but that wouldn't be scientific enough for my taste. So I decide to look in the source code. The documentation states that the license field must be valued (or specified) with the values from the (guix licenses) module. A little tour in the Guix git repository allows me to find the source file of this module, logically: guix/licenses.scm.

In the license module file, I see that the module exports the bsd-3 symbol (so it wasn't bsd3 haha), which would fit my package. So I'm going to modify the definition I'm building to import the (guix licenses) module so that I can specify the license field with the appropriate symbol :

$ echo '(use-modules (guix packages) (guix build-system emacs) (guix licenses)) (package (name "") (version "") (source origin) (build-system emacs-build-system) (synopsis "") (description "") (license bsd-3) home-page)' > /tmp/dummy-package-definition.scm
$ ./pre-inst-env guix build -f /tmp/dummy-package-definition.scm
/tmp/dummy-package-definition.scm:1:72: error: home-page: invalid field specifier

Guix doesn't return an error concerning the field I just modified, so I can go to the last field still unspecified: home-page. Easy, this one waits for a string.

$ echo '(use-modules (guix packages) (guix build-system emacs) (guix licenses)) (package (name "") (version "") (source origin) (build-system emacs-build-system) (synopsis "") (description "") (license bsd-3) (home-page ""))' > /tmp/dummy-package-definition.scm
$ ./pre-inst-env guix build -f /tmp/dummy-package-definition.scm
guix build: error: origin: source expression failed to match any pattern

Clearly, we are done specifying the mandatory fields of the package. The new error will make us go into the details of the source object, more precisely, the origin object that is used to value it.

But I'll stop here for today. I'll look into it in a future article. Here is the definition at this point:

(use-modules
 (guix packages)
 (guix build-system emacs)
 (guix licenses))

(package
 (name "")
 (version "")
 (source origin)
 (build-system emacs-build-system)
 (synopsis "")
 (description "")
 (license bsd-3)
 (home-page ""))

Thank you so much for reading this article !

Don't hesitate to give me your opinion, leave a comment, or ask a question via :E-mail: jeremy AT korwin-zmijowski DOT frMastodon: @jeko@framapiaf.orgPeertube: @jeko@video.tedomum.netTwitter: @JeremyKorwin

Also, please subscribe so you don't miss the next ones :blog via Mastodon @jeko@write.as et RSSscreencast via Peertube @jeko@video.tedomum.net et RSS

And most importantly, share the blog and tell your friends it's the best blog in the history of Free Software! No shit!

#guix #package #english

#kata #tdd #testdrivendevelopment #guile #scheme #emacs #screencast

Guile Logo

Objectif de cette session : répéter l'exercice en veillant à ne pas faire l'impasse sur le ré-usinage (refactoring) des tests.

Bon screencast !

Merci beaucoup d'avoir regardé ce screencast !

N'hésites pas à me donner ton avis, proposer une idée d'amélioration, laisser un commentaire, ou poser une question via :E-mail: jeremy AT korwin-zmijowski DOT frMastodon: @jeko@framapiaf.orgPeertube: @jeko@video.tedomum.netTwitter: @JeremyKorwin

Abonnes-toi pour ne pas manquer les prochains articles et épisodes:blog via Mastodon @jeko@write.as et RSSscreencast via Peertube @jeko@video.tedomum.net et RSS

Et encore plus important, partages le screencast et dis à tes amis que c'est le meilleur screencast de l'histoire du logiciel libre ! Sans dec'

Logo Guix

This serie of blog posts is an invitation to see how one can learn how to package software for Guix. Without prior knowledge about Guix or even software packaging, I show you what resources are needed and how to use them. My method is driven by doing. The commands execution rhythms my iterations and its return guides the code to produce and the use of external resources (documentation, source code, community).

In this article, I continue the work of the previous one.

In the Guix repository you've cloned in the first article of this serie, do the following :

$ git pull
$ guix environment --pure guix
[dev]$ ./bootstrap && ./configure --localstatedir=/var && make

You now have an up-to-date stuff.

I retrieve the last commands executed (the first one to create a package definition, the second to build the package according to the definition):

$ echo '(use-modules (guix packages)) (package (name "") (version "") source build-system synopsis description license home-page)' > /tmp/dummy-package-definition.scm
$ ./pre-inst-env guix build -f /tmp/dummy-package-definition.scm
/tmp/dummy-package-definition.scm:1:30: error: source: invalid field specifier

Right! The source field of the package object is incorrectly specified. How do you specify it? I don't know yet.

Lets have a look at the Guix documentation about it. I can read that the source field needs an `origin' object. Let's try this without looking further.

$ echo '(use-modules (guix packages)) (package (name "") (version "") (source origin) build-system synopsis description license home-page)' > /tmp/dummy-package-definition.scm
$ ./pre-inst-env guix build -f /tmp/dummy-package-definition.scm
/tmp/dummy-package-definition.scm:1:30: error: build-system: invalid field specifier

That seems enough for Guix concerning the source field. Now, Guix point the build-system field out. A little tour in the appropriate section in the documentation, where I learn this field needs to be specified with one of many build systems. One could be appropriate for my package so I'm trying it out : emacs-buid-system. I don't forget to add the (guix build-system emacs) dependency as specified in the documentation.

$ echo '(use-modules (guix packages) (guix build-system emacs)) (package (name "") (version "") (source origin) (build-system emacs-build-system) synopsis description license home-page)' > /tmp/dummy-package-definition.scm
$ ./pre-inst-env guix build -f /tmp/dummy-package-definition.scm
/tmp/dummy-package-definition.scm:1:56: error: synopsis: invalid field specifier

Guix isn't complaining, so I can move on to the next field: synopsis. The documentation doesn't specify what type of data is expected, but given the field name, I'll bet on a string.

$ echo '(use-modules (guix packages) (guix build-system emacs)) (package (name "") (version "") (source origin) (build-system emacs-build-system) (synopsis "") description license home-page)' > /tmp/dummy-package-definition.scm
$ ./pre-inst-env guix build -f /tmp/dummy-package-definition.scm

Ditto for description !

$ echo '(use-modules (guix packages) (guix build-system emacs)) (package (name "") (version "") (source origin) (build-system emacs-build-system) (synopsis "") (description "") license home-page)' > /tmp/dummy-package-definition.scm
$ ./pre-inst-env guix build -f /tmp/dummy-package-definition.scm
/tmp/dummy-package-definition.scm:1:56: error: license: invalid field specifier

No worries, Guix is still satisfied. In the next article, I will start by fixing the license field !

Here is the definition obtained at this point:

(use-modules
 (guix packages)
 (guix build-system emacs))

(package
 (name "")
 (version "")
 (source origin)
 (build-system emacs-build-system)
 (synopsis "")
 (description "")
 license
 home-page)

Thank you so much for reading this article !

Don't hesitate to give me your opinion, leave a comment, or ask a question via :E-mail: jeremy AT korwin-zmijowski DOT frMastodon: @jeko@framapiaf.orgPeertube: @jeko@video.tedomum.netTwitter: @JeremyKorwin

Also, please subscribe so you don't miss the next ones :blog via Mastodon @jeko@write.as et RSSscreencast via Peertube jeko@video.tedomum.net et RSS

And most importantly, share the blog and tell your friends it's the best blog in the history of Free Software! No shit!

#guix #package #english

#kata #tdd #testdrivendevelopment #guile #scheme #emacs #screencast

Guile Logo

Pour ce kata, j'ai choisi un exercice du site Programming Praxis : String Rotations.

Je choisi généralement de faire des sessions de 25 minutes. Pour ce kata, je n'avais pas d'objectif particulier autre que voir de quoi je suis capable avec les outils que j'utilise.

Bon screencast !

Merci beaucoup d'avoir regardé ce screencast ! N'hésites pas à me donner ton avis, proposer une idée d'amélioration, laisser un commentaire, ou poser une question via :E-mail: jeremy AT korwin-zmijowski DOT frMastodon: @jeko@framapiaf.orgPeertube: @jeko@video.tedomum.netTwitter: @JeremyKorwin

Abonnes-toi pour ne pas manquer les prochains articles et épisodes:blog via Mastodon @jeko@write.as et RSSscreencast via Peertube jeko@video.tedomum.net et RSS

Et encore plus important, partages le screencast et dis à tes amis que c'est le meilleur screencast de l'histoire du logiciel libre ! Sans dec'

Logo Guix

This serie of blog posts is an invitation to see how one can learn how to package software for Guix. Without prior knowledge about Guix or even software packaging, I show you what resources are needed and how to use them. My method is driven by doing. The commands execution rhythms my iterations and its return guides the code to produce and the use of external resources (documentation, source code, community). At the end of this serie, I would have packaged a simple piece of free software : ac-geiser, an extension of Emacs that brings a hint of self-completion to Geiser when I hack with the Guile language.

Before we get started, I want to talk to you about my style, yeah baby. I'm lazy. I like to do as little as possible. So I have a penchant for sobriety. I also like things tidy and clear. I only read documentation when I know what I'm looking for. Also, I like to do things on my own. Even when I find a shortcut, I will always take a step back to see how I could have figure it out by myself. But I don't like to waste my time. So I don't hesitate to approach the Guixters community once I admit my failure (not a pleasant feeling). Well, enough coming out. Let's get started !

To understand the following, you will need to be familiar with the syntax of the Guile programming language. I can suggest you to start with Mu Lei's Scheme tutorial as Guile is a Scheme implementation. To reproduce manipulations, you will need to have Guix installed. Here is a way to do so :

$ cd /tmp
$ wget https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh
$ chmod +x guix-install.sh
$ sudo ./guix-install.sh

Done, you think ? Hell no, haha. Because we are going to hack Guix itself, we need to download the Guix's source code and compile it. Then use the result as our main toolkit. Follow the guide ! (All these steps are decribed here)

$ git clone https://git.savannah.gnu.org/git/guix.git
$ cd guix
$ guix environment --pure guix
[dev]$ ./bootstrap # for [dev]$ see https://guix.gnu.org/manual/en/html_node/Invoking-guix-environment.html
[dev]$ ./configure --localstatedir=/var
[dev]$ make # coffee? tea? workout? meditation? poo?

If you encounter errors while executing these commands, you may need to ask for help to the Guixters Community, don't hesitate!

Fair enough.

What is a package, for Guix point of view ? According to the documentation, a Guix package is represented by an instanciation of the package Guile object.

How do I build a package definition ? Using... guix build ! It won't install anything on my system (good to know as I am pretty sure I will make a lot of mistakes). With the —file option, I can specify a package definition file as an input.

Remember to use the Guix binary (previously compiled) through the pre-inst-env script freshly generated. Lets try it once, to see what happen :

What if I just execute this :

$ ./pre-inst-env guix build

Well, nothing. What about :

$ ./pre-inst-env guix build -f
guix build: error: invalid argument: Missing required argument after `-f'

As expected, and now, I give it a filename :

$ ./pre-inst-env guix build -f /tmp/dummy-package-definition.scm
guix build: error: failed to load '/tmp/dummy-package-definition.scm': No such file or directory

Here, Guix is telling me the file in location /tmp/dummy-package-definition.scm doesn't exist. It is true, I didn't create that file yet. So what if I create the file and re-execute the guix build -f command :

$ touch /tmp/dummy-package-definition.scm
$ ./pre-inst-env guix build -f /tmp/dummy-package-definition.scm
guix build: error: #<unspecified>: not something we can build

Now there is a file, Guix tells me it is not buildable. Could be because the file doesn't have a package definition, I mean, a package object. Lets try that :

$ echo "(package)" > /tmp/dummy-package-definition.scm
$ ./pre-inst-env guix build -f /tmp/dummy-package-definition.scm 
/tmp/dummy-package-definition.scm:1:0: error: package: unbound variable
hint: Did you forget `(use-modules (guix packages))'?

Guix points out to me the variable package is unbound and suggest to me I how I can fix this error (so kind).

$ echo "(use-modules (guix packages)) (package)" > /tmp/dummy-package-definition.scm
$ ./pre-inst-env guix build -f /tmp/dummy-package-definition.scm
/tmp/dummy-package-definition.scm:1:30: error: (package): missing field initializers (name version source build-system synopsis description license home-page)

Another attempt, another mistake (but that's how you learn, isn't it?).

So, here, Guix tells me that the initialization of several fields is missing from (package) and tells me which ones. Did I mention that Guix is nice? I add the requested fields in my definition and I retry.

$ echo "(use-modules (guix packages)) (package name version source build-system synopsis description license home-page)" > /tmp/dummy-package-definition.scm
$ ./pre-inst-env guix build -f /tmp/dummy-package-definition.scm
/tmp/dummy-package-definition.scm:1:30: error: name: invalid field specifier

Ah, we're making progress (yeah, in my world, another error is what I call a new step) ! Now, Guix tells me that the name field is misspecified. Since I have no idea how name should be specified, I'm going to look up some information in the Guix documentation. It is so well done that there is a whole package reference page. I learn there that the name field is waiting for a string. OK !

$ echo '(use-modules (guix packages)) (package (name "") version source build-system synopsis description license home-page)' > /tmp/dummy-package-definition.scm
$ ./pre-inst-env guix build -f /tmp/dummy-package-definition.scm
/tmp/dummy-package-definition.scm:1:30: error: version: invalid field specifier

For version, same punishment!

$ echo '(use-modules (guix packages)) (package (name "") (version "") source build-system synopsis description license home-page)' > /tmp/dummy-package-definition.scm
$ ./pre-inst-env guix build -f /tmp/dummy-package-definition.scm
/tmp/dummy-package-definition.scm:1:30: error: source: invalid field specifier

I'll stop here for today. I'll look into the source field in the next article. Here is the definition obtained at this point:

(use-modules
 (guix packages))
(package
 (name "")
 (version "")
 source
 build-system
 synopsis
 description
 license
 home-page)

Thank you so much for reading this article !

Don't hesitate to give me your opinion, leave a comment, or ask a question via :E-mail: jeremy AT korwin-zmijowski DOT frMastodon: @jeko@framapiaf.orgPeertube: @jeko@video.tedomum.netTwitter: @JeremyKorwin

Subscribe so you don't miss the next ones :blog via Mastodon @jeko@write.as et RSSscreencast via Peertube jeko@video.tedomum.net et RSS

And most importantly, share the blog and tell your friends it's the best blog in the history of Free Software! No shit!

#guix #package #english

#guix #package #screencast #français Logo Guix

Cet article s'inscrit dans la lignée de ma série sur la découverte de l'empaquetage (communément appelé packaging) de logiciel pour le gestionnaire de paquet Guix. J'y documente ma façon d'apprendre. Tu peux y voir les difficultés auxquelles je fais face et les options que j'ai pour m'aider à les surmonter. Dans cet article, je poursuis le travail de l'article précédent.

Si tu préfères le format vidéo, je te met à disposition le screencast de cette session!

Pour démarrer cette nouvelle session de travail, je prend le réflexe de me placer dans un environnement de développement isolé :

$ guix environment --pure guix

Je reprends les commandes de la dernière étape de l'article précédent :

[dev]$ echo '(use-modules (guix packages) (guix build-system emacs) (guix licenses)) (define-public ac-geiser (package (name "") (version "") (source (origin (uri (git-reference (url "") (commit ""))) (method git-fetch) sha256)) (build-system emacs-build-system) (synopsis "") (description "") (license bsd-3) (home-page "")))' > /tmp/emacs-ac-geiser.scm
[dev]$ ./pre-inst-env guix build -f /tmp/emacs-ac-geiser.scm
/tmp/emacs-ac-geiser.scm:1:137: error: sha256: invalid field specifier

N'ayant aucune idée de comment spécifier sha256, je vais voir ce que me dit la documentation à ce sujet. Malheureusement, je ne trouve pas beaucoup d'informations sur comment utiliser sha256. J'ai donc regarder l'exemple du paquet hello de la documentation pour me débloquer (c'est le joker de la session). Je peux maintenant modifier ma définition en conséquence.

[dev]$ echo '(use-modules (guix packages) (guix build-system emacs) (guix licenses) (guix git-download)) (define-public ac-geiser (package (name "") (version "") (source (origin (uri (git-reference (url "") (commit ""))) (method git-fetch) (sha256 (base32 "")))) (build-system emacs-build-system) (synopsis "") (description "") (license bsd-3) (home-page "")))' > /tmp/emacs-ac-geiser.scm 
[dev]$ ./pre-inst-env guix build -f /tmp/emacs-ac-geiser.scm
guix build: error: #<unspecified>: not something we can build

Maintenant, Guix ne comprend plus rien. Je bloque, je réfléchis, le temps passe et j'arrive à la fin du temps imparti pour la session !

Je pense que la prochaine s'annonce déjà comme étant riche en action... Je solliciterai quand même l'aide de la communauté des Guixters pour comprendre ce qui ne va pas.

Voici la définition obtenue à ce stade :

(use-modules
 (guix packages)
 (guix build-system emacs)
 (guix licenses)
 (guix git-download))

(define-public ac-geiser
  (package
   (name "")
   (version "")
   (source
    (origin
     (uri
      (git-reference (url "") (commit "")))
     (method git-fetch)
     (sha256
      (base32 ""))))
   (build-system emacs-build-system)
   (synopsis "")
   (description "")
   (license bsd-3)
   (home-page "")))

Merci beaucoup d'avoir lu cet article ! N'hésites pas à me donner ton avis, proposer une idée d'amélioration, laisser un commentaire, ou poser une question via :E-mail: jeremy AT korwin-zmijowski DOT frMastodon: @jeko@framapiaf.orgPeertube: @jeko@video.tedomum.netTwitter: @JeremyKorwin Abonnes-toi pour ne pas manquer les prochains :articles via Mastodon @jeko@write.as et RSSscreencasts via Peertube jeko@video.tedomum.net et RSS

Et encore plus important, partages ce blog et dis à tes amis que c'est le meilleur blog de l'histoire du logiciel libre ! Sans dec'

#guix #package #screencast #français Logo Guix

Je documente ici la poursuite du travail de l'article précédent. Ces articles font partie d'une série sur l'empaquetage de logiciels pour le gestionnaire de paquet Guix.

Pour démarrer cette nouvelle session de travail, je me replace dans un environnement de développement isolé :

$ guix environment --pure guix

Je reprends les commandes de la dernière étape de l'article précédent :

[dev]$ echo '(use-modules (guix packages) (guix build-system emacs) (guix licenses)) (define-public ac-geiser (package (name "") (version "") (source origin) (build-system emacs-build-system) (synopsis "") (description "") (license bsd-3) (home-page "")))' > /tmp/emacs-ac-geiser.scm
[dev]$ ./pre-inst-env guix build -f /tmp/emacs-ac-geiser.scm
guix build: error: origin: source expression failed to match any pattern

À priori, cette portion de la définition pose problème (source origin). Je vais voir ce que me dit la documentation à ce sujet. Effectiovement, origin est un objet et pas un symbole. Je modifie la définition pour coller avec ça :

[dev]$ echo '(use-modules (guix packages) (guix build-system emacs) (guix licenses)) (define-public ac-geiser (package (name "") (version "") (source (origin)) (build-system emacs-build-system) (synopsis "") (description "") (license bsd-3) (home-page "")))' > /tmp/emacs-ac-geiser.scm
[dev]$ ./pre-inst-env guix build -f /tmp/emacs-ac-geiser.scm
/tmp/emacs-ac-geiser.scm:1:137: error: (origin): missing field initializers (uri method sha256)

Guix m'indique que l'objet origin est au moins constitué de trois champs obligatoires : (uri method sha256). Je vais les passer brutalement à origin et voir ce que Guix me dit :

[dev]$ echo '(use-modules (guix packages) (guix build-system emacs) (guix licenses)) (define-public ac-geiser (package (name "") (version "") (source (origin uri method sha256)) (build-system emacs-build-system) (synopsis "") (description "") (license bsd-3) (home-page "")))' > /tmp/emacs-ac-geiser.scm
[dev]$ ./pre-inst-env guix build -f /tmp/emacs-ac-geiser.scm
/tmp/emacs-ac-geiser.scm:1:137: error: uri: invalid field specifier

uri n'est pas spécifié. Je vais vérifier dans la documentation de origin comment spécifier ce champ. Il s'agit d'une chaîne de caractères. Essayons ça :

[dev]$ echo '(use-modules (guix packages) (guix build-system emacs) (guix licenses)) (define-public ac-geiser (package (name "") (version "") (source (origin (uri "") method sha256)) (build-system emacs-build-system) (synopsis "") (description "") (license bsd-3) (home-page "")))' > /tmp/emacs-ac-geiser.scm
[dev]$ ./pre-inst-env guix build -f /tmp/emacs-ac-geiser.scm
/tmp/emacs-ac-geiser.scm:1:137: error: method: invalid field specifier

Bingo, maintenant, je peux avancer avec le deuxième champ : method. La documetation me dit que c'est une procédure qui va récupérer les sources du logiciel soit depuis une URL, soit depuis un dépôt git. Dans mon cas, ce sera un dépôt git. Ce que me dit aussi la documentation, c'est que pour un dépôt git, uri doit être un objet git-reference et pas une chaîne de caratère comme je l'ai spécifié à l'étape d'avant. Je vais reprendre ça avant d'avancer sur method.

[dev]$ echo '(use-modules (guix packages) (guix build-system emacs) (guix licenses)) (define-public ac-geiser (package (name "") (version "") (source (origin (uri (git-reference (url "") (commit ""))) method sha256)) (build-system emacs-build-system) (synopsis "") (description "") (license bsd-3) (home-page "")))' > /tmp/emacs-ac-geiser.scm
[dev]$ ./pre-inst-env guix build -f /tmp/emacs-ac-geiser.scm
/tmp/emacs-ac-geiser.scm:1:137: error: method: invalid field specifier

La construction de mon uri semble convenir Guix. Maintenant, je vais m'occuper du champ method. La documentation me dit que method, pour récupérer les sources d'un logiciel via git doit prendre la valeur git-fetch :

[dev]$ echo '(use-modules (guix packages) (guix build-system emacs) (guix licenses)) (define-public ac-geiser (package (name "") (version "") (source (origin (uri (git-reference (url "") (commit ""))) (method git-fetch) sha256)) (build-system emacs-build-system) (synopsis "") (description "") (license bsd-3) (home-page "")))' > /tmp/emacs-ac-geiser.scm
[dev]$ ./pre-inst-env guix build -f /tmp/emacs-ac-geiser.scm
/tmp/emacs-ac-geiser.scm:1:137: error: sha256: invalid field specifier

Cool, la spécification de champ method est OK pour Guix.

Mais je m'arrête là pour aujourd'hui. Je me pencherai dessus dans un prochain article. Voici la définition obtenue à ce stade :

(use-modules 
 (guix packages) 
 (guix build-system emacs) 
 (guix licenses)) 

(define-public ac-geiser 
  (package 
   (name "") 
   (version "") 
   (source 
    (origin 
     (uri (git-reference 
	   (url "") (commit "")))
     (method git-fetch) 
     sha256))
   (build-system emacs-build-system) 
   (synopsis "") 
   (description "") 
   (license bsd-3) 
   (home-page "")))

Merci beaucoup d'avoir lu cet article ! N'hésites pas à me donner ton avis, laisser un commentaire, ou poser une question via :e-mail: jeremy AT korwin-zmijowski DOT frMastodon: @jeko@framapiaf.orgTwitter: @JeremyKorwin Abonnes-toi pour ne pas manquer les prochains articles :via une plateforme fédérée (ex: mastodon) @jeko@write.asvia RSS https://jeko.write.as/feed/

Et encore plus important, partages le blog et dis à tes amis que c'est le meilleur blog de l'histoire du logiciel libre ! Sans dec'