Guix Package Rebuilds

Building any package from the archive

Mastering Guix Packaging

  • The main scenarios are
    • ​Using an older package (downgrading)
    • Rebuilding an existing package
    • Modifying an existing package
    • Creating a new package (with and without source)
    • Contributing a package to the distribution
  • ​We use Guix build in all these scenarios
     

Learning Path

Profiles

Package

Commands

Shell

Command

Basic Build

Command

Manifests

Manifests

Transforms in Manifests

Guix Build Overview

  • Guix build is used to build a package (or a derivation)

  • Receives:
    • package definition
    • Guix build options

  • It outputs:
    • build logs
    • build derivation
    • package

  • Recommendation: use with guix shell for a clean build environment

Guix Build Overview

  • Guix build is used to build a package (or a derivation)
  • Receives:
    • package definition
    • Guix build options
  • It outputs:
    • build logs
    • build derivation 
    • package
  • Recommendation: use with guix shell for a clean build environment
$ guix build hello --no-substitutes --no-grafts
The following derivation will be built:
     /gnu/store/xn12lv3ckihkai4044p28h5im78lvad5-hello-2.12.1.drv
    
    [... lots of output as it builds the package ...]
    
    successfully built /gnu/store/xn12lv3ckihkai4044p28h5im78lvad5-hello-2.12.1.drv
	/gnu/store/5mqwac3zshjjn1ig82s12rbi7whqm4n8-hello-2.12.1

1

Create build environment with guix shell

3

Create a test environment with guix shell and test the new build

2

Build the current package to test dependencies

Package build steps

Start a build shell environment:

 

guix shell --container --nesting  --network \

  --development hello nss-certs

See it in Action

Option Description
--dry-run Give output but don't take the action
--no-substitutes Don't use binary substitutes
--no-grafts Do not put security grafts onto packages
--verbosity=<lvl> 0=no output; 1=quiet; 2=show urls; 3=build log
--cores=n Use N CPU cores for each build job
--max-jobs=N Allow the Guix Daemon to run at most N build jobs. Each build can be limited to use --cores=N
--check Rebuilt an items that's already in the Store to check determinism  
--source Build the packages source derivation

Common Build Options

$ guix shell --container --nesting --development hello \
  --network --no-grafts nss-certs
The following derivation will be built:
  /gnu/store/jaz9fabc7l9iwkxf648iq0ajafzgs049-profile.drv
building CA certificate bundle...
listing Emacs sub-directories...
building fonts directory...
building directory of Info manuals...
building profile with 23 packages...

Create a build environment

- nesting - run further package commands in the shell environment

- add nss-certs so that commands can use SSL

1

Rebuild the Package

$ guix shell --container --nesting --development hello \
  --network --no-grafts nss-certs
The following derivation will be built:
  /gnu/store/jaz9fabc7l9iwkxf648iq0ajafzgs049-profile.drv
building CA certificate bundle...
listing Emacs sub-directories...
building fonts directory...
building directory of Info manuals...
building profile with 23 packages...

[env]$ guix build --no-substitutes --no-grafts --source hello
The following derivation will be built:
  /gnu/store/2p9bkv91gr64nm17qq0byavwg5q6w2lg-hello-2.12.1.tar.gz.drv
building /gnu/store/2p9bkv91gr64nm17qq0byavwg5q6w2lg-hello-2.12.1.tar.gz.drv...

