<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="fr">
    <title>La Forge - nix</title>
    <subtitle>Le blog de la Forge</subtitle>
    <link rel="self" type="application/atom+xml" href="https://staging.lafor.ge/tags/nix/atom.xml"/>
    <link rel="alternate" type="text/html" href="https://staging.lafor.ge"/>
    <generator uri="https://www.getzola.org/">Zola</generator>
    <updated>2023-05-02T00:00:00+00:00</updated>
    <id>https://staging.lafor.ge/tags/nix/atom.xml</id>
    <entry xml:lang="fr">
        <title>Partie 6 : Vers une normalisation des dérivations</title>
        <published>2023-05-02T00:00:00+00:00</published>
        <updated>2023-05-02T00:00:00+00:00</updated>
        
        <author>
          <name>Unknown</name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://staging.lafor.ge/nix-6/"/>
        <id>https://staging.lafor.ge/nix-6/</id>
        
        <content type="html" xml:base="https://staging.lafor.ge/nix-6/">&lt;details &gt;
	&lt;summary&gt;&lt;span&gt;Les articles de la série&lt;/span&gt;&lt;/summary&gt;
	&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;/nix-1&quot;&gt;Partie 1&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;/nix-2&quot;&gt;Partie 2&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;/nix-3&quot;&gt;Partie 3&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;/nix-4&quot;&gt;Partie 4&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;/nix-5&quot;&gt;Partie 5&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;/details&gt;
