all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Timothy Sample <samplet@ngyro.com>
To: "Pierre-Henry F." <contact@phfrohring.com>
Cc: help-guix@gnu.org
Subject: Re: Help defining a trivial package.
Date: Mon, 02 Sep 2019 21:58:42 -0400	[thread overview]
Message-ID: <87woeqywbx.fsf@ngyro.com> (raw)
In-Reply-To: <Al-P-mUDUQnoUvF4kgNS_NeITvHjEDEvxG8Gmk9aMiXX2FTUfL0lbZAq5h4m54GIGNXPwM271CzLWwt5sgOt1JI6Z1wxqxSwWmpnPHu7I5A=@phfrohring.com> (Pierre-Henry F.'s message of "Mon, 02 Sep 2019 21:25:53 +0000")

Hello,

"Pierre-Henry F." <contact@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

  parent reply	other threads:[~2019-09-03  1:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-23 19:42 Help defining a trivial package Pierre-Henry F.
2019-08-25 12:17 ` Timothy Sample
2019-08-29 11:23   ` Pierre-Henry F.
2019-08-29 15:26     ` Timothy Sample
     [not found]       ` <Al-P-mUDUQnoUvF4kgNS_NeITvHjEDEvxG8Gmk9aMiXX2FTUfL0lbZAq5h4m54GIGNXPwM271CzLWwt5sgOt1JI6Z1wxqxSwWmpnPHu7I5A=@phfrohring.com>
2019-09-03  1:58         ` Timothy Sample [this message]
2019-09-04 11:21           ` Pierre-Henry F.
2019-09-04 17:34             ` Timothy Sample

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87woeqywbx.fsf@ngyro.com \
    --to=samplet@ngyro.com \
    --cc=contact@phfrohring.com \
    --cc=help-guix@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.