all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: david larsson <david.larsson@selfhosted.xyz>
To: jgart <jgart@dismail.de>
Cc: Guix Devel <guix-devel@gnu.org>,
	Guix-devel
	<guix-devel-bounces+david.larsson=selfhosted.xyz@gnu.org>
Subject: Re: What happens when you build a Guix package at every step?
Date: Sun, 25 Sep 2022 21:17:36 +0200	[thread overview]
Message-ID: <df87b93bedb58101e93653a37d1e53c6@selfhosted.xyz> (raw)
In-Reply-To: <20220925122824.GB30202@dismail.de>

On 2022-09-25 19:28, jgart wrote:
> What would be the best way to illustrate the levels of nesting and code
> paths that get traversed when building a Guix package?
> 
> I'd like to make some sequence diagram notation or something else to
> better understand what happens in a visual way.
> 
> wdyt

I like your idea! I'm probably not the most qualified person to answer 
it, since I am (also?) mainly using guix as a sparetime "hobby", but 
still very interested in learning more about it on a deeper level, which 
is a challenge. Some visual aids would definitely be helpful.

I think a shell of an answer would be to link together the following 
things in such a diagram:

1. gexps
2. the store
3. derivations
4. build systems
5. a package

Building a package in the repl, kind of illustrates the code paths via 
code modules used:

scheme@(guix-user)> ,use (guix gexp)
scheme@(guix-user)> ,use (guix store)
scheme@(guix-user)> ,use (guix derivations)
scheme@(guix-user)> ,use (gnu packages bash)

However, in my opinion, the reason we look for the diagram is partially 
bcs of that the concepts of the related things are relatively high level 
so that it takes a while to grasp them, just like monads or maybe higher 
order functions.

However, to continue the repl example:

scheme@(guix-user)> (define (sh-symlink)
   (gexp->derivation "sh"
                     #~(symlink (string-append #$bash "/bin/bash")
                                #$output)))
scheme@(guix-user)> (build-derivations (open-connection) 
`(,(run-with-store (open-connection) (sh-symlink))))
$1 = #t

Now if you run just the (run-with-store (open-connection) (sh-symlink)) 
you will see the derivation path output, and if you then open a new 
terminal you can cat /gnu/store/shcvi6d1vgry26sq1i3qdmgsmh0n6wmi-sh.drv 
to see the build script without building it.

Now, to build a "package" after above code is loaded:
scheme@(guix-user)> ,use (guix packages)
scheme@(guix-user)> (build-derivations (open-connection) 
`(,(package-derivation (open-connection) bash)))
substitute: updating substitutes from 'https://ci.guix.gnu.org'... 
100.0%
fetching path 
`/gnu/store/vk4r0x7baig8jnmsqrgrqpyq8qxr4gm3-bash-5.0.16-doc'...
Downloading 
https://ci.guix.gnu.org/nar/lzip/vk4r0x7baig8jnmsqrgrqpyq8qxr4gm3-bash-5.0.16-doc...
bash-5.0.16-doc  290KiB              750KiB/s 00:00 [##################] 
100.0%
$2 = #t

And to only "inspect" it (so you can cat the /gnu/store/paths):
scheme@(guix-user)> (package-derivation (open-connection) bash)
$4 = #<derivation 
/gnu/store/cklj3xvrzrc930qwj1brmwr2dz4zbgd6-bash-5.0.16.drv => 
/gnu/store/vk4r0x7baig8jnmsqrgrqpyq8qxr4gm3-bash-5.0.16-doc 
/gnu/store/v1xc4405s7xilmwhhkdj8z55wa2wlr8y-bash-5.0.16-include 
/gnu/store/87kif0bpf0anwbsaw0jvg8fyciw4sz67-bash-5.0.16 7fc3d283e500>

Concepts:
   - code staging or "delayed evaluation" concepts
   - what is the store and what is a build environment
   - what is a derivation
   - and finally build systems (normal build steps) and a package (incl. 
dependency graphs).

The start reference point: 
https://guix.gnu.org/manual/en/html_node/Defining-Packages.html


I hope above helps.

Best regards,
David


  reply	other threads:[~2022-09-25 19:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-25 17:28 What happens when you build a Guix package at every step? jgart
2022-09-25 19:17 ` david larsson [this message]
2022-09-26 21:03 ` jbranso
2022-09-29 17:00   ` david larsson

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=df87b93bedb58101e93653a37d1e53c6@selfhosted.xyz \
    --to=david.larsson@selfhosted.xyz \
    --cc=guix-devel-bounces+david.larsson=selfhosted.xyz@gnu.org \
    --cc=guix-devel@gnu.org \
    --cc=jgart@dismail.de \
    /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.