&lt;p&gt;Bonjour à toutes et tous! 😀&lt;/p&gt;
&lt;p&gt;Sixième article sur Nix.&lt;/p&gt;
&lt;p&gt;Les dérivations pures c’est bien, mais elles donnent un peu trop de liberté.&lt;/p&gt;
&lt;h2 id=&quot;absence-de-standard&quot;&gt;Absence de standard&lt;/h2&gt;
&lt;p&gt;Le problème de l’informatique est souvent l’interopérérabilité.&lt;/p&gt;
&lt;p&gt;L’interopérabilté est le fait de permettre à deux sytèmes de pouvoir se parler au travers d’un canal normalisé.&lt;/p&gt;
&lt;p&gt;Prenons la dérivation de la &lt;a href=&quot;/nix-4/#se-debarasser-du-contexte&quot;&gt;partie 4&lt;/a&gt; :&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;nix&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-10&quot;&gt;with&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt; import&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;fetchTarball&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  url&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;https://github.com/NixOS/nixpkgs/archive/release-21.11.tar.gz&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  sha256&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;1xk1f62n00z7q5i3pf4c8c4rlv5k4jwpgh0pqgzw1l40vhdkixk9&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span&gt;}&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;derivation&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span&gt;          &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  name&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;hello-world&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span&gt;    &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  system&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;x86_64-linux&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  builder&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;pkgs&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;bash&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;/bin/bash&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span&gt;   &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  args&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span&gt; [&lt;/span&gt;&lt;span&gt;                 &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;-c&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;                                                                                                                               &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;                       &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    gcc $SOURCE -o $out         &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  ]&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  PATH&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;gcc&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;/bin&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  SOURCE&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; builtins&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;toFile&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;main.c&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    #include &amp;quot;stdio.h&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;  &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    void main() {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;      printf(&amp;quot;Hello World\n&amp;quot;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Elle complile les sources vers le chemin &lt;code&gt;$out&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Et donc le &lt;code&gt;$out&lt;/code&gt; est un exécutable.&lt;/p&gt;
&lt;p&gt;A l’inverse, le paquet &lt;code&gt;${pkgs.bash}&lt;/code&gt; a son binaire dans le dossier &lt;code&gt;$out/bin/bash&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Pour coller à ce mode fonctionnement, nous allons devoir modifier quelques peu notre dérivation.&lt;/p&gt;
&lt;p&gt;La première est de créer le dossier &lt;code&gt;$out/bin&lt;/code&gt; que l’on souhaite devenir la destination du produit de
compilation.&lt;/p&gt;
&lt;p&gt;On modifie également le paramètre &lt;code&gt;-o $out&lt;/code&gt; de gcc en &lt;code&gt;-o $out/bin/hello-world&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;On rajoute aussi &lt;code&gt;coreutils&lt;/code&gt; dans le PATH pour accéder à la commande &lt;code&gt;mkdir&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-shell&amp;gt; with import (fetchTarball {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  url = &amp;quot;https://github.com/NixOS/nixpkgs/archive/release-21.11.tar.gz&amp;quot;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  sha256 = &amp;quot;1xk1f62n00z7q5i3pf4c8c4rlv5k4jwpgh0pqgzw1l40vhdkixk9&amp;quot;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}) {};&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;derivation {          &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  name = &amp;quot;hello-world&amp;quot;;    &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  system = &amp;quot;x86_64-linux&amp;quot;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  builder = &amp;quot;${pkgs.bash}/bin/bash&amp;quot;;   &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  args = [                 &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;quot;-c&amp;quot;                                                                                                                               &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    mkdir -p $out/bin                       &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    gcc $SOURCE -o $out/bin/hello-world         &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  ];&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  PATH = &amp;quot;${gcc}/bin:${coreutils}/bin/&amp;quot;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  SOURCE = builtins.toFile &amp;quot;main.c&amp;quot; &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    #include &amp;quot;stdio.h&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    void main() {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      printf(&amp;quot;Hello World\n&amp;quot;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;#39;&amp;#39;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;This derivation produced the following outputs:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  out -&amp;gt; /nix/store/4wvz6l7l436ma226k4gky9985fanv8cg-hello-world&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;On peut ainsi visualiser le contenu de la réalisation de la dérivation.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; tree&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; /nix/store/4wvz6l7l436ma226k4gky9985fanv8cg-hello-world&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;/nix/store/4wvz6l7l436ma226k4gky9985fanv8cg-hello-world&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;└──&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; bin&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;    └──&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; hello-world&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;On se retrouve bien avec une structure semblable à celle de &lt;code&gt;${pkgs.bash}/bin/bash&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&quot;inputs&quot;&gt;Inputs&lt;/h2&gt;
&lt;p&gt;L’intérêt principal de normaliser des manières de faire c’est que l’on peut facilement automatiser.&lt;/p&gt;
&lt;p&gt;Par exemple, la définition du PATH.&lt;/p&gt;
&lt;p&gt;Si tout les paquets respectent le même schéma de définitions des binaires.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;ini&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-10&quot;&gt;PATH&lt;/span&gt;&lt;span&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;{bash}/bin:{gcc}/bin:{coreutils}/bin&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Alors, on peut simplifier l’écriture pour passer par un tableau.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;buildInputs = [ bash gcc coreutils ]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Bon très bien, mais il n’y aura pas grand chose qui se passera.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;$buildInputs&lt;/code&gt; n’est qu’une variable d’environnement.&lt;/p&gt;
&lt;p&gt;Nous allons devoir la faire vivre.&lt;/p&gt;
&lt;h2 id=&quot;setup&quot;&gt;Setup&lt;/h2&gt;
&lt;p&gt;Nous allons établir une stratégie permettant d’utiliser notre variable &lt;code&gt;$buildInputs&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Pour cela, nous allons déterminer un script qui fera le travail à notre place.&lt;/p&gt;
&lt;blockquote class=&quot;markdown-alert-note&quot;&gt;
	&lt;p&gt;Je le défini délibérément naïf, dans la réalité, il faudrait le rendre plus versatile, mais ça suffira pour la démo.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;On reset d’abord le &lt;code&gt;$PATH&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Puis on profite de la propriété de la dérivation qui lorsque que l’on l’interpole sous la forme d’une chaîne devient le &lt;code&gt;$out&lt;/code&gt; de la dérivation.&lt;/p&gt;
&lt;p&gt;Propriété qui fonctionne également avec un tableau.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; toString [ bash gcc coreutils ]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&amp;quot;/nix/store/zlf0f88vj30sc7567b80l52d19pbdmy2-bash-5.2-p15 &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;/nix/store/nlgyw2fv0cm8rkz8qm1jyw78vyif1bl9-gcc-wrapper-12.2.0 &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;/nix/store/arbxkmcgv9h8pjgj95c6d7r86yb77rl5-coreutils-9.1&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Comme nous avons choisi que les binaires serait dans le dossier &lt;code&gt;$out/bin&lt;/code&gt;. Nous pouvons créer notre &lt;code&gt;$PATH&lt;/code&gt; automatiquement.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;PATH&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-10&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt; input&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-10&quot;&gt; in&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt; $&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;buildInputs&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-10&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  PATH&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;PATH&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;/bin&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-10&quot;&gt;done&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Nous allons alors faire deux choses:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;définir un fichier &lt;code&gt;setup.sh&lt;/code&gt; via la même méthode que pour les sources&lt;/li&gt;
&lt;li&gt;utiliser la &lt;code&gt;source&lt;/code&gt; qui permet d’exécuter le bash contenu dans un fichier&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;La réunion de ces deux actions nous donnes la dérivation suivante:&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;nix&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-10&quot;&gt;with&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt; import&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;fetchTarball&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  url&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;https://github.com/NixOS/nixpkgs/archive/release-21.11.tar.gz&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  sha256&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;1xk1f62n00z7q5i3pf4c8c4rlv5k4jwpgh0pqgzw1l40vhdkixk9&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span&gt;}&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;derivation&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span&gt;          &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  name&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;hello-world&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span&gt;    &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  system&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;x86_64-linux&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  builder&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;pkgs&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;bash&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;/bin/bash&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span&gt;   &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  args&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span&gt; [&lt;/span&gt;&lt;span&gt;                 &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;-c&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;                                                                                                                               &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    source $SETUP&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    # builder&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    mkdir -p $out/bin                       &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    gcc $SOURCE -o $out/bin/hello-world         &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  ]&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  SETUP&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; builtins&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;toFile&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;setup.sh&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    PATH=&amp;quot;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    for input in $buildInputs; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;      PATH=&amp;quot;$PATH:$input/bin&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    done&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  buildInputs&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span&gt; [&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; bash&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; gcc&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; coreutils&lt;/span&gt;&lt;span&gt; ]&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  SOURCE&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; builtins&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;toFile&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;main.c&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    #include &amp;quot;stdio.h&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;  &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    void main() {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;      printf(&amp;quot;Hello World\n&amp;quot;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Cela peut sembler étrange de vouloir écrire plus de lignes pour le même résultat, mais nous sommes en train de nous rapprocher de l’automatisation.&lt;/p&gt;
&lt;p&gt;Et nous allons aller encore plus loin !&lt;/p&gt;
&lt;h2 id=&quot;builder&quot;&gt;Builder&lt;/h2&gt;
&lt;p&gt;Nous allons sortir dans un &lt;code&gt;builder.sh&lt;/code&gt; le contenu du build.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;mkdir&lt;/span&gt;&lt;span class=&quot;z-l-4 z-d-11&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-l-4 z-d-11&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt; $&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;out&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;/bin&lt;/span&gt;&lt;span&gt;                       &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;gcc&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt; $&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;SOURCE&lt;/span&gt;&lt;span class=&quot;z-l-4 z-d-11&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-l-4 z-d-11&quot;&gt;o&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt; $&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;out&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;/bin/hello-world&lt;/span&gt;&lt;span&gt;   &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Je vais alors définir deux variables:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;$setupPhase&lt;/code&gt; anciennement &lt;code&gt;$SETUP&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;$buildPhase&lt;/code&gt; le chemin du builder.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Et on rajoute le &lt;code&gt;source builder.sh&lt;/code&gt; qui va bien.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;nix&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-10&quot;&gt;with&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt; import&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;fetchTarball&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  url&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;https://github.com/NixOS/nixpkgs/archive/release-21.11.tar.gz&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  sha256&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;1xk1f62n00z7q5i3pf4c8c4rlv5k4jwpgh0pqgzw1l40vhdkixk9&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span&gt;}&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;derivation&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span&gt;          &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  name&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;hello-world&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span&gt;    &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  system&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;x86_64-linux&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  builder&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;pkgs&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;bash&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;/bin/bash&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span&gt;   &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  args&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span&gt; [&lt;/span&gt;&lt;span&gt;                 &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;-c&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;                                                                                                                               &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    source $setupPhase&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    source $buildPhase&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  ]&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  buildPhase&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; builtins&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;toFile&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;builder.sh&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    mkdir -p $out/bin&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    gcc $SOURCE -o $out/bin/hello-world&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;  &amp;#39;&amp;#39;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  setupPhase&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; builtins&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;toFile&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;setup.sh&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    PATH=&amp;quot;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    for input in $buildInputs; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;      PATH=&amp;quot;$PATH:$input/bin&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    done&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;  &amp;#39;&amp;#39;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  buildInputs&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span&gt; [&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; bash&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; gcc&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; coreutils&lt;/span&gt;&lt;span&gt; ]&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  SOURCE&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; builtins&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;toFile&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;main.c&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    #include &amp;quot;stdio.h&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;  &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    void main() {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;      printf(&amp;quot;Hello World\n&amp;quot;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;  &amp;#39;&amp;#39;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Ok, et donc, ça nous avance à quoi ?&lt;/p&gt;
&lt;p&gt;J’y arrive ^^
^&lt;/p&gt;
&lt;h2 id=&quot;normalisation-de-la-derivation&quot;&gt;Normalisation de la dérivation&lt;/h2&gt;
&lt;p&gt;Maintenant que nous avons normalisé ce que l’on pouvais, nous allons pouvoir passer à l’automatisation !&lt;/p&gt;
&lt;p&gt;Pour cela, nous allons créer une fonction qui va retourner une dérivation.&lt;/p&gt;
&lt;p&gt;Mais avant de pouvoir y arriver, nous allons encore manipuler un peu de Nix.&lt;/p&gt;
&lt;blockquote class=&quot;markdown-alert-tip&quot;&gt;
	&lt;p&gt;Ne vous plaignez pas c’est pour votre bien. ^^ C’est comme pour aller à l’étranger, savoir commander une bière c’est bien.&lt;/p&gt;
&lt;p&gt;Pouvoir également dire en cas d’arrestation: “Je suis français, je voudrai appeler l’Ambassade” dans la langue, c’est mieux ^^&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Nous allons donc découvrir d’autres syntaxes de la grammaire.&lt;/p&gt;
&lt;h3 id=&quot;parametres-optionels&quot;&gt;Paramètres optionels&lt;/h3&gt;
&lt;p&gt;Lorsque l’on défini une fonction en Nix, nous pouvons lui donner un set en entrée, ce set possède des champs qui sont nommés.&lt;/p&gt;
&lt;p&gt;Si notre fonction a pour signature&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;nix&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;z-l-10 z-l-bg5 z-d-12 z-d-bg4&quot;&gt; =&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; y&lt;/span&gt;&lt;span&gt;}&lt;/span&gt;&lt;span&gt; :&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; x&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; +&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; y&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Il est obligatoire de remplir tous les champs&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; f {x = 12;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;error: function &amp;#39;anonymous lambda&amp;#39; called without required argument &amp;#39;y&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Ici, Nix, nous averti qu’il manque un paramètre.&lt;/p&gt;
&lt;p&gt;Bien que cela soit pratique dans certains cas, cela peut être ennuyeux. Car l’obligation de conformité est également contraignante lorsqu’il y a trop de paramètres.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; f { x = 12; y = 4; z = 42;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;error: function &amp;#39;anonymous lambda&amp;#39; called with unexpected argument &amp;#39;z&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Nix attendait seulement un paramètre x et y. Nous lui avons donné un paramètres ‘z’.&lt;/p&gt;
&lt;p&gt;Sauf que parfois, nous ne contrôlons pas avec exactitude les paramètres d’entrées, il peut y avoir les bons champs au bon nom mais avec des
des champs supplémentaires.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;nix&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;z-l-10 z-l-bg5 z-d-12 z-d-bg4&quot;&gt; =&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt; x&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; 12&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt; y&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; 4&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt; z&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; 42&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt; t&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt; a&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;chat&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt; b&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; true&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;A l’appel, nous avons sans surprise une erreur.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; f data&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;error: function &amp;#39;anonymous lambda&amp;#39; called with unexpected argument &amp;#39;z&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Il est possible de déclarer différement notre fonction pour lui faire accepter des paramètres optionels.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;f2 = {x, y, ...} : x + y&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Et maintenant ça marche correctement ^^&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; f2 data&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;16&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Bien entendu, les règles de champs obligatoires restent valides.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; f { x = 12; }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;error: function &amp;#39;anonymous lambda&amp;#39; called without required argument &amp;#39;y&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Et il est également possible de mélanger les concepts de champs par défaut et optionnel.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;nix&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;f3&lt;/span&gt;&lt;span class=&quot;z-l-10 z-l-bg5 z-d-12 z-d-bg4&quot;&gt; =&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; x&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; y&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; ?&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; 0&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; ...&lt;/span&gt;&lt;span&gt;}&lt;/span&gt;&lt;span&gt; :&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; x&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; +&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; y&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Et désormais y n’est plus obligatoire.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; f3 { x = 12; }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;12&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&quot;le-mot-clef-inherit&quot;&gt;Le mot-clef inherit&lt;/h3&gt;
&lt;p&gt;Il s’agit d’un sucre syntaxique qui permet de ne pas répéter le champ et la valeur lorsque les deux possèdent le même nom.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; x = 12&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; { x = x; }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{ x = 12; }&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Est équivalent à&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; { inherit x; }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{ x = 12; }&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&quot;set-binding&quot;&gt;Set Binding&lt;/h3&gt;
&lt;p&gt;J’ai pas trouvé de traduction satisfaisante.&lt;/p&gt;
&lt;p&gt;C’est l’idée que l’on puisse récupérer le set dans une variable.&lt;/p&gt;
&lt;p&gt;La syntaxe est:&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;args @ { x = 12; y = true; }&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;ou&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{ x = 12; y = true; } @ args&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;On peut utiliser cette propriété pour copier les champs dans un set:&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;nix&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;wrapping&lt;/span&gt;&lt;span class=&quot;z-l-10 z-l-bg5 z-d-12 z-d-bg4&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; inner&lt;/span&gt;&lt;span&gt; @&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; y&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; ?&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; 0&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; ...&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;span&gt; :&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; name&lt;/span&gt;&lt;span&gt; :&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  {&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-10&quot;&gt; inherit&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt; inner&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-10&quot;&gt; inherit&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt; name&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;On peut alors utiliser notre &lt;code&gt;data&lt;/code&gt; et lui donner un label.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; wrapping data &amp;quot;toto&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{ inner = { ... }; name = &amp;quot;toto&amp;quot;; }&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&quot;fusion-merge-de-sets&quot;&gt;Fusion (merge) de sets&lt;/h3&gt;
&lt;p&gt;Il est possible de combiner plusieurs sets en un seul.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; { x = 12; } // { y = true; }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{ x = 12; y = true; }&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Ce qui peut se faire à répétitions&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; { x = 12; } // { y = true; } // { z = { a = 12.2; }; }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{ x = 12; y = true; z = { ... }; }&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Le merge peut également réécrire des champs.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; { x = 12; y = true; } // { x = 42; }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{ x = 42; y = true; }&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&quot;supprimer-un-champ&quot;&gt;Supprimer un champ&lt;/h3&gt;
&lt;p&gt;Ce n’est pas forcément un outil du langage, mais c’est très pratique pour nore besoin.&lt;/p&gt;
&lt;p&gt;Nix est fourni avec une série de fonctions, dont une qui nous intéresse &lt;code&gt;builtins.removeAttrs&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Celle-ci prend deux paramètres:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;le set à modifier&lt;/li&gt;
&lt;li&gt;une liste de noms de champs à supprimer&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Comme son nom l’indique permet de supprimer des champs d’un set.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; builtins.removeAttrs { x = 12; y = true; z = 12.2; } [ &amp;quot;x&amp;quot; &amp;quot;z&amp;quot; ]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{ y = true; }&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&quot;notre-fonction-makederivation&quot;&gt;Notre fonction makeDerivation&lt;/h3&gt;
&lt;p&gt;Nous avons tous les outils, maintenant assemblage !!&lt;/p&gt;
&lt;p&gt;Que voulons-nous faire déjà ?&lt;/p&gt;
&lt;p&gt;Nous avons créé une dérivation normalisée:&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;nix&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;derivation&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span&gt;          &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  name&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;    =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;hello-world&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span&gt;    &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  system&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;  =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;x86_64-linux&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  builder&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;pkgs&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;bash&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;/bin/bash&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span&gt;   &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  args&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;    =&lt;/span&gt;&lt;span&gt; [&lt;/span&gt;&lt;span&gt;                 &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;-c&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;                                                                                                                               &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    source $setupPhase&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    source $buildPhase&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  ]&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  buildPhase&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;  =&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; .&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  setupPhase&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;  =&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; .&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  buildInputs&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; .&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Le but est de pouvoir remplir seulement les champs pertinents, nous donnerons le nom de &lt;code&gt;makeDerivation&lt;/code&gt; à notre fonction.&lt;/p&gt;
&lt;p&gt;Par exemple, notre &lt;code&gt;setupPhase&lt;/code&gt; sera toujours identique, de même que le &lt;code&gt;builder&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;A contrario, d’autres champs sont à redéfinir pour chaque dérivation, comme &lt;code&gt;buildPhase&lt;/code&gt;, &lt;code&gt;buildInputs&lt;/code&gt; et &lt;code&gt;name&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;On désire également définir le &lt;code&gt;&amp;lt;nixpkgs&amp;gt;&lt;/code&gt; que l’on désire pour conserver la reproductivité.&lt;/p&gt;
&lt;p&gt;Et dernière contrainte, nous voulons pouvoir définir n’importe quelle variable d’environnement.&lt;/p&gt;
&lt;p&gt;Prenons les choses dans l’ordre, réglons les problèmes un par un.&lt;/p&gt;
&lt;p&gt;D’abord les champs obligatoires:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;name&lt;/li&gt;
&lt;li&gt;pkgs&lt;/li&gt;
&lt;li&gt;buildPhase&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Et un champ possédant une valeur par défaut &lt;code&gt;buildInputs&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Ce qui nous donne la signature&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;nix&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;makeDerivation&lt;/span&gt;&lt;span class=&quot;z-l-10 z-l-bg5 z-d-12 z-d-bg4&quot;&gt; =&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; pkgs&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; name&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; buildPhase&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; buildInputs&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; ?&lt;/span&gt;&lt;span&gt; [&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;span&gt; :&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Ok, rajoutons le corps de la dérivation avec les champs obligatoires:&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;nix&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;makeDerivation&lt;/span&gt;&lt;span class=&quot;z-l-10 z-l-bg5 z-d-12 z-d-bg4&quot;&gt; =&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; pkgs&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; name&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; buildPhase&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; buildInputs&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; ?&lt;/span&gt;&lt;span&gt; [&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;span&gt; :&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;derivation&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  system&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;x86_64-linux&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  setupPhase&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; builtins&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;toFile&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;setup.sh&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    PATH=&amp;quot;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    for input in $buildInputs; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;      PATH=&amp;quot;$PATH:$input/bin&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    done&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;  &amp;#39;&amp;#39;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  builder&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;pkgs&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;bash&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;/bin/bash&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  args&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span&gt; [&lt;/span&gt;&lt;span&gt;                 &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;-c&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;                                                                                                                               &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    source $setupPhase&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    source $buildPhase&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  ]&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Il manque les champs définis par la fonction, on les rajoute:&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;nix&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;makeDerivation&lt;/span&gt;&lt;span class=&quot;z-l-10 z-l-bg5 z-d-12 z-d-bg4&quot;&gt; =&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; pkgs&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; name&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; buildPhase&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; buildInputs&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; ?&lt;/span&gt;&lt;span&gt; [&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;span&gt; :&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;derivation&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-7 z-d-7&quot;&gt;  #&lt;/span&gt;&lt;span class=&quot;z-l-7 z-d-7&quot;&gt; champs hérités&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-10&quot;&gt;  inherit&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt; name&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-10&quot;&gt;  inherit&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt; buildPhase&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-10&quot;&gt;  inherit&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt; buildInputs&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  system&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;x86_64-linux&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  setupPhase&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; builtins&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;toFile&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;setup.sh&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    PATH=&amp;quot;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    for input in $buildInputs; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;      PATH=&amp;quot;$PATH:$input/bin&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    done&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;  &amp;#39;&amp;#39;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  builder&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;pkgs&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;bash&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;/bin/bash&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  args&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span&gt; [&lt;/span&gt;&lt;span&gt;                 &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;-c&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;                                                                                                                               &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    source $setupPhase&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    source $buildPhase&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  ]&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Sauf que l’on peut être plus malin et utiliser le merge à la place&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;nix&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;makeDerivation&lt;/span&gt;&lt;span class=&quot;z-l-10 z-l-bg5 z-d-12 z-d-bg4&quot;&gt; =&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; pkgs&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; name&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; buildPhase&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; buildInputs&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; ?&lt;/span&gt;&lt;span&gt; [&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;span&gt; @&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; args&lt;/span&gt;&lt;span&gt; :&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;derivation&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  system&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;x86_64-linux&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  setupPhase&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; builtins&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;toFile&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;setup.sh&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    PATH=&amp;quot;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    for input in $buildInputs; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;      PATH=&amp;quot;$PATH:$input/bin&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    done&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;  &amp;#39;&amp;#39;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  builder&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;pkgs&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;bash&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;/bin/bash&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  args&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span&gt; [&lt;/span&gt;&lt;span&gt;                 &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;-c&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;                                                                                                                               &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    source $setupPhase&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    source $buildPhase&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  ]&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; //&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; args&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Il nous manque un bout, comment rajouter les variables d’environnement personnalisées ?&lt;/p&gt;
&lt;p&gt;Nous utilisons les paramètres optionels, plus le merge&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;nix&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;makeDerivation&lt;/span&gt;&lt;span class=&quot;z-l-10 z-l-bg5 z-d-12 z-d-bg4&quot;&gt; =&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; pkgs&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; name&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; buildPhase&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; buildInputs&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; ?&lt;/span&gt;&lt;span&gt; [&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; ...&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;span&gt; @&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; args&lt;/span&gt;&lt;span&gt; :&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;derivation&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  system&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;x86_64-linux&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  setupPhase&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; builtins&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;toFile&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;setup.sh&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    PATH=&amp;quot;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    for input in $buildInputs; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;      PATH=&amp;quot;$PATH:$input/bin&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    done&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;  &amp;#39;&amp;#39;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  builder&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;pkgs&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;bash&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;/bin/bash&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  args&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span&gt; [&lt;/span&gt;&lt;span&gt;                 &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;-c&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    source $setupPhase&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    source $buildPhase&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  ]&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; //&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; args&lt;/span&gt;&lt;span&gt; )&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;blockquote class=&quot;markdown-alert-warning&quot;&gt;
	&lt;p&gt;&lt;strong&gt;Attention!&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Il faut bien entouré de paranthèses sinon le merge est appliqué sur le résultat de l’appel à la dérivation et non comme paramètre de dérivation&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Ok, c’est pas mal.&lt;/p&gt;
&lt;p&gt;Testons notre fonction:&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;nix&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-10&quot;&gt;with&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt; import&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;fetchTarball&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  url&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;https://github.com/NixOS/nixpkgs/archive/release-21.11.tar.gz&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  sha256&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;1xk1f62n00z7q5i3pf4c8c4rlv5k4jwpgh0pqgzw1l40vhdkixk9&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span&gt;}&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;makeDerivation&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  name&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;hello-world&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  buildPhase&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; builtins&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;toFile&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;builder.sh&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    mkdir -p $out/bin&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    gcc $SOURCE -o $out/bin/hello-world&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;  &amp;#39;&amp;#39;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  buildInputs&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span&gt; [&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; bash&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; gcc&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; coreutils&lt;/span&gt;&lt;span&gt; ]&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-10&quot;&gt;  inherit&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt; pkgs&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  SOURCE&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; builtins&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;toFile&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;main.c&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    #include &amp;quot;stdio.h&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    void main() {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;      printf(&amp;quot;Hello World\n&amp;quot;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;  &amp;#39;&amp;#39;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Hum, pas fameux …&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;… while evaluating derivation &amp;#39;hello-world&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;         whose name attribute is located at «string»:7:3&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;       … while evaluating attribute &amp;#39;pkgs&amp;#39; of derivation &amp;#39;hello-world&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;         at «string»:16:10:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;           15|&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;           16|   inherit pkgs;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;             |          ^&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;           17|&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Après, je ne vous ai pas parlé du &lt;code&gt;removeAttrs&lt;/code&gt; pour rien 😁&lt;/p&gt;
&lt;p&gt;Avant de l’utiliser, qu’est ce qui se passe ?&lt;/p&gt;
&lt;p&gt;La méthode dérivation, ne prend pas de paramètre autre que tu type “chaîne de caractères”.&lt;/p&gt;
&lt;p&gt;Or &lt;code&gt;pkgs&lt;/code&gt; est un set qui ne peut pas être converti en &lt;code&gt;string&lt;/code&gt;, ce &lt;code&gt;pkgs&lt;/code&gt; étant passé lors du merge, il se retrouve dans le paramètre de la
dérivation qui le refuse.&lt;/p&gt;
&lt;p&gt;On va donc nettoyer notre set d’entré pour qu’il n’y ait plus de champ &lt;code&gt;pkgs&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;nix&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;makeDerivation&lt;/span&gt;&lt;span class=&quot;z-l-10 z-l-bg5 z-d-12 z-d-bg4&quot;&gt; =&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; pkgs&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; name&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; buildPhase&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; buildInputs&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; ?&lt;/span&gt;&lt;span&gt; [&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; ...&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;span&gt; @&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;args&lt;/span&gt;&lt;span&gt; :&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt; derivation&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;{&lt;/span&gt;&lt;span&gt;           &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  system&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;x86_64-linux&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  setupPhase&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; builtins&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;toFile&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;setup.sh&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    PATH=&amp;quot;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    for input in $buildInputs; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;      PATH=&amp;quot;$PATH:$input/bin&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    done&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;  &amp;#39;&amp;#39;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  builder&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;pkgs&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;bash&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;/bin/bash&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span&gt;   &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  args&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span&gt; [&lt;/span&gt;&lt;span&gt;                 &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;-c&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;                                                                                                                               &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    source $setupPhase&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    source $buildPhase&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  ]&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; //&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; builtins&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;removeAttrs&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; args&lt;/span&gt;&lt;span&gt; [&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;pkgs&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt; )&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Nous pouvons alors utiliser notre &lt;code&gt;makeDerivation&lt;/code&gt; fraîchement réparée&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;nix&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;deriv&lt;/span&gt;&lt;span class=&quot;z-l-10 z-l-bg5 z-d-12 z-d-bg4&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-10 z-l-bg5 z-d-12 z-d-bg4&quot;&gt; with&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt; import&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;fetchTarball&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  url&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;https://github.com/NixOS/nixpkgs/archive/release-21.11.tar.gz&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  sha256&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;1xk1f62n00z7q5i3pf4c8c4rlv5k4jwpgh0pqgzw1l40vhdkixk9&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span&gt;}&lt;/span&gt;&lt;span class=&quot;z-l-10 z-l-bg5 z-d-12 z-d-bg4&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;makeDerivation&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  name&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;hello-world&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  buildPhase&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; builtins&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;toFile&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;builder.sh&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    mkdir -p $out/bin&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    gcc $SOURCE -o $out/bin/hello-world&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;  &amp;#39;&amp;#39;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  buildInputs&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span&gt; [&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; bash&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; gcc&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; coreutils&lt;/span&gt;&lt;span&gt; ]&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-10&quot;&gt;  inherit&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt; pkgs&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  SOURCE&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; builtins&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;toFile&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;main.c&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    #include &amp;quot;stdio.h&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    void main() {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;      printf(&amp;quot;Hello World\n&amp;quot;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;  &amp;#39;&amp;#39;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Ce qui donne&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; :b deriv&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;This derivation produced the following outputs:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  out -&amp;gt; /nix/store/ij9lwz1wm1x02zhcix5fsdzxqf969s96-hello-world&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$ /nix/store/ij9lwz1wm1x02zhcix5fsdzxqf969s96-hello-world/bin/hello-world&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Hello World&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;C’est plus court et plus lisible, non ? 😀&lt;/p&gt;
&lt;p&gt;Essayons avec quelque chose de plus consistant.&lt;/p&gt;
&lt;p&gt;Nous allons reprendre le projet &lt;a rel=&quot;nofollow noreferrer external&quot; href=&quot;https://github.com/Akanoa/nix-hello/&quot;&gt;github&lt;/a&gt; au &lt;a rel=&quot;nofollow noreferrer external&quot; href=&quot;https://github.com/Akanoa/nix-hello/commit/9e363d35a44b00b190a5fa8376dc2d4a221d94a2&quot;&gt;commit&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;On oublie pas les bonnes habitudes et on prefetch pour récupérer la signature:&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$ nix-prefetch-url --unpack https://github.com/Akanoa/nix-hello/archive/9e363d35a44b00b190a5fa8376dc2d4a221d94a2.tar.gz&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;path is &amp;#39;/nix/store/dl6rj73hw5qpj14sk7wazzh16cvrjpvv-9e363d35a44b00b190a5fa8376dc2d4a221d94a2.tar.gz&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;106ra1nd19y57rnzndb87d59x1vhr6magy4y46vk98d5x6fhmr6y&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Il est construit via &lt;a href=&quot;/autotools&quot;&gt;Autotools&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Et donc notre &lt;code&gt;buildPhase&lt;/code&gt; sera:&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;./configure&lt;/span&gt;&lt;span class=&quot;z-l-4 z-d-11&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-l-4 z-d-11&quot;&gt;-prefix&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt; $&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;out&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;make&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;make&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; test&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;make&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; install&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Nous avons besoin de &lt;a rel=&quot;nofollow noreferrer external&quot; href=&quot;https://search.nixos.org/packages?channel=22.11&amp;amp;show=gnumake&amp;amp;from=0&amp;amp;size=50&amp;amp;sort=relevance&amp;amp;type=packages&amp;amp;query=make&quot;&gt;make&lt;/a&gt; et de &lt;a rel=&quot;nofollow noreferrer external&quot; href=&quot;https://search.nixos.org/packages?channel=22.11&amp;amp;show=gcc&amp;amp;from=0&amp;amp;size=50&amp;amp;sort=relevance&amp;amp;type=packages&amp;amp;query=gcc&quot;&gt;gcc&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;On rajoute également une &lt;a rel=&quot;nofollow noreferrer external&quot; href=&quot;https://search.nixos.org/packages?channel=22.11&amp;amp;show=busybox&amp;amp;from=0&amp;amp;size=50&amp;amp;sort=relevance&amp;amp;type=packages&amp;amp;query=grep&quot;&gt;busybox&lt;/a&gt; car make demande tout un tas de commandes. Sans &lt;code&gt;busybox&lt;/code&gt;, cela ne fonctionnerait pas. Essayez sans pour voir. 🙂&lt;/p&gt;
&lt;p&gt;Bon, nous avons tout, nous pouvons construire notre dérivation&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;nix&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-10&quot;&gt;with&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt; import&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;fetchTarball&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  url&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;https://github.com/NixOS/nixpkgs/archive/release-21.11.tar.gz&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  sha256&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;1xk1f62n00z7q5i3pf4c8c4rlv5k4jwpgh0pqgzw1l40vhdkixk9&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span&gt;}&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;makeDerivation&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  name&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;hello-world&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  buildPhase&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; builtins&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;toFile&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;builder.sh&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    cd $SOURCE&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    ./configure --prefix $out&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    make&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    make test&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    make install&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;  &amp;#39;&amp;#39;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  buildInputs&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span&gt; [&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; busybox&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; gcc&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; gnumake&lt;/span&gt;&lt;span&gt; ]&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-10&quot;&gt;  inherit&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt; pkgs&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  SOURCE&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; fetchTarball&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;    url&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;https://github.com/Akanoa/nix-hello/archive/9e363d35a44b00b190a5fa8376dc2d4a221d94a2.tar.gz&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;    sha256&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;106ra1nd19y57rnzndb87d59x1vhr6magy4y46vk98d5x6fhmr6y&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  }&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Ben oui, mais non …&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;error: builder for &amp;#39;/nix/store/7lb3z8dxl1hwkmdk0irwkcxal2wbqias-hello-world.drv&amp;#39; failed with exit code 2;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;last 10 log lines:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&amp;gt; ./configure: line 1460: can&amp;#39;t create config.log: Permission denied&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Le configure va vouloir créer des fichiers de même que le make. Résultat, ça ne fonctionne pas. Il faut donner accès au dossier.&lt;/p&gt;
&lt;p&gt;Or, rappelez-vous, les sources sont dans le /nix/store qui n’appartient pas à notre utilisateur de build.&lt;/p&gt;
&lt;p&gt;la stratégie est donc de copier les sources avant de modifier les droits du dossier pour finalement lancer la procédure à l’intérieur.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;cp&lt;/span&gt;&lt;span class=&quot;z-l-4 z-d-11&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-l-4 z-d-11&quot;&gt;r&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt; $&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;SOURCE&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; work&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;chmod&lt;/span&gt;&lt;span class=&quot;z-l-4 z-d-11&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-l-4 z-d-11&quot;&gt;R&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; u+w&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; work&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;cd&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; work&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Ce qui nous donne au final:&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;nix&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-10&quot;&gt;with&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt; import&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;fetchTarball&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  url&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;https://github.com/NixOS/nixpkgs/archive/release-21.11.tar.gz&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  sha256&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;1xk1f62n00z7q5i3pf4c8c4rlv5k4jwpgh0pqgzw1l40vhdkixk9&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span&gt;}&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;makeDerivation&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  name&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;hello-world&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  buildPhase&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; builtins&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;toFile&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;builder.sh&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    cp -r $SOURCE work&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    chmod -R u+w work&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    cd work&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    ./configure --prefix $out&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    make&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    make test&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    make install&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;  &amp;#39;&amp;#39;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  buildInputs&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span&gt; [&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; busybox&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; gcc&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; gnumake&lt;/span&gt;&lt;span&gt; ]&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-10&quot;&gt;  inherit&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt; pkgs&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  SOURCE&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; fetchTarball&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;    url&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;https://github.com/Akanoa/nix-hello/archive/9e363d35a44b00b190a5fa8376dc2d4a221d94a2.tar.gz&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;    sha256&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;106ra1nd19y57rnzndb87d59x1vhr6magy4y46vk98d5x6fhmr6y&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  }&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Et cette fois-ci notre dérivation fonctionne 😁&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$ /nix/store/m9gibyx0yxn4raa4bd0xhrfa6jwxaqm8-hello-world/bin/hello &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Hello World!&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;On peut même se donner un dernier sucre syntaxique.&lt;/p&gt;
&lt;p&gt;Il est possible de fusionner deux tableaux&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; [ 1 ] ++ [ 2 3 4 ]  &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[ 1 2 3 4 ]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Nous pouvons utiliser cette propriété pour nous simplifier le travail en rendant la &lt;code&gt;busybox&lt;/code&gt; “pré-remplie”.&lt;/p&gt;
&lt;blockquote class=&quot;markdown-alert-warning&quot;&gt;
	&lt;p&gt;Ne pas oublier de retirer également le champs &lt;code&gt;buildInputs&lt;/code&gt; du merge avec &lt;code&gt;args&lt;/code&gt;, sinon le busybox est écrasé.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;nix&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;makeDerivation&lt;/span&gt;&lt;span class=&quot;z-l-10 z-l-bg5 z-d-12 z-d-bg4&quot;&gt; =&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; pkgs&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; name&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; buildPhase&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; buildInputs&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; ?&lt;/span&gt;&lt;span&gt; [&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; ...&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;span&gt; @&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;args&lt;/span&gt;&lt;span&gt; :&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt; derivation&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;{&lt;/span&gt;&lt;span&gt;           &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  system&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;x86_64-linux&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  setupPhase&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; builtins&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;toFile&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;setup.sh&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    PATH=&amp;quot;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    for input in $buildInputs; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;      PATH=&amp;quot;$PATH:$input/bin&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    done&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;  &amp;#39;&amp;#39;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  builder&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;pkgs&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;bash&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;/bin/bash&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  buildInputs&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span&gt; [&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; pkgs&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;busybox&lt;/span&gt;&lt;span&gt; ]&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; ++&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; buildInputs&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  args&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span&gt; [&lt;/span&gt;&lt;span&gt;                 &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;-c&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;                                                                                                                               &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    source $setupPhase&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    source $buildPhase&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  ]&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; //&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; builtins&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;removeAttrs&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; args&lt;/span&gt;&lt;span&gt; [&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;pkgs&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;buildInputs&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt; ]&lt;/span&gt;&lt;span&gt; )&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Ce qui permet de ne plus nous en soucier:&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;nix&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-10&quot;&gt;with&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt; import&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;fetchTarball&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  url&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;https://github.com/NixOS/nixpkgs/archive/release-21.11.tar.gz&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  sha256&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;1xk1f62n00z7q5i3pf4c8c4rlv5k4jwpgh0pqgzw1l40vhdkixk9&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span&gt;}&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;makeDerivation&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  name&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;hello-world&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  buildPhase&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; builtins&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;toFile&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;builder.sh&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    cp -r $SOURCE work&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    chmod -R u+w work&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    cd work&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    ./configure --prefix $out&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    make&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    make test&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    make install&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;  &amp;#39;&amp;#39;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  buildInputs&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span&gt; [&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; gcc&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; gnumake&lt;/span&gt;&lt;span&gt; ]&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-10&quot;&gt;  inherit&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt; pkgs&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  SOURCE&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; fetchTarball&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;    url&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;https://github.com/Akanoa/nix-hello/archive/9e363d35a44b00b190a5fa8376dc2d4a221d94a2.tar.gz&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;    sha256&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;106ra1nd19y57rnzndb87d59x1vhr6magy4y46vk98d5x6fhmr6y&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  }&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;On pourrait encore rafiner plus la &lt;code&gt;buildPhase&lt;/code&gt; pour écrire encore moins de code, mais nous allons nous arrêter là, nous avons la
philosophie de création de dérivation normalisée.&lt;/p&gt;
&lt;p&gt;Philosophie que nous appliqueront plus tard avec de meilleurs outils.&lt;/p&gt;
&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Nous avons bien manipulé et même trituré le langage dans tous les sens, mais vous vous doutez bien que ce n’est pas de cette façon
quasi artisanale que l’on créé des dérivations dans Nix.&lt;/p&gt;
&lt;p&gt;Dans la partie 7, nous verrons comment utiliser &lt;code&gt;stdenv.mkDerivation&lt;/code&gt; qui n’est autre que le pendant de la fonction que nous avons créé mais en bien
plus sophistiquée et directement fournie par la librairie standard!&lt;/p&gt;
&lt;p&gt;Merci de votre lecture et à la prochaine ❤️&lt;/p&gt;
</content>
        
    </entry>
    <entry xml:lang="fr">
        <title>Partie 5 : Externaliser les sources</title>
        <published>2023-04-21T00:00:00+00:00</published>
        <updated>2023-04-21T00:00:00+00:00</updated>
        
        <author>
          <name>Unknown</name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://staging.lafor.ge/nix-5/"/>
        <id>https://staging.lafor.ge/nix-5/</id>
        
        <content type="html" xml:base="https://staging.lafor.ge/nix-5/">&lt;details &gt;
	&lt;summary&gt;&lt;span&gt;Les articles de la série&lt;/span&gt;&lt;/summary&gt;
	&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;/nix-1&quot;&gt;Partie 1&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;/nix-2&quot;&gt;Partie 2&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;/nix-3&quot;&gt;Partie 3&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;/nix-4&quot;&gt;Partie 4&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;/nix-6&quot;&gt;Partie 6&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;/details&gt;
&lt;p&gt;Bonjour à toutes et tous! 😀&lt;/p&gt;
&lt;p&gt;Cinquième article sur Nix.&lt;/p&gt;
&lt;p&gt;Aujourd’hui nous allons utiliser des sources qui ne sont pas dans la dérivation, cela rendra notre dérivation plus souple.&lt;/p&gt;
&lt;h2 id=&quot;plus-de-sources&quot;&gt;Plus de sources !&lt;/h2&gt;
&lt;p&gt;Jusqu’à présent notre dérivation ressemble à ceci:&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;nix&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-10&quot;&gt;with&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt; import&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;fetchTarball&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;https://github.com/NixOS/nixpkgs/archive/release-21.11.tar.gz&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span&gt;}&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;derivation&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span&gt;          &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  name&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;hello-world&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span&gt;    &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  system&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;x86_64-linux&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  builder&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;pkgs&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;bash&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;/bin/bash&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span&gt;   &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  args&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span&gt; [&lt;/span&gt;&lt;span&gt;                 &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;-c&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;                                                                                                                               &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;                       &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    gcc $SOURCE -o $out         &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  ]&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  PATH&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;pkgs&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;gcc&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;/bin&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  SOURCE&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; builtins&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;toFile&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;main.c&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    #include &amp;quot;stdio.h&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;  &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    void main() {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;      printf(&amp;quot;Hello World\n&amp;quot;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Nous utilisons la varaible d’environnement “$SOURCE” pour stocker un chemin de fichier local que l’on génère directement à partir de la fonction &lt;code&gt;toFile&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;C’est très bien si l’on a qu’un seul fichier mais si l’on commence à faire grandir le projet ça va devenir de plus en plus compliqué de suivre la cadence.&lt;/p&gt;
&lt;p&gt;Exemple deux fichiers de sources nous donne:&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;nix&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-10&quot;&gt;with&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt; import&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;fetchTarball&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;https://github.com/NixOS/nixpkgs/archive/release-21.11.tar.gz&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span&gt;}&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;derivation&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span&gt;          &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  name&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;hello-world&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span&gt;    &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  system&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;x86_64-linux&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  builder&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;pkgs&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;bash&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;/bin/bash&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span&gt;   &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  args&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span&gt; [&lt;/span&gt;&lt;span&gt;                 &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;-c&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;                                                                                                                               &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    mkdir src&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    cd src&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    ln -s $SOURCE main.c&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    ln -s $SOURCE2 hello.c                       &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    gcc main.c -o $out         &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  ]&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  PATH&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;pkgs&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;gcc&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;/bin:&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;pkgs&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;coreutils&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;/bin&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  SOURCE&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; builtins&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;toFile&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;main.c&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    #include &amp;quot;stdio.h&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    #include &amp;quot;hello.c&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;  &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    void main() {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;      printf(&amp;quot;%s\n&amp;quot;, hello());&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;   SOURCE2&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; builtins&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;toFile&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;hello.c&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    const char* hello() {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;      return &amp;quot;Hello World&amp;quot;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;On introduit la dérivations &lt;code&gt;pkgs.coreutils&lt;/code&gt; qui contient les commandes &lt;code&gt;ln&lt;/code&gt; et &lt;code&gt;mkdir&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;On créé un dossier “src” et on rentre dedans&lt;/li&gt;
&lt;li&gt;On symlink les sources dedans&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Et si on veut le faire de manière cannonique, il faut en plus rajouter un header.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;nix&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-10&quot;&gt;with&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt; import&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;fetchTarball&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;https://github.com/NixOS/nixpkgs/archive/release-21.11.tar.gz&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span&gt;}&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;derivation&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span&gt;          &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  name&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;hello-world&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span&gt;    &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  system&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;x86_64-linux&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  builder&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;pkgs&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;bash&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;/bin/bash&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span&gt;   &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  args&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span&gt; [&lt;/span&gt;&lt;span&gt;                 &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;-c&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;                                                                                                                               &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    mkdir src&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    cd src&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    ln -s $SOURCE main.c&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    ln -s $SOURCE2 hello.c&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    ln -s $HEADER  hello.h                       &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    gcc main.c hello.c -o $out         &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  ]&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  PATH&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;pkgs&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;gcc&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;/bin:&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;pkgs&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;coreutils&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;/bin&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  SOURCE&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; builtins&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;toFile&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;main.c&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    #include &amp;quot;stdio.h&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    #include &amp;quot;hello.h&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;  &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    void main() {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;      printf(&amp;quot;%s\n&amp;quot;, hello());&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  HEADER&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; builtins&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;toFile&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;hello.h&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;      const char* hello();   &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  SOURCE2&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; builtins&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;toFile&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;hello.c&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    #include &amp;quot;hello.h&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    const char* hello() {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;      return &amp;quot;Hello World&amp;quot;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Si en plus, nous voulons respecter les standards, on peut même se créer le Makefile. 😇&lt;/p&gt;
&lt;p&gt;Mais pour ce faire nous allons déporter nos sources.&lt;/p&gt;
&lt;h2 id=&quot;fetch&quot;&gt;Fetch&lt;/h2&gt;
&lt;p&gt;Pour tester cela, j’ai créé un projet sur &lt;a rel=&quot;nofollow noreferrer external&quot; href=&quot;https://github.com/Akanoa/nix-hello&quot;&gt;github&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Nous avons appris de notre erreur, il nous faut quelque chose de stable dans le temps, de reproductible.&lt;/p&gt;
&lt;p&gt;L’intérêt de git est de créer des signatures uniques pour chaque modification. Nous allons utiliser cette propriété pour s’assurer de la
stabilité de notre dérivation.&lt;/p&gt;
&lt;p&gt;Sur github, il est possible de voir tous les &lt;a rel=&quot;nofollow noreferrer external&quot; href=&quot;https://github.com/Akanoa/nix-hello/commits/main&quot;&gt;commits&lt;/a&gt; d’une branche.&lt;/p&gt;
&lt;p&gt;Et ainsi récupérer le SHA1 de ce commit.&lt;/p&gt;
&lt;p&gt;On peut alors récupérer les sources sous la forme d’une archive via une URL formatée comme suit:&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;https://github.com/&amp;lt;projet&amp;gt;/archive/&amp;lt;SHA1&amp;gt;.tar.gz&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Mon commit est le &lt;code&gt;639841dcbc59ed24a461a9dadf6234073cdafad0&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Essayons de récupérer les sources, pour cela nous allons réutiliser la commande &lt;code&gt;fetchTarball&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; fetchTarball &amp;quot;https://github.com/Akanoa/nix-hello/archive/639841dcbc59ed24a461a9dadf6234073cdafad0.tar.gz&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&amp;quot;/nix/store/83z8gfh3lmi8psikgv39fpl67awkg4fg-source&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$ ls -l /nix/store/83z8gfh3lmi8psikgv39fpl67awkg4fg-source&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;-r--r--r-- 1 root root   70 janv.  1  1970 hello.c&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;-r--r--r-- 1 root root   20 janv.  1  1970 hello.h&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;-r--r--r-- 1 root root 1295 janv.  1  1970 LICENSE&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;-r--r--r-- 1 root root   90 janv.  1  1970 main.c&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;-r--r--r-- 1 root root   42 janv.  1  1970 Makefile&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;-r--r--r-- 1 root root   83 janv.  1  1970 README.md&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Magnifique, nous avons nos sources. 😃&lt;/p&gt;
&lt;p&gt;Pour les construire, nous allons utiliser la méthode standard du Makefile.&lt;/p&gt;
&lt;p&gt;Pour constuire les sources, il faut s’y déplacer puis lancer la commande &lt;code&gt;make&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Le Makefile ressemble à ceci:&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;make&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;all&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span&gt; main.c &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	gcc main.c hello.c -o &lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;out&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;On remarque le &lt;code&gt;${out}&lt;/code&gt; qui est directement défini par la dérivation. La sortie de compilation sera au bon endroit.&lt;/p&gt;
&lt;p&gt;Nous pouvons créer la dérivation qui va bien.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; :b with import (fetchTarball &amp;quot;https://github.com/NixOS/nixpkgs/archive/release-21.11.tar.gz&amp;quot;) {};&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;derivation {          &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  name = &amp;quot;hello-world&amp;quot;;    &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  system = &amp;quot;x86_64-linux&amp;quot;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  builder = &amp;quot;${pkgs.bash}/bin/bash&amp;quot;;   &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  args = [                 &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;quot;-c&amp;quot;                                                                                                                               &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    cd $SOURCE                   &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    make        &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  ];&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  PATH = &amp;quot;${pkgs.gcc}/bin:${pkgs.coreutils}/bin:${pkgs.gnumake}/bin&amp;quot;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  SOURCE = fetchTarball &amp;quot;https://github.com/Akanoa/nix-hello/archive/639841dcbc59ed24a461a9dadf6234073cdafad0.tar.gz&amp;quot;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;This derivation produced the following outputs:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  out -&amp;gt; /nix/store/mbx1qs39fgqiyfiikfx98gbs9vvqqxnm-hello-world&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$ /nix/store/mbx1qs39fgqiyfiikfx98gbs9vvqqxnm-hello-world&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Hello world!&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;De cette manière les sources de la dérivations ne sont plus contenues par elle, mais déportées tout en conservant l’aspect de reproductibilité.&lt;/p&gt;
&lt;p&gt;En parlant de reproductibilité, nous pouvons faire mieux. 😃&lt;/p&gt;
&lt;h2 id=&quot;checksum&quot;&gt;Checksum&lt;/h2&gt;
&lt;p&gt;Nix propose un outil &lt;code&gt;nix-prefetch-url&lt;/code&gt; pour calculer la somme de contrôle ou &lt;em&gt;checksum&lt;/em&gt; de ce que l’on télécharge.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$ nix-prefetch-url --unpack https://github.com/Akanoa/nix-hello/archive/639841dcbc59ed24a461a9dadf6234073cdafad0.tar.gz&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;path is &amp;#39;/nix/store/livh28m4dpk96q347s8j17fv2k5drb8g-639841dcbc59ed24a461a9dadf6234073cdafad0.tar.gz&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;0pvjw2kf0fwv569j2caqc983qk3x78znj52brr1a0av8f2c8rwjl&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;blockquote class=&quot;markdown-alert-warning&quot;&gt;
	&lt;p&gt;&lt;strong&gt;Attention!&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;L’argument &lt;code&gt;--unpack&lt;/code&gt; est important, car sinon c’est la signature n’est pas correcte, en effet le &lt;code&gt;fetchTarball&lt;/code&gt; procède au désarchivage du tar.gz après
son téléchargement.&lt;/p&gt;
&lt;p&gt;Sans &lt;code&gt;--unpack&lt;/code&gt; on calcule la signature de l’archive pas de son contenu&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$ nix-prefetch-url https://github.com/Akanoa/nix-hello/archive/639841dcbc59ed24a461a9dadf6234073cdafad0.tar.gz&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;path is &amp;#39;/nix/store/qi5nmqi9np2jbjw4f52zakr10pa6j4pr-639841dcbc59ed24a461a9dadf6234073cdafad0.tar.gz&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;1wh3vf4ydvvxyiw18wwdyr1xgcqpxnlrl0wl2wcjsysflbrxlhgp&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;p&gt;D’ailleurs, si l’on utilise le mauvais checksum:&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; :b with import (fetchTarball &amp;quot;https://github.com/NixOS/nixpkgs/archive/release-21.11.tar.gz&amp;quot;) {};&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;derivation {          &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  name = &amp;quot;hello-world&amp;quot;;    &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  system = &amp;quot;x86_64-linux&amp;quot;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  builder = &amp;quot;${pkgs.bash}/bin/bash&amp;quot;;   &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  args = [                 &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;quot;-c&amp;quot;                                                                                                                               &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    cd $SOURCE                   &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    make        &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  ];&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  PATH = &amp;quot;${pkgs.gcc}/bin:${pkgs.coreutils}/bin:${pkgs.gnumake}/bin&amp;quot;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  SOURCE = fetchTarball {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    url = &amp;quot;https://github.com/Akanoa/nix-hello/archive/639841dcbc59ed24a461a9dadf6234073cdafad0.tar.gz&amp;quot;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    sha256 = &amp;quot;1wh3vf4ydvvxyiw18wwdyr1xgcqpxnlrl0wl2wcjsysflbrxlhgp&amp;quot;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  };&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;error: hash mismatch in file downloaded from &amp;#39;https://github.com/Akanoa/nix-hello/archive/639841dcbc59ed24a461a9dadf6234073cdafad0.tar.gz&amp;#39;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  specified: sha256:1wh3vf4ydvvxyiw18wwdyr1xgcqpxnlrl0wl2wcjsysflbrxlhgp&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  got:       sha256:0pvjw2kf0fwv569j2caqc983qk3x78znj52brr1a0av8f2c8rwjl&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Le système signale une incohérence entre le checksum calculé d’une part et le checksum spécifié, d’autre part.&lt;/p&gt;
&lt;p&gt;Si le SHA1 correspond, le build est possible.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; :b with import (fetchTarball &amp;quot;https://github.com/NixOS/nixpkgs/archive/release-21.11.tar.gz&amp;quot;) {};&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;derivation {          &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  name = &amp;quot;hello-world&amp;quot;;    &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  system = &amp;quot;x86_64-linux&amp;quot;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  builder = &amp;quot;${pkgs.bash}/bin/bash&amp;quot;;   &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  args = [                 &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;quot;-c&amp;quot;                                                                                                                               &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    cd $SOURCE                   &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    make        &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  ];&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  PATH = &amp;quot;${pkgs.gcc}/bin:${pkgs.coreutils}/bin:${pkgs.gnumake}/bin&amp;quot;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  SOURCE = fetchTarball {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    url = &amp;quot;https://github.com/Akanoa/nix-hello/archive/639841dcbc59ed24a461a9dadf6234073cdafad0.tar.gz&amp;quot;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    sha256 = &amp;quot;0pvjw2kf0fwv569j2caqc983qk3x78znj52brr1a0av8f2c8rwjl&amp;quot;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  };&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;This derivation produced the following outputs:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  out -&amp;gt; /nix/store/mbx1qs39fgqiyfiikfx98gbs9vvqqxnm-hello-world&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Et on peut faire de de même avec le &lt;code&gt;nixpkgs&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$ nix-prefetch-url --unpack https://github.com/NixOS/nixpkgs/archive/release-21.11.tar.gz&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;1xk1f62n00z7q5i3pf4c8c4rlv5k4jwpgh0pqgzw1l40vhdkixk9&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;On peut alors fixé également spécifier le SHA1 du &lt;code&gt;nixpkgs&lt;/code&gt; dans la dérivation.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;nix&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-10&quot;&gt;with&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt; import&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;fetchTarball&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  url&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;https://github.com/NixOS/nixpkgs/archive/release-21.11.tar.gz&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  sha256&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;1xk1f62n00z7q5i3pf4c8c4rlv5k4jwpgh0pqgzw1l40vhdkixk9&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span&gt;}&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;derivation&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span&gt;          &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  name&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;hello-world&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span&gt;    &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  system&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;x86_64-linux&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  builder&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;pkgs&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;bash&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;/bin/bash&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span&gt;   &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  args&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span&gt; [&lt;/span&gt;&lt;span&gt;                 &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;-c&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;                                                                                                                               &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    cd $SOURCE                   &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    make        &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  ]&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  PATH&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;pkgs&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;gcc&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;/bin:&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;pkgs&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;coreutils&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;/bin:&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;pkgs&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;gnumake&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;/bin&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  SOURCE&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; fetchTarball&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;    url&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;https://github.com/Akanoa/nix-hello/archive/639841dcbc59ed24a461a9dadf6234073cdafad0.tar.gz&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;    sha256&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;0pvjw2kf0fwv569j2caqc983qk3x78znj52brr1a0av8f2c8rwjl&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  }&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Là on commence à avoir quelque chose qui a de la gueule! 🤩&lt;/p&gt;
&lt;p&gt;Ainsi, même si les données pointée par l’URL changent, nous sommes capable de le détecter et d’annuler la réalisation de la dérivation.&lt;/p&gt;
&lt;p&gt;Ce mécanisme permet de s’assurer que les sources n’ont pas été corrompues d’une manière ou d’une autre.&lt;/p&gt;
&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Nous commençons à nous rapprocher d’une dérivation qui est utilisable pour de vrais projets.&lt;/p&gt;
&lt;p&gt;Dans la &lt;a href=&quot;/nix-6&quot;&gt;partie 6&lt;/a&gt;, nous verrons comment construire des projets plus normalisés via &lt;code&gt;mkDerivation&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Merci de votre lecture ❤️&lt;/p&gt;
</content>
        
    </entry>
    <entry xml:lang="fr">
        <title>Partie 4 : Contraindre une dérivation</title>
        <published>2023-04-20T00:00:00+00:00</published>
        <updated>2023-04-20T00:00:00+00:00</updated>
        
        <author>
          <name>Unknown</name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://staging.lafor.ge/nix-4/"/>
        <id>https://staging.lafor.ge/nix-4/</id>
        
        <content type="html" xml:base="https://staging.lafor.ge/nix-4/">&lt;details &gt;
	&lt;summary&gt;&lt;span&gt;Les articles de la série&lt;/span&gt;&lt;/summary&gt;
	&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;/nix-1&quot;&gt;Partie 1&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;/nix-2&quot;&gt;Partie 2&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;/nix-3&quot;&gt;Partie 3&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;/nix-5&quot;&gt;Partie 5&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;/nix-6&quot;&gt;Partie 6&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;/details&gt;
&lt;p&gt;Bonjour à toutes et tous! 😀&lt;/p&gt;
&lt;p&gt;Quatrième article sur Nix.&lt;/p&gt;
&lt;h2 id=&quot;bilan-de-la-situation&quot;&gt;Bilan de la situation&lt;/h2&gt;
&lt;p&gt;Dans la &lt;a href=&quot;/nix-3&quot;&gt;partie 3&lt;/a&gt;, nous avons réussi à compiler du C.&lt;/p&gt;
&lt;p&gt;Cependant, nous n’avons pas tout fixé, seuls nos sources sont déterministes.&lt;/p&gt;
&lt;p&gt;On a deux points flottants:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;le &lt;code&gt;/bin/sh&lt;/code&gt; on ne sait pas d’où il vient&lt;/li&gt;
&lt;li&gt;la dérivation du &lt;code&gt;gcc&lt;/code&gt; vient d’un &lt;code&gt;&amp;lt;nixpkgs&amp;gt;&lt;/code&gt; dont on ne connait pas la version&lt;/li&gt;
&lt;/ul&gt;
&lt;img class=&quot;&quot; width=&quot;100%&quot; src=&quot;/assets/images/nix/nix1.png&quot; /&gt;
&lt;h2 id=&quot;rendre-le-builder-deterministe&quot;&gt;Rendre le builder déterministe&lt;/h2&gt;
&lt;p&gt;Pour cela, nous allons déjà déterminer le &lt;code&gt;/bin/sh&lt;/code&gt; qui est-il? que fait-il dans sa vie?&lt;/p&gt;
&lt;p&gt;Générons une dérivation.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; derivation {          &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  name = &amp;quot;hello-world&amp;quot;;    &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  system = &amp;quot;x86_64-linux&amp;quot;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  builder = &amp;quot;/bin/sh&amp;quot;;   &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  args = [                 &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;quot;-c&amp;quot;                                                                                                                               &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;#39;&amp;#39;                       &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    gcc $SOURCE -o $out         &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  ];&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  PATH = &amp;quot;${pkgs.gcc}/bin&amp;quot;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  SOURCE = builtins.toFile &amp;quot;main.c&amp;quot; &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    #include &amp;quot;stdio.h&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    void main() {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      printf(&amp;quot;Hello World 1\n&amp;quot;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;#39;&amp;#39;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;«derivation /nix/store/i8r1j3d07w4rnzaj7rlsyh08jz2yc04f-hello-world.drv»&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Et buildons là en mode verbose à l’extérieur du repl.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; nix-build&lt;/span&gt;&lt;span class=&quot;z-l-4 z-d-11&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-l-4 z-d-11&quot;&gt;vvv&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; /nix/store/zhv7hwhhhql4jk8qklidwi0kdkkj9593-hello-world.drv&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; 2&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;&amp;gt;&amp;amp;1&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; |&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt; grep&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;sandbox setup: bind mounting&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;sandbox&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; setup:&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; bind&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; mounting&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;/nix/store/7b943a2k4amjmam6dnwnxnj8qbba9lbq-busybox-static-x86_64-unknown-linux-musl-1.35.0/bin/busybox&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; to&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;/nix/store/zhv7hwhhhql4jk8qklidwi0kdkkj9593-hello-world.drv.chroot/bin/sh&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Là c’est un peu les entrailles de la bête.&lt;/p&gt;
&lt;p&gt;Pour éviter tout parasites extérieurs, les builds de Nix sont réalisés dans une sandbox logicielle où tout est contrôlable.&lt;/p&gt;
&lt;p&gt;L’une des étapes, consiste à ajouter dans cette sandbox, un exécutable &lt;code&gt;/bin/sh&lt;/code&gt; provenant d’une version de &lt;a rel=&quot;nofollow noreferrer external&quot; href=&quot;https://busybox.net/&quot;&gt;busybox&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Mais cette version, est totalement dépendante de l’installation de Nix pour l’environnement de build et donc dépendant notamment de la version de Nix elle-même.&lt;/p&gt;
&lt;p&gt;Pour éviter le fameux, “mais ça marche sur mon laptop”.&lt;/p&gt;
&lt;p&gt;Nous devons vérouiller ce comportement.&lt;/p&gt;
&lt;p&gt;Pour cela nous allons utiliser un &lt;code&gt;bash&lt;/code&gt; provenant d’une dérivation que l’on souhaite devenir fixe.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; :b derivation {          &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  name = &amp;quot;hello-world&amp;quot;;    &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  system = &amp;quot;x86_64-linux&amp;quot;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  builder = &amp;quot;${pkgs.bash}/bin/bash&amp;quot;;   &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  args = [                 &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;quot;-c&amp;quot;                                                                                                                               &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;#39;&amp;#39;                       &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    gcc $SOURCE -o $out         &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  ];&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  PATH = &amp;quot;${pkgs.gcc}/bin&amp;quot;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  SOURCE = builtins.toFile &amp;quot;main.c&amp;quot; &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    #include &amp;quot;stdio.h&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    void main() {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      printf(&amp;quot;Hello World 1\n&amp;quot;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;#39;&amp;#39;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;This derivation produced the following outputs:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  out -&amp;gt; /nix/store/9rsg6zcismripg13mqi4yrmws5i9hq7j-hello-world&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Ok, mais nous avons juste caché la poussière sous le tapis.&lt;/p&gt;
&lt;p&gt;Le problème reste entier, on ne sait pas ce qu’est &lt;code&gt;&amp;lt;nixpkgs&amp;gt;&lt;/code&gt;, ou plutôt son état dépend de l’état d’installation de Nix.&lt;/p&gt;
&lt;p&gt;Ce n’est pas reproductible.&lt;/p&gt;
&lt;img class=&quot;&quot; width=&quot;100%&quot; src=&quot;/assets/images/nix/nix2.png&quot; /&gt;
&lt;h2 id=&quot;rendre-nixpkgs-deterministe&quot;&gt;Rendre &amp;lt;nixpkgs&amp;gt; déterministe&lt;/h2&gt;
&lt;p&gt;Heureusement, il est également possible de fixer cela également.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;&amp;lt;nixpkgs&amp;gt;&lt;/code&gt; n’est dans les faits qu’une itération parmis d’autres du &lt;a rel=&quot;nofollow noreferrer external&quot; href=&quot;https://github.com/NixOS/nixpkgs&quot;&gt;projet nixpkgs&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Nix fourni des outils pour rechercher de la donnée venant d’internet, comme &lt;a rel=&quot;nofollow noreferrer external&quot; href=&quot;https://nixos.org/manual/nix/stable/language/builtins.html#builtins-fetchGit&quot;&gt;fetchGit&lt;/a&gt; ou &lt;a rel=&quot;nofollow noreferrer external&quot; href=&quot;https://nixos.org/manual/nix/stable/language/builtins.html#builtins-fetchTarball&quot;&gt;fetchTarball&lt;/a&gt;.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; builtins.fetchTarball {                                                    &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  url = &amp;quot;https://github.com/NixOS/nixpkgs/archive/refs/tags/22.11.tar.gz&amp;quot;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}                                                                          &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&amp;quot;/nix/store/nkhjmzkf9hky9h34yrfy0cgyd9pbh03v-source&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; builtins.fetchTarball {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  url = &amp;quot;https://github.com/NixOS/nixpkgs/archive/refs/tags/22.05.tar.gz&amp;quot;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&amp;quot;/nix/store/di36mqc6y19ivaa4qjrb2l82c6dqg7m3-source&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;On a bien une unicité de l’empreinte selon la version de nixpgs que l’on télécharge.&lt;/p&gt;
&lt;p&gt;Voyons un peu ce qu’il y a dedans.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; tree&lt;/span&gt;&lt;span class=&quot;z-l-4 z-d-11&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-l-4 z-d-11&quot;&gt;L&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; 1&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; /nix/store/nkhjmzkf9hky9h34yrfy0cgyd9pbh03v-source&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;/nix/store/nkhjmzkf9hky9h34yrfy0cgyd9pbh03v-source&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;├──&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; CONTRIBUTING.md&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;├──&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; COPYING&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;├──&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; default.nix&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;├──&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; doc&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;├──&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; flake.nix&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;├──&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; lib&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;├──&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; maintainers&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;├──&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; nixos&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;├──&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; pkgs&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;└──&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; README.md&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Le dossier pkgs nous intéresse. ^^&lt;/p&gt;
&lt;h3 id=&quot;fonction-en-nix&quot;&gt;Fonction en Nix&lt;/h3&gt;
&lt;p&gt;Si je vous donne directement la méthode pour récupérer le pkgs de notre tarball vous aller avoir une syncope, donc nous allons y aller progressivement. 😅&lt;/p&gt;
&lt;p&gt;Cela, va nous donner un prétexte pour manipuler du Nix et un peu mieux comprendre ce que l’on fera dans les parties suivantes. ^^&lt;/p&gt;
&lt;p&gt;D’abord la notion fonction en Nix.&lt;/p&gt;
&lt;p&gt;Le &lt;code&gt;x&lt;/code&gt; à gauche des deux-points &lt;code&gt;:&lt;/code&gt; est le paramètre de la fonction. Ce qui est à droite est le corps de la fonction.&lt;/p&gt;
&lt;p&gt;Cette fonction est stockée dans la varible &lt;code&gt;inc&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Qui peut ensuite être appelée et donc évaluée avec une valeur, ici 2.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; inc = x : x + 1                &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; inc 2                          &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;3&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;On peut mettre autant de paramètres que l’on veut, il suffit de les séparer par des &lt;code&gt;:&lt;/code&gt;. Le dernier élément sera le corps de la fonction.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; inc_by = x : by : x + by       &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; inc_by 4 3                     &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;7&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;En vrai, il s’agit d’une fonction qui renvoit une fonction.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; inc_by = x : ( by : x + by )&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; inc_by 4 3                   &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;7&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Une fonction peut également prendre un set comme paramètre d’entrée.&lt;/p&gt;
&lt;p&gt;Ici un set à deux attributs:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;x&lt;/li&gt;
&lt;li&gt;by&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Pour l’appeler, il faut donc lui passer le set correspondant.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;nix&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  x&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; 7&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  y&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; 3&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; inc_by_object = { x, by } :  x + by&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; inc_by_object { x = 7; by = 3; }    &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;10&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&quot;attribut-par-defaut&quot;&gt;Attribut par défaut&lt;/h3&gt;
&lt;p&gt;Il est également possible d’omettre un paramètre en fournissant un attribut par défaut.&lt;/p&gt;
&lt;p&gt;Via la syntaxe&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;nix&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; x&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; ?&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; 3&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;span&gt; :&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; x&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Si x est défini dans le paramètre d’entré, alors il est utilisé, sinon c’est la valeur 3 qui remplace x.&lt;/p&gt;
&lt;p&gt;On peut alors utiliser cette propriété:&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; inc_by_object_optional = { x, by ? 1 } :  x + by&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; inc_by_object_optional { x = 7; by = 3; }    &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;10&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; inc_by_object_optional { x = 7; }    &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;8&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&quot;contexte&quot;&gt;Contexte&lt;/h3&gt;
&lt;p&gt;Nix, possède une autre particularité, il s’agit des contextes.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;nix&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-10&quot;&gt;let&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt; default&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; 12&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-10&quot;&gt;in&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; x&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; ?&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; default&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;span&gt; :&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; x&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;let&lt;/code&gt; définit qu’une variable est déclarée et que celle-ci est disponible dans le contexte suivant le mot-clef &lt;code&gt;in&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; l = let default = 12;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  in&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  { x ? default } : x&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; l { x = 3; }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;3&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; l {}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;12&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Si l’on passe un objet contenant un attribut &lt;code&gt;x&lt;/code&gt;, il est utilisé, si on ne passe rien c’est &lt;code&gt;default&lt;/code&gt; qui sera évalué en tant que &lt;code&gt;x&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Petit sucre syntaxique.&lt;/p&gt;
&lt;p&gt;Il n’est pas nécessaire de stocker la fonction et son contexte dans une variable, nous pouvons l’appeler directement.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;nix&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;nix-repl&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-10&quot;&gt; let&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt; default&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; 12&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-10&quot;&gt;  in&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  {&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; x&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; ?&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; default&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;span&gt; :&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; x&lt;/span&gt;&lt;span&gt; )&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;12&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;nix-repl&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-10&quot;&gt; let&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt; default&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; 12&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-10&quot;&gt;  in&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  {&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; x&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; ?&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; default&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;span&gt; :&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; x&lt;/span&gt;&lt;span&gt; )&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt; x&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; 3&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;3&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&quot;import&quot;&gt;Import&lt;/h3&gt;
&lt;p&gt;Enfin, la méthode &lt;code&gt;import&lt;/code&gt; permet de charger les dérivations dans le contexte.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; nixpkgs = import (fetchTarball &amp;quot;https://github.com/NixOS/nixpkgs/archive/release-21.05.tar.gz&amp;quot;) {}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; nixpkgs.pkgs.gcc                                                                                   &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;«derivation /nix/store/91r1rsrc9mjh8xcppfm071lv8p46a45a-gcc-wrapper-10.3.0.drv»&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&quot;le-bout-du-chemin&quot;&gt;Le bout du chemin&lt;/h3&gt;
&lt;p&gt;Si vous avez survécu jusque là, félicitations à vous. 😇&lt;/p&gt;
&lt;p&gt;Il est temps de rassembler le tout.&lt;/p&gt;
&lt;p&gt;Dans l’ordre:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;on &lt;code&gt;fetchTarball&lt;/code&gt; les sources à la version voulue&lt;/li&gt;
&lt;li&gt;on &lt;code&gt;import&lt;/code&gt; les dérivations&lt;/li&gt;
&lt;li&gt;on stocke dans la variable &lt;code&gt;nixpkgs&lt;/code&gt; les dérivations&lt;/li&gt;
&lt;li&gt;on défini avec &lt;code&gt;let&lt;/code&gt; et &lt;code&gt;in&lt;/code&gt; un contexte où &lt;code&gt;nixpkgs&lt;/code&gt; existe&lt;/li&gt;
&lt;li&gt;dans ce contexte on créer une fonction qui prend un paramètre optionel &lt;code&gt;pkgs&lt;/code&gt; qui a pour valeur par défaut &lt;code&gt;nixpkgs.pkgs&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;le corps de cette fonction est notre dérivation utilisant le paramètre &lt;code&gt;pkgs&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;on appelle la fonction sans paramètre ce qui a pour effet de déclencher l’utilisation de la valeur par défaut du champ &lt;code&gt;pkgs&lt;/code&gt;, donc la valeur de &lt;code&gt;pkgs == nixpkgs.pkgs&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;En code ça donne ça:&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;nix&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-10&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;nixpkgs&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt; import&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;fetchTarball&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;https://github.com/NixOS/nixpkgs/archive/release-21.11.tar.gz&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span&gt;}&lt;/span&gt;&lt;span&gt; ;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-10&quot;&gt;in&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; pkgs&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; ?&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; nixpkgs&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;pkgs&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;span&gt; :&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;derivation&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span&gt;          &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  name&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;hello-world&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span&gt;    &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  system&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;x86_64-linux&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  builder&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;pkgs&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;bash&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;/bin/bash&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span&gt;   &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  args&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span&gt; [&lt;/span&gt;&lt;span&gt;                 &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;-c&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;                                                                                                                               &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;                       &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    gcc $SOURCE -o $out         &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  ]&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  PATH&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;pkgs&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;gcc&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;/bin&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  SOURCE&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; builtins&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;toFile&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;main.c&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    #include &amp;quot;stdio.h&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;  &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    void main() {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;      printf(&amp;quot;Hello World\n&amp;quot;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;{&lt;/span&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;On est d’accord, c’est pas top. Mais j’ai pas trouvé plus simple… (c’est faux) 🥲&lt;/p&gt;
&lt;p&gt;Par contre, c’est pratique pour tester notre théorie ^^&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; :b (let &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nixpkgs = import (fetchTarball &amp;quot;https://github.com/NixOS/nixpkgs/archive/release-21.05.tar.gz&amp;quot;) {} ;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;in&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{ pkgs ? nixpkgs.pkgs } : &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;derivation { ... }){}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;This derivation produced the following outputs:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  out -&amp;gt; /nix/store/15xyifj30dmivl2j5frfym0081wmi7p9-hello-world&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; :b (let &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nixpkgs = import (fetchTarball &amp;quot;https://github.com/NixOS/nixpkgs/archive/release-21.11.tar.gz&amp;quot;) {} ;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;in&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{ pkgs ? nixpkgs.pkgs } : &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;derivation { ... }){}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;This derivation produced the following outputs:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  out -&amp;gt; /nix/store/dab6w96pj7vgrw3n64kk4c8d819w08lc-hello-world&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Pour deux &lt;code&gt;&amp;lt;nixpkgs&amp;gt;&lt;/code&gt; différents, nous avons bien deux empreintes différentes et reproductibles ! 🎉&lt;/p&gt;
&lt;p&gt;On peut cocher tout le monde ^^&lt;/p&gt;
&lt;img class=&quot;&quot; width=&quot;100%&quot; src=&quot;/assets/images/nix/nix3.png&quot; /&gt;
&lt;h2 id=&quot;simplifier-notre-derivation&quot;&gt;Simplifier notre dérivation&lt;/h2&gt;
&lt;p&gt;Alors en fait, on peut dratisquement simlplifier tout ça, mais je ne l’ai trouvé qu’après coup… ^^’&lt;/p&gt;
&lt;p&gt;La première avancée, est qu’on peut se débarasser de la fonction et de l’attribut optionnel.&lt;/p&gt;
&lt;h3 id=&quot;operateur-with&quot;&gt;Opérateur with&lt;/h3&gt;
&lt;p&gt;En utilisant le mot clef &lt;code&gt;with&lt;/code&gt;, qui a pour rôle de démonter une structure et de mettre chacun de ses attributs dans le
contexte courant.&lt;/p&gt;
&lt;p&gt;Donc &lt;code&gt;pkgs&lt;/code&gt; de &lt;code&gt;nixpkgs.pkgs&lt;/code&gt; devient disponible après le &lt;code&gt;with&lt;/code&gt; pour le corps de la dérivation.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;nix&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-10&quot;&gt;let&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;nixpkgs&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt; import&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;fetchTarball&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;https://github.com/NixOS/nixpkgs/archive/release-21.11.tar.gz&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span&gt;}&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-10&quot;&gt;in&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-10&quot;&gt;with&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; nixpkgs&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;derivation&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span&gt;          &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  name&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;hello-world&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span&gt;    &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  system&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;x86_64-linux&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  builder&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;pkgs&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;bash&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;/bin/bash&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span&gt;   &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  args&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span&gt; [&lt;/span&gt;&lt;span&gt;                 &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;-c&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;                                                                                                                               &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;                       &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    gcc $SOURCE -o $out         &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  ]&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  PATH&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;pkgs&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;gcc&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;/bin&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  SOURCE&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; builtins&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;toFile&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;main.c&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    #include &amp;quot;stdio.h&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;  &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    void main() {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;      printf(&amp;quot;Hello World\n&amp;quot;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&quot;se-debarasser-du-contexte&quot;&gt;Se débarasser du contexte&lt;/h3&gt;
&lt;p&gt;Et comme nous n’avons pas non plus besoin d’isolation de contexte, on peut également faire sauter le &lt;code&gt;let&lt;/code&gt; et le &lt;code&gt;in&lt;/code&gt;&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;nix&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-10&quot;&gt;with&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt; import&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;fetchTarball&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;https://github.com/NixOS/nixpkgs/archive/release-21.11.tar.gz&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span&gt;}&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;derivation&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span&gt;          &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  name&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;hello-world&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span&gt;    &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  system&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;x86_64-linux&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  builder&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;pkgs&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;bash&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;/bin/bash&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span&gt;   &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  args&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span&gt; [&lt;/span&gt;&lt;span&gt;                 &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;-c&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;                                                                                                                               &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;                       &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    gcc $SOURCE -o $out         &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  ]&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  PATH&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;gcc&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;/bin&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;  SOURCE&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; builtins&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;toFile&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;main.c&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    #include &amp;quot;stdio.h&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;  &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    void main() {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;      printf(&amp;quot;Hello World\n&amp;quot;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Et là tout de suite, ça respire! 😄&lt;/p&gt;
&lt;p&gt;J’ai laissé dans l’article le chemin de croix, parce que ça fait manipuler le langage et c’est pas pire, même si le résultat était désastreux. 🤣&lt;/p&gt;
&lt;blockquote class=&quot;markdown-alert-note&quot;&gt;
	&lt;p&gt;&lt;strong&gt;Remarque&lt;/strong&gt;&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;PATH = &amp;quot;${pkgs.gcc}/bin&amp;quot;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Peut se remplacer en&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;PATH = &amp;quot;${gcc}/bin&amp;quot;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Car, &lt;code&gt;&amp;lt;nixpkgs&amp;gt;&lt;/code&gt; expose directement &lt;code&gt;pkgs&lt;/code&gt;, l’import est donc capable d’aller chercher les dérivations du dossier &lt;code&gt;pkgs&lt;/code&gt; et de les exposer.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Nous avons enfin une dérivation reproductible capable de compiler du C.&lt;/p&gt;
&lt;p&gt;Dans la &lt;a href=&quot;/nix-5&quot;&gt;partie 5&lt;/a&gt;, nous verrons comment déporter les sources de la dérivations.&lt;/p&gt;
&lt;p&gt;Merci de votre lecture ❤️&lt;/p&gt;
</content>
        
    </entry>
    <entry xml:lang="fr">
        <title>Partie 3 : Première utilisation de Nixpkgs</title>
        <published>2023-04-19T00:00:00+00:00</published>
        <updated>2023-04-19T00:00:00+00:00</updated>
        
        <author>
          <name>Unknown</name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://staging.lafor.ge/nix-3/"/>
        <id>https://staging.lafor.ge/nix-3/</id>
        
        <content type="html" xml:base="https://staging.lafor.ge/nix-3/">&lt;details &gt;
	&lt;summary&gt;&lt;span&gt;Les articles de la série&lt;/span&gt;&lt;/summary&gt;
	&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;/nix-1&quot;&gt;Partie 1&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;/nix-2&quot;&gt;Partie 2&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;/nix-4&quot;&gt;Partie 4&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;/nix-5&quot;&gt;Partie 5&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;/nix-6&quot;&gt;Partie 6&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;/details&gt;
&lt;p&gt;Bonjour à toutes et tous! 😀&lt;/p&gt;
&lt;p&gt;Troisième article sur Nix.&lt;/p&gt;
&lt;h2 id=&quot;nixpkgs&quot;&gt;Nixpkgs&lt;/h2&gt;
&lt;p&gt;Dans la &lt;a href=&quot;/nix-2&quot;&gt;partie 2&lt;/a&gt;, nous avons réalisé une dérivation, mais elle ne fait quasiment rien, et surtout pas ce que l’on veut.&lt;/p&gt;
&lt;p&gt;C’est à dire &lt;a href=&quot;/nix-2/#le-paquet-que-l-on-veut-creer&quot;&gt;compiler du C&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;On a besoin de plus! On a besoin d’un compilateur! On a besoin de gcc.&lt;/p&gt;
&lt;p&gt;Et donc de sa dérivation ou au moins de son paquet.&lt;/p&gt;
&lt;p&gt;Pour cela nous allons appeler repl différemment.&lt;/p&gt;
&lt;p&gt;Nous rajoutons un argument &lt;code&gt;--file &#39;&amp;lt;nixpkgs&amp;gt;&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$ nix repl --file &amp;#39;&amp;lt;nixpkgs&amp;gt;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Welcome to Nix 2.15.0. Type :? for help.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Loading installable &amp;#39;&amp;#39;...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Added 18779 variables.&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Ah! Il y a du changement, il nous dit qu’il a chargé plein de variables.&lt;/p&gt;
&lt;p&gt;Le ‘&amp;lt;nixpkgs&amp;gt;’ est un alias pour dire d’aller chercher toutes les dérivations de &lt;a rel=&quot;nofollow noreferrer external&quot; href=&quot;https://github.com/NixOS/nixpkgs&quot;&gt;nixpkgs&lt;/a&gt;, le repo officiel de Nix.&lt;/p&gt;
&lt;p&gt;Donc maintenant dans votre repl, vous avez accès à toutes les dérivations qui ont pu être faites par la communautée.&lt;/p&gt;
&lt;p&gt;Exemple, &lt;code&gt;gcc&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Lorsque l’on a fait un&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; nix-shell&lt;/span&gt;&lt;span class=&quot;z-l-4 z-d-11&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-l-4 z-d-11&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; gcc&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;On a dans les faits déclaré un environnement où le paquet “gcc” était disponible.&lt;/p&gt;
&lt;p&gt;Dans le repl, on peut faire de même, la variable qui nous intéresse est &lt;code&gt;pkgs&lt;/code&gt;, elle contient toutes les dérivations. Dont celle de gcc.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; pkgs.gcc&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;«derivation /nix/store/wfb8f6nsrnfhpw7ya1dwj3k9d4vx6li1-gcc-wrapper-12.2.0.drv»&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;On peut d’ailleurs aller voir à quoi elle ressemble.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$ nix derivation show /nix/store/wfb8f6nsrnfhpw7ya1dwj3k9d4vx6li1-gcc-wrapper-12.2.0.drv&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  &amp;quot;/nix/store/wfb8f6nsrnfhpw7ya1dwj3k9d4vx6li1-gcc-wrapper-12.2.0.drv&amp;quot;: {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;quot;args&amp;quot;: [&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      &amp;quot;-e&amp;quot;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      &amp;quot;/nix/store/6xg259477c90a229xwmb53pdfkn6ig3g-default-builder.sh&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    ],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;quot;name&amp;quot;: &amp;quot;gcc-wrapper-12.2.0&amp;quot;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;quot;builder&amp;quot;: &amp;quot;/nix/store/dsn6vl7x1hbn1akgpxync19gpx2dzy8w-bootstrap-tools/bin/bash&amp;quot;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;quot;env&amp;quot;: {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      &amp;quot;out&amp;quot; : &amp;quot;/nix/store/nlgyw2fv0cm8rkz8qm1jyw78vyif1bl9-gcc-wrapper-12.2.0&amp;quot;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      ...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;quot;system&amp;quot;: &amp;quot;x86_64-linux&amp;quot;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    ...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;( J’ai tronqué plein de champ, sinon c’était trop long )&lt;/p&gt;
&lt;p&gt;Mais comme vous pouvez le voir, ça reste une dérivation “classique”.&lt;/p&gt;
&lt;h2 id=&quot;builder-avec-gcc&quot;&gt;Builder avec gcc&lt;/h2&gt;
&lt;p&gt;Testons d’appeler gcc dans notre builder.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; :b derivation {          &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  name = &amp;quot;hello-world&amp;quot;;    &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  system = &amp;quot;x86_64-linux&amp;quot;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  builder = &amp;quot;/bin/sh&amp;quot;;   &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  args = [                 &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;quot;-c&amp;quot;                                                                                                                               &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;#39;&amp;#39;                       &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    gcc --version &amp;gt; $out         &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  ];&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;error: builder for &amp;#39;/nix/store/bfrw7x8b09r53fkhmif89jslcv0zr0fp-hello-world.drv&amp;#39; failed with exit code 127;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;       last 1 log lines:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;       &amp;gt; sh: gcc: not found&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;       For full logs, run &amp;#39;nix-store -l /nix/store/bfrw7x8b09r53fkhmif89jslcv0zr0fp-hello-world.drv&amp;#39;.&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Arf! 😩&lt;/p&gt;
&lt;p&gt;Bon petite expérience, où est gcc sur le disque?&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; nix-shell&lt;/span&gt;&lt;span class=&quot;z-l-4 z-d-11&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-l-4 z-d-11&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; gcc&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[&lt;/span&gt;&lt;span&gt;nix-shell:/dir&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt;$ which gcc&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;/nix/store/nlgyw2fv0cm8rkz8qm1jyw78vyif1bl9-gcc-wrapper-12.2.0/bin/gcc&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Ok, donc c’est du “$out/bin/gcc”. Très bien.&lt;/p&gt;
&lt;p&gt;Retour au repl.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl &amp;gt; &amp;quot;${pkgs.gcc}&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[nix-shell:~/Documents/Workshop/nix/hello]$ which gcc&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;/nix/store/nlgyw2fv0cm8rkz8qm1jyw78vyif1bl9-gcc-wrapper-12.2.0&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Ok, donc interpoler une dérivation donne le chemin de sortie de cette dérivation&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl &amp;gt; &amp;quot;${pkgs.gcc}/bin/gcc&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[nix-shell:~/Documents/Workshop/nix/hello]$ which gcc&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;/nix/store/nlgyw2fv0cm8rkz8qm1jyw78vyif1bl9-gcc-wrapper-12.2.0/bin/gcc&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;On peut également concaténer des chaîne de caratères. Maintenant le chemin est complet.&lt;/p&gt;
&lt;p&gt;Plus qu’à l’introduire dans le builder et l’affaire est dans le sac.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; :b derivation {          &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  name = &amp;quot;hello-world&amp;quot;;    &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  system = &amp;quot;x86_64-linux&amp;quot;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  builder = &amp;quot;/bin/sh&amp;quot;;   &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  args = [                 &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;quot;-c&amp;quot;                                                                                                                               &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;#39;&amp;#39;                       &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    ${pkgs.gcc}/bin/gcc --version &amp;gt; $out         &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  ];&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;This derivation produced the following outputs:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  out -&amp;gt; /nix/store/kzwd92if64f115pvg46n7sdc1x2wp6ir-hello-world&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; :e /nix/store/kzwd92if64f115pvg46n7sdc1x2wp6ir-hello-world&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;gcc (GCC) 12.2.0&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Copyright (C) 2022 Free Software Foundation, Inc.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;This is free software; see the source for copying conditions.  There is NO&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Et boom ! on a gcc ! 💥&lt;/p&gt;
&lt;h2 id=&quot;modifier-le-path&quot;&gt;Modifier le PATH&lt;/h2&gt;
&lt;p&gt;Oui mais c’est pas top, les scripts de build standards n’auront jamais &lt;code&gt;${pkgs.gcc}/bin/gcc&lt;/code&gt; seulement &lt;code&gt;gcc&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Pour résoudre le problème, on doit ramener gcc dans le PATH du builder&lt;/p&gt;
&lt;p&gt;On va introduire une nouvelle règle de la fonction derivation.&lt;/p&gt;
&lt;p&gt;Qui dit que l’on peut générer des variables d’environnements comme bon nous semble.&lt;/p&gt;
&lt;p&gt;Exemple:&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; :b derivation {          &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  name = &amp;quot;hello-world&amp;quot;;    &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  system = &amp;quot;x86_64-linux&amp;quot;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  builder = &amp;quot;/bin/sh&amp;quot;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  value = &amp;quot;tata&amp;quot;;     &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  args = [                 &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;quot;-c&amp;quot;                                                                                                                               &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;#39;&amp;#39;                       &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    echo $value &amp;gt; $out         &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  ];&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;This derivation produced the following outputs:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  out -&amp;gt; /nix/store/l0zl8hhcpywsvzzgmyxzxjf61hyqwq4i-hello-world&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl &amp;gt; :e /nix/store/l0zl8hhcpywsvzzgmyxzxjf61hyqwq4i-hello-world&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;tata&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Nous ce que l’on veut définir c’est “$PATH”.&lt;/p&gt;
&lt;p&gt;Voyons son contenu.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; :b derivation {          &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  name = &amp;quot;hello-world&amp;quot;;    &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  system = &amp;quot;x86_64-linux&amp;quot;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  builder = &amp;quot;/bin/sh&amp;quot;;   &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  args = [                 &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;quot;-c&amp;quot;                                                                                                                               &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;#39;&amp;#39;                       &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    echo $PATH &amp;gt; $out         &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  ];&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;This derivation produced the following outputs:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  out -&amp;gt; /nix/store/lvjhj4zgqrvcq2sviwhxii5mw3hdali5-hello-world&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; :e /nix/store/lvjhj4zgqrvcq2sviwhxii5mw3hdali5-hello-world&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;/path-not-set&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Bon, clairement nada ^^&lt;/p&gt;
&lt;p&gt;On peut donc s’amuser.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; :b derivation {          &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  name = &amp;quot;hello-world&amp;quot;;    &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  system = &amp;quot;x86_64-linux&amp;quot;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  builder = &amp;quot;/bin/sh&amp;quot;;   &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  args = [                 &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;quot;-c&amp;quot;                                                                                                                               &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;#39;&amp;#39;                       &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    gcc --version &amp;gt; $out         &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  ];&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  PATH = &amp;quot;${pkgs.gcc}/bin&amp;quot;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;This derivation produced the following outputs:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  out -&amp;gt; /nix/store/48vlxdr5bhhcgsz7z4plhaxdsbz35i3m-hello-world&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; :e /nix/store/48vlxdr5bhhcgsz7z4plhaxdsbz35i3m-hello-world&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;gcc (GCC) 12.2.0&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Copyright (C) 2022 Free Software Foundation, Inc.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;This is free software; see the source for copying conditions.  There is NO&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Et re-boom ! on a gcc et pas en format bizare ! 💥💥&lt;/p&gt;
&lt;h2 id=&quot;definir-des-fichiers&quot;&gt;Définir des fichiers&lt;/h2&gt;
&lt;p&gt;Maintenant que nous avons un compilateur, il nous faut des sources.&lt;/p&gt;
&lt;p&gt;Nix propose dans sa librairie standard une fonction appelée &lt;a rel=&quot;nofollow noreferrer external&quot; href=&quot;https://nixos.org/manual/nix/stable/language/builtins.html#builtins-toFile&quot;&gt;toFile&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;On va faire comme dans l’exemple mais au lieu de déclarer un builder que nous avons déjà, nous allons déclarer le &lt;code&gt;main.c&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; builtins.toFile &amp;quot;main.c&amp;quot; &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  #include &amp;quot;stdio.h&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  void main() {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    printf(&amp;quot;Hello World&amp;quot;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&amp;quot;/nix/store/9vmwahqfcx6909widh6g9xr736in950q-main.c&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$ file /nix/store/9vmwahqfcx6909widh6g9xr736in950q-main.c&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;/nix/store/9vmwahqfcx6909widh6g9xr736in950q-main.c: C source, ASCII text&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$ cat /nix/store/9vmwahqfcx6909widh6g9xr736in950q-main.c&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;#include &amp;quot;stdio.h&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;void main() {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  printf(&amp;quot;Hello World&amp;quot;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Ok, donc c’est aussi un chemin et dedans nous avons le main.c.&lt;/p&gt;
&lt;p&gt;On peut alors définir une variable d’environnement $SOURCE qui contiendra ce chemin.&lt;/p&gt;
&lt;p&gt;Puis modifier la commande gcc dans le builder pour compiler.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; :b derivation {          &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  name = &amp;quot;hello-world&amp;quot;;    &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  system = &amp;quot;x86_64-linux&amp;quot;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  builder = &amp;quot;/bin/sh&amp;quot;;   &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  args = [                 &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;quot;-c&amp;quot;                                                                                                                               &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;#39;&amp;#39;                       &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    gcc $SOURCE -o $out         &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  ];&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  PATH = &amp;quot;${pkgs.gcc}/bin&amp;quot;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  SOURCE = builtins.toFile &amp;quot;main.c&amp;quot; &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    #include &amp;quot;stdio.h&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    void main() {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      printf(&amp;quot;Hello World&amp;quot;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;#39;&amp;#39;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;This derivation produced the following outputs:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  out -&amp;gt; /nix/store/m6pd92z8rm9a2ia3qxml096cc33z1g2l-hello-world&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Bon, ça marche ^^&lt;/p&gt;
&lt;p&gt;Voyons le résultat…&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; file&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; /nix/store/m6pd92z8rm9a2ia3qxml096cc33z1g2l-hello-world&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;/nix/store/m6pd92z8rm9a2ia3qxml096cc33z1g2l-hello-world:&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; ELF&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; 64-bit&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; LSB&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; executable,&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; x86-64,&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; version&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; 1&lt;/span&gt;&lt;span&gt; (SYSV&lt;/span&gt;&lt;span&gt;), dynamically linked, interpreter /nix/store/1n2l5law9g3b77hcfyp50vrhhssbrj5g-glibc-2.37-8/lib/ld-linux-x86-64.so.2, &lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-10&quot;&gt;for&lt;/span&gt;&lt;span&gt; GNU/Linux 3.10.0, not stripped&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Ok, ça sent bon, c’est une executable.&lt;/p&gt;
&lt;p&gt;Ben éxécutons-le!&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; /nix/store/m6pd92z8rm9a2ia3qxml096cc33z1g2l-hello-world&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;Hello&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; World&lt;/span&gt;&lt;span&gt;$&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Cool! 😎&lt;/p&gt;
&lt;p&gt;Bon, par contre le “$” attaché c’est pas trop.&lt;/p&gt;
&lt;p&gt;Faisons une autre version.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; :b derivation {          &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  name = &amp;quot;hello-world&amp;quot;;    &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  system = &amp;quot;x86_64-linux&amp;quot;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  builder = &amp;quot;/bin/sh&amp;quot;;   &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  args = [                 &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;quot;-c&amp;quot;                                                                                                                               &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;#39;&amp;#39;                       &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    gcc $SOURCE -o $out         &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  ];&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  PATH = &amp;quot;${pkgs.gcc}/bin&amp;quot;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  SOURCE = builtins.toFile &amp;quot;main.c&amp;quot; &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    #include &amp;quot;stdio.h&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    void main() {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      printf(&amp;quot;Hello World\n&amp;quot;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;#39;&amp;#39;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;This derivation produced the following outputs:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  out -&amp;gt; /nix/store/807y2c1zj9zz8p8b5ki0a99fkm0lw0w7-hello-world&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$ /nix/store/807y2c1zj9zz8p8b5ki0a99fkm0lw0w7-hello-world&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Hello World &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Ah, beaucoup mieux. 😃&lt;/p&gt;
&lt;p&gt;Comme vous pouvez l’observez, une minuscule modification dans le main.c, a eu des répercussions dramatiques sur l’empreinte de la dérivation.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;v1 : &lt;code&gt;m6pd92z8rm9a2ia3qxml096cc33z1g2l-hello-world&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;v2 : &lt;code&gt;807y2c1zj9zz8p8b5ki0a99fkm0lw0w7-hello-world&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;C’est cela qui permet d’être certain de savoir ce que l’on manipule.&lt;/p&gt;
&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Dans cette partie, nous avons appris à créer une dérivation capable de compiler du C.&lt;/p&gt;
&lt;p&gt;Cependant, nous n’avons pas tout fixé, seul nos sources sont déterministes.&lt;/p&gt;
&lt;p&gt;Dans la &lt;a href=&quot;/nix-4&quot;&gt;partie 4&lt;/a&gt; nous verrons comment rendre déterministe notre dérivation.&lt;/p&gt;
&lt;p&gt;Merci de votre lecture ❤️&lt;/p&gt;
</content>
        
    </entry>
    <entry xml:lang="fr">
        <title>Partie 2 : Première dérivation</title>
        <published>2023-04-18T00:00:00+00:00</published>
        <updated>2023-04-18T00:00:00+00:00</updated>
        
        <author>
          <name>Unknown</name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://staging.lafor.ge/nix-2/"/>
        <id>https://staging.lafor.ge/nix-2/</id>
        
        <content type="html" xml:base="https://staging.lafor.ge/nix-2/">&lt;details &gt;
	&lt;summary&gt;&lt;span&gt;Les articles de la série&lt;/span&gt;&lt;/summary&gt;
	&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;/nix-1&quot;&gt;Partie 1&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;/nix-3&quot;&gt;Partie 3&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;/nix-4&quot;&gt;Partie 4&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;/nix-5&quot;&gt;Partie 5&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;/nix-6&quot;&gt;Partie 6&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;/details&gt;
&lt;p&gt;Bonjour à toutes et tous! 😀&lt;/p&gt;
&lt;p&gt;Deuxième article sur Nix.&lt;/p&gt;
&lt;p&gt;Cette fois-ci, on fait vraiment du Nix.&lt;/p&gt;
&lt;p&gt;Mais d’une façon un peu différente de ce que j’ai pu trouver sur internet.&lt;/p&gt;
&lt;p&gt;Ok, les dessins vus en &lt;a href=&quot;/nix-1/#la-philosophie-derriere-nix&quot;&gt;partie 1&lt;/a&gt; c’est rigolo, mais en vrai, comment je peux créer ces paquets ?&lt;/p&gt;
&lt;p&gt;C’est là que les choses sérieuses débutent! 🥲&lt;/p&gt;
&lt;h2 id=&quot;le-paquet-que-l-on-veut-creer&quot;&gt;Le paquet que l’on veut créer&lt;/h2&gt;
&lt;p&gt;Nous allons faire le paquet le plus simple du monde.&lt;/p&gt;
&lt;p&gt;Un hello-world en C.&lt;/p&gt;
&lt;p&gt;Pour cela, il nous faut des sources.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;c&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-10&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-10&quot;&gt;include&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;stdio.h&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-10&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt; main&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;  printf&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;Hello World&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Normalement pour compiler on fait un coup de&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;gcc&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; main.c&lt;/span&gt;&lt;span class=&quot;z-l-4 z-d-11&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-l-4 z-d-11&quot;&gt;o&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; result&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Et bien allons-y ! Mais utilisons ce qu’on sait déjà faire.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-shell -p gcc&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;On obtient alors un shell avec &lt;code&gt;gcc&lt;/code&gt;&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[&lt;/span&gt;&lt;span&gt;nix-shell:&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;~&lt;/span&gt;&lt;span&gt;/path&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt;$ gcc --version&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;gcc&lt;/span&gt;&lt;span&gt; (GCC&lt;/span&gt;&lt;span&gt;) 12.2.0&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Compilons et rendons exécutable le fichier&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[nix-shell:~/path]$ gcc main.c -o result&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[nix-shell:~/path]$ chmod +x result&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[nix-shell:~/path]$ ./result&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Hello World&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[nix-shell:~/path]$ exit&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Wouhou, on sait encore faire du C 😎&lt;/p&gt;
&lt;h2 id=&quot;decouverte-de-nix-repl&quot;&gt;Découverte de nix-repl&lt;/h2&gt;
&lt;p&gt;Bon assez rigolé, attaquons les choses sérieuses.&lt;/p&gt;
&lt;p&gt;Mais nous allons le faire très progressivement.&lt;/p&gt;
&lt;p&gt;Tout d’abord et en dehors d’un nix-shell, nous allons utiliser le REPL “Real Event Print Loop” de Nix. Il s’agit d’un programme qui permet de manipuler Nix en
mode interactif.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$ nix repl&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Welcome to Nix 2.15.0. Type :? for help.&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Si tout se passe bien, vous devriez avoir un affichage semblable.&lt;/p&gt;
&lt;p&gt;Il permet de taper des expressions qui seront analysées et exécutées.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl &amp;gt; 1 + 2&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;3&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&quot;la-fonction-derivation&quot;&gt;La fonction derivation&lt;/h2&gt;
&lt;p&gt;Créons maintenant, une dérivation dont on a si souvent parlé dans la partie précédente.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl &amp;gt; derivation&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;«lambda @ //builtin/derivation.nix:5:1»&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Ok, “lambda” … Cela signifie qu’il s’agit d’une fonction.&lt;/p&gt;
&lt;p&gt;En Nix, pour appeler une fonction on fait&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;nix&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;expr&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;blockquote class=&quot;markdown-alert-note&quot;&gt;
	&lt;p&gt;Pour les pros, oui je sais c’est un raccourci, j’explicite dans la &lt;a href=&quot;/nix-3&quot;&gt;partie 3&lt;/a&gt; ^^&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Allons-y pour la derivation.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl &amp;gt; derivation {}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;error: attribute &amp;#39;name&amp;#39; missing&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Donc la fonction prend un attribut qui est &lt;code&gt;name&lt;/code&gt;;&lt;/p&gt;
&lt;p&gt;Les attributs sont les champs de structures de données comme ci-dessous:&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;nix&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt; x&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; 1&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt; y&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; 2&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;En Nix on nomme ceci un &lt;code&gt;set&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Remarquez le point virgule &lt;code&gt;;&lt;/code&gt; à la fin de chaque attribut&lt;/p&gt;
&lt;p&gt;Nous allons donc donner à notre fonction un set comportant l’attribut &lt;code&gt;name&lt;/code&gt; et qui a pour valeur “hello-world”.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl &amp;gt; derivation { name = &amp;quot;hello-world&amp;quot;; }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;error: required attribute &amp;#39;builder&amp;#39; missing&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Bon ça progresse ! Je vais pas vous faire tous les attributs manquants, un à un ^^&lt;/p&gt;
&lt;p&gt;Voici un set complet&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl &amp;gt; derivation { name = &amp;quot;hello-world&amp;quot;; builder = &amp;quot;fake-builder&amp;quot;; system = &amp;quot;fake-system&amp;quot;;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;«derivation /nix/store/z4lc26wzbma1c5s7spp98zz7xz99m5gh-hello-world.drv»&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Wouhou ! Vous venez de créer votre première dérivation !&lt;/p&gt;
&lt;h2 id=&quot;derivation-nix&quot;&gt;Derivation Nix&lt;/h2&gt;
&lt;p&gt;Le retour de vous avez créé a tout l’air d’être un chemin sur l’ordi.&lt;/p&gt;
&lt;p&gt;Sortons du REPL avec &lt;code&gt;ctrl+d&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Voyons ce qu’il en est.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; file&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; /nix/store/z4lc26wzbma1c5s7spp98zz7xz99m5gh-hello-world.drv&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;/nix/store/z4lc26wzbma1c5s7spp98zz7xz99m5gh-hello-world.drv:&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; ASCII&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; text,&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; with&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; no&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; line&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; terminators&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;C’est bien un fichier, visualisons son contenu.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; cat&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; /nix/store/z4lc26wzbma1c5s7spp98zz7xz99m5gh-hello-world.drv&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;Derive([(&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;out&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;/nix/store/vzv4g8bavybrp4682xidd5dn7r9w8lf6-hello-world&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;)],&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;fake-system&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;fake-builder&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;builder&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;fake-builder&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;hello-world&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;out&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;/nix/store/vzv4g8bavybrp4682xidd5dn7r9w8lf6-hello-world&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;system&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;fake-system&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Nix propose une alternative plus sympatique pour le visualiser.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; nix&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; derivation&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; show&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; /nix/store/z4lc26wzbma1c5s7spp98zz7xz99m5gh-hello-world.drv&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;error:&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; experimental&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; Nix&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; feature&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;nix-command&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; is&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; disabled&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt; use&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;--extra-experimental-features nix-command&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; to&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; override&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Bon, il faut rajouter l’argument.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; nix&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; derivation&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; show&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; /nix/store/z4lc26wzbma1c5s7spp98zz7xz99m5gh-hello-world.drv&lt;/span&gt;&lt;span class=&quot;z-l-4 z-d-11&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-l-4 z-d-11&quot;&gt;-extra-experimental-features&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; nix-command&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;  &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;/nix/store/z4lc26wzbma1c5s7spp98zz7xz99m5gh-hello-world.drv&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;    &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;:&lt;/span&gt;&lt;span&gt; [&lt;/span&gt;&lt;span&gt;],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;    &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;builder&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;fake-builder&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;    &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;env&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;      &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;builder&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;fake-builder&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;      &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;hello-world&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;      &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;out&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;/nix/store/vzv4g8bavybrp4682xidd5dn7r9w8lf6-hello-world&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;      &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;system&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;fake-system&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;    &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;inputDrvs&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; {},&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;    &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;inputSrcs&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;:&lt;/span&gt;&lt;span&gt; [&lt;/span&gt;&lt;span&gt;],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;    &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;hello-world&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;    &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;outputs&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;      &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;out&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;        &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;/nix/store/vzv4g8bavybrp4682xidd5dn7r9w8lf6-hello-world&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    },&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;    &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;system&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;fake-system&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;blockquote class=&quot;markdown-alert-note&quot;&gt;
	&lt;p&gt;Vu que c’est experimental mais pas complet cassé, nous allons désactiver les warnings.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; vim&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; ~/.config/nix/nix.conf&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;experimental-features&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; nix-command&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;p&gt;Dans ce qui ressemble a du JSON, nous avons une clef avec le nom de notre dérivation &amp;lt;deriv&amp;gt; et dedans une clef &lt;code&gt;&amp;lt;deriv&amp;gt;.env.out&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Celle-ci a pour valeur un autre chemin &lt;code&gt;/nix/store/vzv4g8bavybrp4682xidd5dn7r9w8lf6-hello-world&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Si on tente de l’atteindre.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; ls&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; /nix/store/vzv4g8bavybrp4682xidd5dn7r9w8lf6-hello-world&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;ls:&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; cannot&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; access&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;/nix/store/vzv4g8bavybrp4682xidd5dn7r9w8lf6-hello-world&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; No&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; such&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; file&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; or&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; directory&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Normal, nous avons déclaré notre dérivation mais nous ne l’avons pas encore réalisée.&lt;/p&gt;
&lt;p&gt;C’est donc logique et plutôt rassurant que le paquet &lt;code&gt;hello-world&lt;/code&gt; n’existe pas encore.&lt;/p&gt;
&lt;h2 id=&quot;realisation-de-la-derivation&quot;&gt;Réalisation de la dérivation&lt;/h2&gt;
&lt;p&gt;Réalisons notre dérivation !&lt;/p&gt;
&lt;p&gt;Pour cela, nouvelle commande : &lt;code&gt;nix-build&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; nix-build&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; /nix/store/z4lc26wzbma1c5s7spp98zz7xz99m5gh-hello-world.drv&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; derivation&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; will&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; be&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; built:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;  /nix/store/z4lc26wzbma1c5s7spp98zz7xz99m5gh-hello-world.drv&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;error:&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; a&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;fake-system&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; with&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; features&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; {}&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; is&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; required&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; to&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; build&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;/nix/store/z4lc26wzbma1c5s7spp98zz7xz99m5gh-hello-world.drv&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; but&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; I&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; am&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; a&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;x86_64-linux&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; with&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; features&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; {benchmark,&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; big-parallel,&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; kvm,&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; nixos-test,&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; uid-range}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Ok, notre dérivation est pas top, je crois que nous allons devoir repartir sur la table à dessins. 😢&lt;/p&gt;
&lt;p&gt;On est de retour dans le REPL.&lt;/p&gt;
&lt;p&gt;Changeons l’attribut &lt;code&gt;system&lt;/code&gt; pour ce qu’il demande.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; derivation { name = &amp;quot;hello-world&amp;quot;; builder = &amp;quot;fake-builder&amp;quot;; system = &amp;quot;x86_64-linux&amp;quot;;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;«derivation /nix/store/85pf9z8ps92lf115wpfy5k493l096g99-hello-world.drv»&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Le chemin est complètement différent, pour cette seconde dérivation.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$ nix derivation show /nix/store/85pf9z8ps92lf115wpfy5k493l096g99-hello-world.drv&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  &amp;quot;/nix/store/85pf9z8ps92lf115wpfy5k493l096g99-hello-world.drv&amp;quot;: {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;quot;builder&amp;quot;: &amp;quot;fake-builder&amp;quot;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;quot;env&amp;quot;: {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      &amp;quot;system&amp;quot;: &amp;quot;x86-64_linux&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Et notre système est à la bonne valeur.&lt;/p&gt;
&lt;p&gt;On relance un build et on croise les doigts. 🤞&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; nix-build&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; /nix/store/85pf9z8ps92lf115wpfy5k493l096g99-hello-world.drv&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; derivation&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; will&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; be&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; built:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;  /nix/store/85pf9z8ps92lf115wpfy5k493l096g99-hello-world.drv&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;building&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;/nix/store/85pf9z8ps92lf115wpfy5k493l096g99-hello-world.drv&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;error:&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; executing&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;fake-builder&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; No&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; such&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; file&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; or&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; directory&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;error:&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; builder&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; for&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;/nix/store/85pf9z8ps92lf115wpfy5k493l096g99-hello-world.drv&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; failed&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; with&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; exit&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; code&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; 1&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;       last&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; 1&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; log&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; lines:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;       &amp;gt;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt; error:&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; executing&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;fake-builder&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; No&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; such&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; file&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; or&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; directory&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;       For&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; full&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; logs,&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; run&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;nix-store -l /nix/store/85pf9z8ps92lf115wpfy5k493l096g99-hello-world.drv&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Ah! De l’avancement. des erreurs mais on progresse.&lt;/p&gt;
&lt;p&gt;Je trouve le chemin de modification un peu longuet: repl, derivation, exit repl, build.&lt;/p&gt;
&lt;p&gt;Est-ce que l’on pourrait rester dans le REPL pour build ? Oui, sinon je poserai pas la question. 😝&lt;/p&gt;
&lt;p&gt;Il suffit de rajouter &lt;code&gt;:b&lt;/code&gt; devant la déclaration de la dérivation.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; :b derivation { name = &amp;quot;hello-world&amp;quot;; builder = &amp;quot;fake-builder&amp;quot;; system = &amp;quot;x86_64-linux&amp;quot;;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;error: builder for &amp;#39;/nix/store/85pf9z8ps92lf115wpfy5k493l096g99-hello-world.drv&amp;#39; failed with exit code 1;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;       last 1 log lines:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;       &amp;gt; error: executing &amp;#39;fake-builder&amp;#39;: No such file or directory&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;       For full logs, run &amp;#39;nix-store -l /nix/store/85pf9z8ps92lf115wpfy5k493l096g99-hello-world.drv&amp;#39;.&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Bon il trouve pas le builder, et pour cause, il n’existe pas.&lt;/p&gt;
&lt;h2 id=&quot;le-builder&quot;&gt;Le builder&lt;/h2&gt;
&lt;p&gt;Un builder est un exécutable qui a pour but de réaliser la dérivation et de mettre le contenu dans &lt;code&gt;&amp;lt;deriv&amp;gt;.env.out&lt;/code&gt; celui du retour de la commande &lt;code&gt;nix derivation show&lt;/code&gt;..&lt;/p&gt;
&lt;p&gt;Pour cela nous allons rajouter un quatrième paramètre &lt;code&gt;args&lt;/code&gt; qui va nous permettre de définir les arguments passés au builder.&lt;/p&gt;
&lt;p&gt;Ici ça sera l’équivalent d’écrire:&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;/bin/sh&lt;/span&gt;&lt;span class=&quot;z-l-4 z-d-11&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-l-4 z-d-11&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;echo toto &amp;gt; &lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-8&quot;&gt;out&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;-c&lt;/code&gt; pour lire le stdin et l’exécuter.&lt;/p&gt;
&lt;p&gt;Et nous allons utiliser un &lt;code&gt;builder&lt;/code&gt; qui existe, celui-ci sera &lt;code&gt;/bin/sh&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;J’explique dans la &lt;a href=&quot;/nix-3&quot;&gt;partie 3&lt;/a&gt; pourquoi. ^^&lt;/p&gt;
&lt;p&gt;Le &lt;code&gt;env&lt;/code&gt; de &lt;code&gt;&amp;lt;deriv&amp;gt;.env.out&lt;/code&gt; est ici pour signaler qu’une variable d’environnement “$out” est définie à la valeur du chemin de sortie de la dérivation.&lt;/p&gt;
&lt;p&gt;Donc ici, notre builder se contente de venir écrire toto à ce chemin. Qui devient un fichier.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nix-repl&amp;gt; :b derivation {          &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  name = &amp;quot;hello-world&amp;quot;;    &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  system = &amp;quot;x86_64-linux&amp;quot;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  builder = &amp;quot;/bin/sh&amp;quot;;     &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  args = [                 &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;quot;-c&amp;quot;                                                                                                                               &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;#39;&amp;#39;                       &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    echo toto &amp;gt; $out         &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  ];&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;This derivation produced the following outputs:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  out -&amp;gt; /nix/store/alrzzi9kljsqazv5a34hspx531wjknz7-hello-world&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;On peut s’en convaincre avec:&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; file&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; /nix/store/alrzzi9kljsqazv5a34hspx531wjknz7-hello-world&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;/nix/store/alrzzi9kljsqazv5a34hspx531wjknz7-hello-world:&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; ASCII&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; text&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; cat&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; /nix/store/alrzzi9kljsqazv5a34hspx531wjknz7-hello-world&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;toto&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Félicitation ! Vous venez de réaliser votre première dérivation!! 🎉 🍾&lt;/p&gt;
&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Nous avons bien une dérivation, elle est fonctionnelle, ne compile pas encore de C.&lt;/p&gt;
&lt;p&gt;On verra dans la &lt;a href=&quot;/nix-3&quot;&gt;partie 3&lt;/a&gt; comment compiler.&lt;/p&gt;
&lt;p&gt;Merci de votre lecture ❤️&lt;/p&gt;
</content>
        
    </entry>
    <entry xml:lang="fr">
        <title>Partie 1 : Premier pas avec Nix</title>
        <published>2023-04-14T00:00:00+00:00</published>
        <updated>2023-04-14T00:00:00+00:00</updated>
        
        <author>
          <name>Unknown</name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://staging.lafor.ge/nix-1/"/>
        <id>https://staging.lafor.ge/nix-1/</id>
        
        <content type="html" xml:base="https://staging.lafor.ge/nix-1/">&lt;details &gt;
	&lt;summary&gt;&lt;span&gt;Les articles de la série&lt;/span&gt;&lt;/summary&gt;
	&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;/nix-2&quot;&gt;Partie 2&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;/nix-3&quot;&gt;Partie 3&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;/nix-4&quot;&gt;Partie 4&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;/nix-5&quot;&gt;Partie 5&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;/nix-6&quot;&gt;Partie 6&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;/details&gt;
&lt;p&gt;Bonjour à toutes et tous! 😀&lt;/p&gt;
&lt;p&gt;Premier article sur le gestionnaire de packages Nix et son langage.&lt;/p&gt;
&lt;p&gt;Cela peut aussi être un système d’exploitation complet, mais chaque chose en son temps. 😅&lt;/p&gt;
&lt;p&gt;Je ferai mon installation sur linux mais la &lt;a rel=&quot;nofollow noreferrer external&quot; href=&quot;https://nix.dev/tutorials/install-nix&quot;&gt;documentation officielle&lt;/a&gt; vous permet de l’installer n’importe où même sur du windows.&lt;/p&gt;
&lt;p&gt;Dans cette partie, je vous explique comment l’installer et quelle est la philosophie adoptée par Nix pour gérer les paquets.&lt;/p&gt;
&lt;p&gt;La pratique viendra dans la &lt;a href=&quot;/nix-2&quot;&gt;partie 2&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&quot;installation&quot;&gt;Installation&lt;/h2&gt;
&lt;p&gt;Nix est installable via un scrip bash&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;curl&lt;/span&gt;&lt;span class=&quot;z-l-4 z-d-11&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-l-4 z-d-11&quot;&gt;L&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; https://nixos.org/nix/install&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt; |&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt; sh&lt;/span&gt;&lt;span class=&quot;z-l-4 z-d-11&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-l-4 z-d-11&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;z-l-4 z-d-11&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-l-4 z-d-11&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;z-l-4 z-d-11&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-l-4 z-d-11&quot;&gt;-daemon&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Celui-ci va vous poser un certain nombre de questions qui vont vous permettre de définir le comportement d’installation.&lt;/p&gt;
&lt;p&gt;Moi, j’ai choisi le multi-user et donc le besoin d’être &lt;code&gt;sudo&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Pour vérifier que tout marche, rendez-vous dans un autre shell.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; nix&lt;/span&gt;&lt;span class=&quot;z-l-4 z-d-11&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-l-4 z-d-11&quot;&gt;-version&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;nix&lt;/span&gt;&lt;span&gt; (Nix&lt;/span&gt;&lt;span&gt;) 2.15.0&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&quot;les-environnements-ephemeres&quot;&gt;Les environnements éphémères&lt;/h2&gt;
&lt;p&gt;Faisons un peu de magie noire.&lt;/p&gt;
&lt;p&gt;Des fois nous avons besoin d’un logiciel à une certaine version pour faire des choses.&lt;/p&gt;
&lt;p&gt;Mais c’est compliqué, il faut installer tout un tas de dépendances, ça “pourrit” le disque et on oublie de désinstaller après coup, ou on ne sait plus où on l’a installé.&lt;/p&gt;
&lt;p&gt;Nix permet de créer des environnements éphémères pour tester des choses. Environnements qui peuvent facilement se nettoyer.&lt;/p&gt;
&lt;p&gt;Exemple, je suis sur un système qui ne possède pas python.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; python&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;Command&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;python&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; not&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; found&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Fâcheux, 2 solutions, je fais un &lt;code&gt;apt install&lt;/code&gt; de python même si j’en ai besoin que maintenant.&lt;/p&gt;
&lt;p&gt;Ou … J’utilise Nix, yes je vois que ça suit derrière 😛&lt;/p&gt;
&lt;p&gt;Pour cela, on créé ce que l’on appelle un &lt;code&gt;nix-shell&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Mais pas n’importe lequel, on lui donne des arguments, par exemple le python que l’on désire.&lt;/p&gt;
&lt;p&gt;Pour cela, on va sur &lt;a rel=&quot;nofollow noreferrer external&quot; href=&quot;https://search.nixos.org&quot;&gt;https://search.nixos.org&lt;/a&gt; !&lt;/p&gt;
&lt;p&gt;On recherche le paquet que l’on désire, par exemple &lt;code&gt;python 3.11&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Et cela nous donne le nom du paquet, ici &lt;code&gt;python311&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Plus qu’à injecter ça dans &lt;code&gt;nix-shell&lt;/code&gt;&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; nix-shell&lt;/span&gt;&lt;span class=&quot;z-l-4 z-d-11&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-l-4 z-d-11&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; python311&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Selon votre shell, vous devriez avoir une indication de changement de contexte.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[&lt;/span&gt;&lt;span&gt;nix-shell:&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;~&lt;/span&gt;&lt;span&gt;/dir&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt;$&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Maintenant, si on retente le&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[&lt;/span&gt;&lt;span&gt;nix-shell:&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;~&lt;/span&gt;&lt;span&gt;/dir&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt;$ python --version&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;Python&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; 3.11.2&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Si on exit&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$ exit&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$ python&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Command &amp;#39;python&amp;#39; not found&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Le python n’est toujours pas installé à l’extérieur 😀&lt;/p&gt;
&lt;p&gt;Et maintenant si l’on veut, 2 versions de python.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;python 3.11&lt;/li&gt;
&lt;li&gt;python 2.7&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; nix-shell&lt;/span&gt;&lt;span class=&quot;z-l-4 z-d-11&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-l-4 z-d-11&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; python311&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; python27&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Il va vous engueuler !&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Known issues:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        - Python 2.7 has reached its end of life after 2020-01-01. See https://www.python.org/doc/sunset-python-2/.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;       You can install it anyway by allowing this package, using the&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;       following methods:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;       a) To temporarily allow all insecure packages, you can use an environment&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;          variable for a single invocation of the nix tools:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            $ export NIXPKGS_ALLOW_INSECURE=1&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Bien Madame, tout de suite Madame.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; NIXPKGS_ALLOW_INSECURE=&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; nix-shell&lt;/span&gt;&lt;span class=&quot;z-l-4 z-d-11&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-l-4 z-d-11&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; python311&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; python27&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Après un certain temps, vu que l’on est en train de compiler les sources de python, vous entrerez dans un shell.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[&lt;/span&gt;&lt;span&gt;nix-shell:&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;~&lt;/span&gt;&lt;span&gt;/dir&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt;$ python --version&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;Python&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; 3.11.2&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[&lt;/span&gt;&lt;span&gt;nix-shell:&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;~&lt;/span&gt;&lt;span&gt;/dir&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt;$ python2 --version&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;Python&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; 2.7.18.6&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Plutôt cool non ? 😎&lt;/p&gt;
&lt;p&gt;Et bien-sûr on peut le faire avec n’importe quoi, pourvu qu’une bonne âme l’ait déjà packagé.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;nix-shell&lt;/span&gt;&lt;span class=&quot;z-l-4 z-d-11&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-l-4 z-d-11&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; rustc&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; cargo&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Créons un projet rust.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[&lt;/span&gt;&lt;span&gt;nix-shell:&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;~&lt;/span&gt;&lt;span&gt;/dir&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt;$ rustc --version&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;rustc&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-14&quot;&gt; 1.68.2&lt;/span&gt;&lt;span&gt; (9eb3afe9e&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; 2023-03-27&lt;/span&gt;&lt;span&gt;) (&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;built&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; from&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; a&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; source&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; tarball&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[&lt;/span&gt;&lt;span&gt;nix-shell:&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;~&lt;/span&gt;&lt;span&gt;/dir&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt;$ cargo init toto&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;Created&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; binary&lt;/span&gt;&lt;span&gt; (application&lt;/span&gt;&lt;span&gt;) package&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[&lt;/span&gt;&lt;span&gt;nix-shell:&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;~&lt;/span&gt;&lt;span&gt;/dir&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt;$ cd toto&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[&lt;/span&gt;&lt;span&gt;nix-shell:&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;~&lt;/span&gt;&lt;span&gt;/dir&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt;$ cargo run&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;   Compiling&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; toto&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; v0.1.0&lt;/span&gt;&lt;span&gt; (/home/noa/Documents/Workshop/nix/toto&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;    Finished&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; dev&lt;/span&gt;&lt;span&gt; [unoptimized&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; +&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; debuginfo]&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; target&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;s&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; in&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; 0.27s&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;     Running&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; `&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;target/debug/toto&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt;`&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;Hello,&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; world!&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Voilà! 30 secondes pour commencer à bosser.&lt;/p&gt;
&lt;p&gt;Vous sortez et pouf, tout disparaît ^^&lt;/p&gt;
&lt;p&gt;Je sais pas si vous avez remarqué mais, le premier environnement est long à installer mais les suivants c’est instantané.&lt;/p&gt;
&lt;p&gt;Il y a sûrement du cache quelque part. 🤔&lt;/p&gt;
&lt;p&gt;La réponse est oui ! 🙂&lt;/p&gt;
&lt;p&gt;Pour s’en convaincre il suffit de faire un &lt;code&gt;which&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[&lt;/span&gt;&lt;span&gt;nix-shell:&lt;/span&gt;&lt;span class=&quot;z-l-3 z-d-3&quot;&gt;~&lt;/span&gt;&lt;span&gt;/dir&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt;$ which rustc&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;/nix/store/hd6l85dw0i9zy7j0h52w9s8smyymha3r-rustc-1.68.2/bin/rustc&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; exit&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; which&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-5&quot;&gt; rustc&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;/home/noa/.cargo/bin/rustc&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;A l’intérieur et au-dehors de l’environnement, ce ne sont pas les mêmes binaires.&lt;/p&gt;
&lt;p&gt;Tout ce qui est utilisable dans l’environnement éphémère est stocké dans
un des sous répertoires du dossier &lt;code&gt;/nix/store&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&quot;la-philosophie-derriere-nix&quot;&gt;La philosophie derrière Nix&lt;/h2&gt;
&lt;p&gt;Si vous n’êtes pas familier de la programmation fonctionnelle, nous allons devoir faire un peu de théorie.&lt;/p&gt;
&lt;p&gt;Le pire cauchemar d’un fonctionnaliste c’est d’avoir des effets de bord dans son système.&lt;/p&gt;
&lt;p&gt;Et qu’est ce qu’un effet de bord ?&lt;/p&gt;
&lt;p&gt;Et bien c’est un paramètre non fixé qui fait varier de manière incontrôlée le système.&lt;/p&gt;
&lt;p&gt;Imaginez que vous avez une fonction qui doit renvoyer la date d’aujourd’hui.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;fun return_now() -&amp;gt; int&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  return now()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;display return_now();&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Cette fonction est impure, car en fonction du moment où vous allez l’appeler, la valeur va varier.&lt;/p&gt;
&lt;p&gt;Pour que celle-ci soit pure, il faut que le temps soit déterministe. Et donc que &lt;code&gt;now()&lt;/code&gt; le soit.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;fun return_now_pure(clock : time) -&amp;gt; int&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  return clock.now()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;clock = time().set_now(&amp;quot;14/04/2023 00:00&amp;quot;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;display return_now(clock);&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Cette fois-ci, nous sommes capable de décider de ce que &lt;code&gt;now()&lt;/code&gt; retourne. La fonction &lt;code&gt;return_now_pure&lt;/code&gt; est donc pure.&lt;/p&gt;
&lt;p&gt;Maintenant, que pourrait signifier la pureté dans un contexte de paquets à installer ?&lt;/p&gt;
&lt;p&gt;Déjà c’est quoi un &lt;strong&gt;paquet&lt;/strong&gt; ?&lt;/p&gt;
&lt;p&gt;Très grossièrement, un paquet c’est:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;un certain nombre de binaires&lt;/li&gt;
&lt;li&gt;un certain nombre de fichiers de configuration&lt;/li&gt;
&lt;li&gt;un certain nombre de paquets en dépendances:
&lt;ul&gt;
&lt;li&gt;un certain nombre de binaires&lt;/li&gt;
&lt;li&gt;un certain nombre de fichiers de configuration&lt;/li&gt;
&lt;li&gt;un certain nombre de paquets en dépendances:
&lt;ul&gt;
&lt;li&gt;…&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Bon clairement on a une récursion de concepts ^^&lt;/p&gt;
&lt;p&gt;Et donc rendre pur un paquet c’est rendre pure cette récursion.&lt;/p&gt;
&lt;p&gt;Cela manque de dessins!&lt;/p&gt;
&lt;p&gt;Imaginons le paquet &lt;code&gt;A&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Celui-ci est constitué de sources, qui doivent être compilées.&lt;/p&gt;
&lt;img class=&quot;&quot; width=&quot;80%&quot; src=&quot;/assets/images/nix/pure1.png&quot; /&gt;
&lt;p&gt;Cela produit un binaire.&lt;/p&gt;
&lt;p&gt;Nous voulons être convaincus du contenu de ce que l’on manipule.&lt;/p&gt;
&lt;p&gt;Pour cela nous allons utiliser une fonction de &lt;strong&gt;hachage crytographique&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Une fonction de hachage ou &lt;em&gt;hash&lt;/em&gt; a pour particularité de renvoyer la même valeur de retour pour un contenu en entrée donnée.&lt;/p&gt;
&lt;p&gt;Nous allons utiliser cette fonction pour venir créer l’empreinte des sources que l’on souhaite compiler.&lt;/p&gt;
&lt;img class=&quot;&quot; width=&quot;80%&quot; src=&quot;/assets/images/nix/pure2.png&quot; /&gt;
&lt;p&gt;Si le contenu des sources évolue, son empreinte en fait d’autant.&lt;/p&gt;
&lt;img class=&quot;&quot; width=&quot;80%&quot; src=&quot;/assets/images/nix/pure3.png&quot; /&gt;
&lt;p&gt;Notre paquet A, possède également un fichier qui est nécessaire à son fonctionnement.&lt;/p&gt;
&lt;img class=&quot;&quot; width=&quot;90%&quot; src=&quot;/assets/images/nix/pure4.png&quot; /&gt;
&lt;p&gt;On étiquette alors le paquet avec l’empreinte calculée précédemment.&lt;/p&gt;
&lt;img class=&quot;&quot; width=&quot;90%&quot; src=&quot;/assets/images/nix/pure5.png&quot; /&gt;
&lt;p&gt;Le souci c’est que si le contenu du fichier accompagnant le binaire évolue, mais que le binaire reste identique.&lt;/p&gt;
&lt;img class=&quot;&quot; width=&quot;90%&quot; src=&quot;/assets/images/nix/pure6.png&quot; /&gt;
&lt;p&gt;Alors, l’étiquette restera la même ! Or ça c’est &lt;strong&gt;impur&lt;/strong&gt;. De l’extérieur, nous pensons savoir ce que l’on manipule alors que finalement cette modification peut avoir des répercussions sur le fonctionnement du paquet A.&lt;/p&gt;
&lt;p&gt;Pour éviter cela, nous allons également ajouter le contenu du fichier dans le calcul d’empreinte.&lt;/p&gt;
&lt;img class=&quot;&quot; width=&quot;90%&quot; src=&quot;/assets/images/nix/pure7.png&quot; /&gt;
&lt;p&gt;Ainsi, peu importe les modifications, l’empreinte évoluera. L’utilisateur du paquet A n’est pas “pris en traître”&lt;/p&gt;
&lt;p&gt;On créé alors une série de “paquets A”, mais étiquetés différemment, ce qui reflète l’état interne du contenu du paquet.&lt;/p&gt;
&lt;img class=&quot;&quot; width=&quot;50%&quot; src=&quot;/assets/images/nix/pure8.png&quot; /&gt;
&lt;p&gt;Si on en revient à la première chose dont on a parlé, on a dit que le binaire devait être compilé, mais compilé par quoi ?&lt;/p&gt;
&lt;p&gt;Et bien par un compilateur.&lt;/p&gt;
&lt;img class=&quot;&quot; width=&quot;90%&quot; src=&quot;/assets/images/nix/pure1.png&quot; /&gt;
&lt;p&gt;Compilateur lui même possède une version.&lt;/p&gt;
&lt;img class=&quot;&quot; width=&quot;100%&quot; src=&quot;/assets/images/nix/pure9.png&quot; /&gt;
&lt;p&gt;Et du coup, si la version du compilateur vient à changer, qu’est ce qui garantit que le binaire résultant ne soit pas altéré ?&lt;/p&gt;
&lt;img class=&quot;&quot; width=&quot;100%&quot; src=&quot;/assets/images/nix/pure10.png&quot; /&gt;
&lt;p&gt;Et bien, rien !&lt;/p&gt;
&lt;p&gt;Or, nous voulons un système déterministe.&lt;/p&gt;
&lt;p&gt;Ce que nous allons faire, c’est également ajouter dans le calcul de l’empreinte, le compilateur lui-même.&lt;/p&gt;
&lt;img class=&quot;&quot; width=&quot;100%&quot; src=&quot;/assets/images/nix/pure11.png&quot; /&gt;
&lt;p&gt;Ainsi, compiler les même sources, mais avec un compilateur différent, nous donne une empreinte finale différente.&lt;/p&gt;
&lt;img class=&quot;&quot; width=&quot;100%&quot; src=&quot;/assets/images/nix/pure12.png&quot; /&gt;
&lt;p&gt;Étant donné que l’on commence à planifier les choses. Nous allons réaliser un plan de construction.&lt;/p&gt;
&lt;p&gt;Ce plan de construction se nomme dans le monde de Nix, une &lt;strong&gt;dérivation&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Cette dérivation nous explique que pour compiler le paquet A, nous avons besoin:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;du compilateur à la version &lt;code&gt;v1.0&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;des sources à la version &lt;code&gt;v1.0.1&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;du fichier à la révision &lt;code&gt;rev 2&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Si tous les ingrédients sont réunis, et dans cet état précis, la dérivation créera un paquet A étiqueté &lt;code&gt;#e12d&lt;/code&gt;.&lt;/p&gt;
&lt;img class=&quot;&quot; width=&quot;100%&quot; src=&quot;/assets/images/nix/pure13.png&quot; /&gt;
&lt;p&gt;En imaginant que le compilateur &lt;code&gt;v1.0&lt;/code&gt; est dans le paquet compilateur étiqueté &lt;code&gt;#7a84&lt;/code&gt;.&lt;/p&gt;
&lt;img class=&quot;&quot; width=&quot;40%&quot; src=&quot;/assets/images/nix/pure15.png&quot; /&gt;
&lt;p&gt;Alors, tout comme nous utilisons une dérivation pour obtenir, le paquet A, nous allons utiliser la dérivation à l’étiquette &lt;code&gt;#7a84&lt;/code&gt; pour obtenir
le paquet compilateur étiqueté &lt;code&gt;#7a84&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;On dit que l’on &lt;strong&gt;réalise&lt;/strong&gt; la dérivation.&lt;/p&gt;
&lt;img class=&quot;&quot; width=&quot;50%&quot; src=&quot;/assets/images/nix/pure14.png&quot; /&gt;
&lt;p&gt;On peut alors mettre à jour notre dérivation du paquet A, qui désormais référence également le dérivation du compilateur &lt;code&gt;#7a84&lt;/code&gt;.&lt;/p&gt;
&lt;img class=&quot;&quot; width=&quot;100%&quot; src=&quot;/assets/images/nix/pure16.png&quot; /&gt;
&lt;p&gt;Pour obtenir notre compilateur, nous avons alors 3 choix:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;réaliser la dérivation pour obtenir le paquet, récupérer le compilateur&lt;/li&gt;
&lt;li&gt;télécharger le paquet déjà réalisé&lt;/li&gt;
&lt;li&gt;utiliser le cache local de la dérivation déjà réalisée&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;On reparlera du cache plus tard dans la série.&lt;/p&gt;
&lt;img class=&quot;&quot; width=&quot;100%&quot; src=&quot;/assets/images/nix/pure17.png&quot; /&gt;
&lt;p&gt;Imaginons, maintenant une dérivation paquet B qui demande, une dérivation de paquet A, de paquet C et des sources.&lt;/p&gt;
&lt;img class=&quot;&quot; width=&quot;90%&quot; src=&quot;/assets/images/nix/pure18.png&quot; /&gt;
&lt;p&gt;Étant donné que toutes les entrées sont fixées, la dérivation garantie que pour une collection d’entrée donnée, le contenu du paquet B sera &lt;strong&gt;TOUJOURS&lt;/strong&gt; identique.&lt;/p&gt;
&lt;p&gt;Nous avons un système de création de paquet qui est &lt;strong&gt;pur&lt;/strong&gt; !&lt;/p&gt;
&lt;p&gt;D’une manière générale, pour une collection de dérivation d’entrées et de données définie. Nous sommes toujours capable de créer une dérivation qui donnera un
paquet donc le contenu est déterministe et donc peut être connu à la simple lecture de son empreinte. 😄&lt;/p&gt;
&lt;img class=&quot;&quot; width=&quot;100%&quot; src=&quot;/assets/images/nix/pure19.png&quot; /&gt;
&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Dans cette partie, nous avons un peu joué avec la partie utilisateur du package manager et expliqué comment Nix s’assurait de la pureté, je veux plutôt dire de la reproductibilité des builds.&lt;/p&gt;
&lt;p&gt;On verra dans la &lt;a href=&quot;/nix-2&quot;&gt;partie 2&lt;/a&gt; comment créer nos propres packages.&lt;/p&gt;
&lt;p&gt;Merci de votre lecture ❤️&lt;/p&gt;
</content>
        
    </entry>
</feed>
