From mboxrd@z Thu Jan 1 00:00:00 1970 From: Timothy Sample Subject: Re: Help defining a trivial package. Date: Mon, 02 Sep 2019 21:58:42 -0400 Message-ID: <87woeqywbx.fsf@ngyro.com> References: <87sgppfnha.fsf@ngyro.com> <87v9ug2dsu.fsf@ngyro.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:44735) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i4y5m-00054s-T3 for help-guix@gnu.org; Mon, 02 Sep 2019 21:58:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i4y5l-0006AN-Jf for help-guix@gnu.org; Mon, 02 Sep 2019 21:58:46 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:36411) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i4y5l-00067y-GD for help-guix@gnu.org; Mon, 02 Sep 2019 21:58:45 -0400 In-Reply-To: (Pierre-Henry F.'s message of "Mon, 02 Sep 2019 21:25:53 +0000") List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-guix-bounces+gcggh-help-guix=m.gmane.org@gnu.org Sender: "Help-Guix" To: "Pierre-Henry F." Cc: help-guix@gnu.org Hello, "Pierre-Henry F." writes: > > Hello Tim ! > > I'm using a couple of hours here an there to try to rebuild the package y= ou gave me (Thank you for that :-) ). > So far, I've built a very stupid but "working" package (see below if you = really want to ;-) ). Looks good so far! > Will answer on the mailing list for others to benefit from this exchange. I=E2=80=99ve added the mailing list back in, then. ;) > Needless to say, it's not exactly obvious to figure these things out /a p= riori/. For sure. By using the trivial build system, you=E2=80=99re working at a p= retty low level. It=E2=80=99s especially tough to learn both Guix and Guile at t= he same time. For your reference, here=E2=80=99s a sketch of what the =E2=80= =9C#:builder=E2=80=9D code would look like if it were Python: import os, shutil, stat, subprocess, guix.build.utils # Unpack source =3D _build_inputs["source"] tar =3D _build_inputs["tar"] lzip =3D _build_inputs["lzip"] os.putenv("PATH", ":".join([tar + "/bin", lzip + "/bin"])) subprocess.run(["tar", "--lzip", "-xvf", source]) # Configure bash =3D _build_inputs["bash"] python =3D _build_inputs["python"] guix.build.utils.substitute("blog/bin/program", [["/usr/bin/bash", bash + "/bin/bash"], ["python3", python + "/bin/python3"]]) # Install out =3D _outputs["out"] os.chmod("blog/bin/program", 0o755) shutil.copytree("blog", out) Here, =E2=80=9C_build_inputs=E2=80=9D and =E2=80=9C_outputs=E2=80=9D are se= t by Guix, and are dictionaries. For =E2=80=9C_build_inputs=E2=80=9D, the keys are the string= s you put in the =E2=80=9Cinputs=E2=80=9D part of the package, and the values are the pa= ths where the packages are installed. So, =E2=80=9C_build_inputs["python"]=E2=80=9D poin= ts to the directory in the store where Python is installed. We usually only have one output, which is called =E2=80=9Cout=E2=80=9D. This is the path in the= store where we install the package being built. The only other thing is that =E2=80=9Cguix.build.utils.substitute=E2=80=9D = is basically just find-and-replace. It takes the name of a file and a list of two-element lists and replaces all the occurrences of the first elements in the file with their corresponding second elements. Obviously the Guile interfaces are a little different, but hopefully this Rosetta Stone makes it easier to see what=E2=80=99s going on. As an aside, ever since I learned that there=E2=80=99s a way to do quasiquo= tes in Python [1], I=E2=80=99ve wondered how strange it would be if Guix were written in Python. Pretty strange! :) [1] https://macropy3.readthedocs.io/en/latest/reference.html#quasiquote > Anyway, thanks! You=E2=80=99re welcome! -- Tim