guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What happens when you build a Guix package at every step?


From: jbranso
Subject: Re: What happens when you build a Guix package at every step?
Date: Mon, 26 Sep 2022 21:03:20 +0000

September 25, 2022 3:18 PM, "david larsson" <david.larsson@selfhosted.xyz> 
wrote:

> 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)

I think you can also do a
,build derivation

This link has more info:

https://issues.guix.gnu.org/56114

> (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 via email to

[Prev in Thread] Current Thread [Next in Thread]