Hello, "Pierre-Henry F." <cont...@phfrohring.com> writes: > > Hello Tim ! > > I'm using a couple of hours here an there to try to rebuild the package you > 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’ve added the mailing list back in, then. ;) > Needless to say, it's not exactly obvious to figure these things out /a > priori/. For sure. By using the trivial build system, you’re working at a pretty low level. It’s especially tough to learn both Guix and Guile at the same time. For your reference, here’s a sketch of what the “#:builder” code would look like if it were Python: import os, shutil, stat, subprocess, guix.build.utils # Unpack source = _build_inputs["source"] tar = _build_inputs["tar"] lzip = _build_inputs["lzip"] os.putenv("PATH", ":".join([tar + "/bin", lzip + "/bin"])) subprocess.run(["tar", "--lzip", "-xvf", source]) # Configure bash = _build_inputs["bash"] python = _build_inputs["python"] guix.build.utils.substitute("blog/bin/program", [["/usr/bin/bash", bash + "/bin/bash"], ["python3", python + "/bin/python3"]]) # Install out = _outputs["out"] os.chmod("blog/bin/program", 0o755) shutil.copytree("blog", out) Here, “_build_inputs” and “_outputs” are set by Guix, and are dictionaries. For “_build_inputs”, the keys are the strings you put in the “inputs” part of the package, and the values are the paths where the packages are installed. So, “_build_inputs["python"]” points to the directory in the store where Python is installed. We usually only have one output, which is called “out”. This is the path in the store where we install the package being built. The only other thing is that “guix.build.utils.substitute” 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’s going on. As an aside, ever since I learned that there’s a way to do quasiquotes in Python [1], I’ve 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’re welcome! -- Tim