Starting download of /gnu/store/3dq55rw99wdc4g4wblz7xikc8a2jy7a3-hello-2.12.1.tar.gz
From https://ftpmirror.gnu.org/gnu/hello/hello-2.12.1.tar.gz...
following redirection to `https://mirrors.tripadvisor.com/gnu/hello/hello-2.12.1.tar.gz'...
downloading from https://ftpmirror.gnu.org/gnu/hello/hello-2.12.1.tar.gz ...
 hello-2.12.1.tar.gz  1009KiB                                                               1.6MiB/s 00:01 [##################] 100.0%
successfully built /gnu/store/2p9bkv91gr64nm17qq0byavwg5q6w2lg-hello-2.12.1.tar.gz.drv
/gnu/store/3dq55rw99wdc4g4wblz7xikc8a2jy7a3-hello-2.12.1.tar.gz

download the source and put it into the store.

2

Rebuild the Package












[env]$ guix build --no-substitutes --no-grafts --source hello
The following derivation will be built:
  /gnu/store/2p9bkv91gr64nm17qq0byavwg5q6w2lg-hello-2.12.1.tar.gz.drv
building /gnu/store/2p9bkv91gr64nm17qq0byavwg5q6w2lg-hello-2.12.1.tar.gz.drv...

Starting download of /gnu/store/3dq55rw99wdc4g4wblz7xikc8a2jy7a3-hello-2.12.1.tar.gz
From https://ftpmirror.gnu.org/gnu/hello/hello-2.12.1.tar.gz...
following redirection to `https://mirrors.tripadvisor.com/gnu/hello/hello-2.12.1.tar.gz'...
downloading from https://ftpmirror.gnu.org/gnu/hello/hello-2.12.1.tar.gz ...
 hello-2.12.1.tar.gz  1009KiB                                                               1.6MiB/s 00:01 [##################] 100.0%
successfully built /gnu/store/2p9bkv91gr64nm17qq0byavwg5q6w2lg-hello-2.12.1.tar.gz.drv
/gnu/store/3dq55rw99wdc4g4wblz7xikc8a2jy7a3-hello-2.12.1.tar.gz

[env]$ guix build --no-substitutes --no-grafts --verbosity=1 hello
The following derivation will be built:
  /gnu/store/3zh2qpi897s2x229s93iakji86b08a20-hello-2.12.1.drv

building /gnu/store/3zh2qpi897s2x229s93iakji86b08a20-hello-2.12.1.drv...
/gnu/store/5mqwac3zshjjn1ig82s12rbi7whqm4n8-hello-2.12.1

2

$ guix shell --container --nesting --no-grafts
guix shell: warning: no packages specified; creating an empty environment
The following derivation will be built:
  /gnu/store/jv8hws211gw8vbv9rcjnigl5xik1k8vq-profile.drv

building CA certificate bundle...
listing Emacs sub-directories...
building fonts directory...
building directory of Info manuals...
building profile with 1 package...

Test the Package

- no network as we're installing locally

- no packages as we're just going to test it

- add testing packages through a manifest (for example coreutils)

  • Install the package into a test shell - use it!
  • 🏆 TIP: by avoiding installing it into a standard profile we can delete it:

$ guix gc --delete /gnu/store/<blah>

                                              OR use --check

3

$ guix shell --container --nesting --no-grafts
guix shell: warning: no packages specified; creating an empty environment
The following derivation will be built:
  /gnu/store/jv8hws211gw8vbv9rcjnigl5xik1k8vq-profile.drv

building CA certificate bundle...
listing Emacs sub-directories...
building fonts directory...
building directory of Info manuals...
building profile with 1 package...

[env]$ guix shell --install  /gnu/store/3zh2qpi897s2x229s93iakji86b08a20-hello-2.12.1.drv
The following package will be installed:
   hello 2.12.1

The following derivation will be built:
  /gnu/store/kkf3dwfjy1mkll3m4wbcxx76v2p2yjyc-profile.drv

building CA certificate bundle...
listing Emacs sub-directories...
building fonts directory...
building directory of Info manuals...
building profile with 1 package...
hint: Consider setting the necessary environment variables by running:

     GUIX_PROFILE="/home/steve/.guix-profile"
     . "$GUIX_PROFILE/etc/profile"

Alternately, see `guix package --search-paths -p "/home/steve/.guix-profile"'.

$ /home/steve/.guix-profile/bin/hello
Hello,world!

Test the Package

Success!

3

What we've seen

Package build command so we can build any package from the archive

1

Guix build

Using Guix shell to create both a build and a test enviroment

2

Guix shell

Installing the package locally to test it

3

Testing packages

Taking it further

To learn more:

 

  • Futurile blog: www.futurile.net
  • Guix Manual: guix.gnu.org

Steps from here

Profiles

Package

Commands

Shell

Command

Basic Build

Command

Manifests

Transform

Command

Manifests

Transforms in Manifests

Thank You!

VIDEO

Guix Build

2:40 minutes

Guix Package Rebuilds

By futurile

Guix Package Rebuilds

  • 29