Suivant: , Précédent: , Monter: Canaux   [Table des matières][Index]


6.6 Écrire de nouveaux de canaux

Let’s say you have a bunch of custom package variants or personal packages that you think would make little sense to contribute to the Guix project, but would like to have these packages transparently available to you at the command line. By creating a channel, you can use and publish such a package collection. This involves the following steps:

  1. A channel lives in a Git repository so the first step, when creating a channel, is to create its repository:
    mkdir my-channel
    cd my-channel
    git init
    
  2. The next step is to create files containing package modules (voir Modules de paquets), each of which will contain one or more package definitions (voir Définition des paquets). A channel can provide things other than packages, such as build systems or services; we’re using packages as it’s the most common use case.

    For example, Alice might want to provide a module called (alice packages greetings) that will provide her favorite “hello world” implementations. To do that Alice will create a directory corresponding to that module name.

    mkdir -p alice/packages
    $EDITOR alice/packages/greetings.scm
    git add alice/packages/greetings.scm
    

    You can name your package modules however you like; the main constraint to keep in mind is to avoid name clashes with other package collections, which is why our hypothetical Alice wisely chose the (alice packages …) name space.

    Note that you can also place modules in a sub-directory of the repository; voir Modules de paquets dans un sous-répertoire, for more info on that.

  3. With this first module in place, the next step is to test the packages it provides. This can be done with guix build, which needs to be told to look for modules in the Git checkout. For example, assuming (alice packages greetings) provides a package called hi-from-alice, Alice will run this command from the Git checkout:
    guix build -L. hi-from-alice
    

    ... where -L. adds the current directory to Guile’s load path (voir Load Paths dans GNU Guile Reference Manual).

  4. It might take Alice a few iterations to obtain satisfying package definitions. Eventually Alice will commit this file:
    git commit
    

    En tant qu’auteur.e d’un canal, envisagez de regrouper le nécessaire d’authentification avec votre canal afin que les utilisatrice·eur·s puissent l’authentifier. Voir Authentification des canaux, et Spécifier les autorisations des canaux, pour savoir comment les utiliser.

  5. To use Alice’s channel, anyone can now add it to their channel file (voir Spécifier des canaux supplémentaires) and run guix pull (voir Invoquer guix pull):
    $EDITOR ~/.config/guix/channels.scm
    guix pull
    

    Guix will now behave as if the root directory of that channel’s Git repository had been permanently added to the Guile load path. In this example, (alice packages greetings) will automatically be found by the guix command.

Et voilà !

Attention : Before you publish your channel, we would like to share a few words of caution:

Vous avez été prévenus ! Maintenant, nous pensons que des canaux externes sont une manière pratique d’exercer votre liberté pour augmenter la collection de paquets de Guix et de partager vos améliorations, qui sont les principes de bases du logiciel libre. Contactez-nous par courriel sur guix-devel@gnu.org si vous souhaitez discuter à ce propos.


Suivant: Modules de paquets dans un sous-répertoire, Précédent: Canaux avec des substituts, Monter: Canaux   [Table des matières][Index]