143
Guix, Functional Package Management for the People Ludovic Court ` es [email protected] GNU Hackers Meeting, July 2012, D¨ usseldorf

Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

  • Upload
    others

  • View
    20

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

Guix, Functional Package Management forthe People

Ludovic [email protected]

GNU Hackers Meeting, July 2012, Dusseldorf

Page 2: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

GNUten Tag, Dusseldorf!

Page 3: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

GNUten Tag, Dusseldorf!

Page 4: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

what’s Guix?http://gitorious.org/guix/

I it’s the new thing!I IPA: /gi:ks/

I functional package manager!I written in Guile Scheme!I a new programming layer for NixI Nix?

Page 5: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

what’s Guix?http://gitorious.org/guix/

I it’s the new thing!I IPA: /gi:ks/I functional package manager!

I written in Guile Scheme!I a new programming layer for NixI Nix?

Page 6: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

what’s Guix?http://gitorious.org/guix/

I it’s the new thing!I IPA: /gi:ks/I functional package manager!I written in Guile Scheme!

I a new programming layer for NixI Nix?

Page 7: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

what’s Guix?http://gitorious.org/guix/

I it’s the new thing!I IPA: /gi:ks/I functional package manager!I written in Guile Scheme!I a new programming layer for Nix

I Nix?

Page 8: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

what’s Guix?http://gitorious.org/guix/

I it’s the new thing!I IPA: /gi:ks/I functional package manager!I written in Guile Scheme!I a new programming layer for NixI Nix?

Page 9: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

so what’s Nix?http://nixos.org/nix/

I a functional package manager

I functional, again?

but the one i use works great too!

I of course it does! more on this later...

Page 10: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

so what’s Nix?http://nixos.org/nix/

I a functional package managerI functional, again?

but the one i use works great too!I of course it does! more on this later...

Page 11: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

so what’s Nix?http://nixos.org/nix/

I a functional package managerI functional, again? but the one i use works great too!

I of course it does! more on this later...

Page 12: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

so what’s Nix?http://nixos.org/nix/

I a functional package managerI functional, again? but the one i use works great too!I of course it does! more on this later...

Page 13: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

and NixOS?http://nixos.org/

I a free GNU/Linux distro (MIT/X11), est. 2006I i686, x86 64, armv5telI ≈8000 packages, ≈35 regular contributors (yeah!)I transparent binary/source deployment

Page 14: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

bells, whistles, and moreper-user package installationtransactional upgrades & rollbacksystem description & instantiation

the mechanicsbuild environmentsbuilding packagesputting it another way

from Nix to Guixrationaleusing ita GNU distro?

Page 15: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

bells, whistles, and moreper-user package installationtransactional upgrades & rollbacksystem description & instantiation

the mechanicsbuild environmentsbuilding packagesputting it another way

from Nix to Guixrationaleusing ita GNU distro?

Page 16: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

per-user, unprivileged package installation

alice@foo$ nix-env --install gcc-4.5 icecat-3.6

alice@foo$ nix-store -q --requisites ‘which icecat‘

/nix/store/...-glibc-2.10

/nix/store/...-gtk+-2.16.6

/nix/store/...-alsa-lib-1.0.19

...

bob@foo$ nix-env --install gcc-4.3 icecat-3.7

bob@foo$ nix-store -q --requisites ‘which icecat‘

/nix/store/...-glibc-2.11.1

/nix/store/...-gtk+-2.18.6

/nix/store/...-alsa-lib-1.0.21a

...

Page 17: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

per-user, unprivileged package installation

alice@foo$ nix-env --install gcc-4.5 icecat-3.6

alice@foo$ nix-store -q --requisites ‘which icecat‘

/nix/store/...-glibc-2.10

/nix/store/...-gtk+-2.16.6

/nix/store/...-alsa-lib-1.0.19

...

bob@foo$ nix-env --install gcc-4.3 icecat-3.7

bob@foo$ nix-store -q --requisites ‘which icecat‘

/nix/store/...-glibc-2.11.1

/nix/store/...-gtk+-2.18.6

/nix/store/...-alsa-lib-1.0.21a

...

Page 18: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

per-user, unprivileged package installation

alice@foo$ nix-env --install gcc-4.5 icecat-3.6

alice@foo$ nix-store -q --requisites ‘which icecat‘

/nix/store/...-glibc-2.10

/nix/store/...-gtk+-2.16.6

/nix/store/...-alsa-lib-1.0.19

...

bob@foo$ nix-env --install gcc-4.3 icecat-3.7

bob@foo$ nix-store -q --requisites ‘which icecat‘

/nix/store/...-glibc-2.11.1

/nix/store/...-gtk+-2.18.6

/nix/store/...-alsa-lib-1.0.21a

...

Page 19: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

per-user, unprivileged package installation

alice@foo$ nix-env --install gcc-4.5 icecat-3.6

alice@foo$ nix-store -q --requisites ‘which icecat‘

/nix/store/...-glibc-2.10

/nix/store/...-gtk+-2.16.6

/nix/store/...-alsa-lib-1.0.19

...

bob@foo$ nix-env --install gcc-4.3 icecat-3.7

bob@foo$ nix-store -q --requisites ‘which icecat‘

/nix/store/...-glibc-2.11.1

/nix/store/...-gtk+-2.18.6

/nix/store/...-alsa-lib-1.0.21a

...

Page 20: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

transparent binary/source deployment

alice@foo$ nix-env --install gcc-4.5

installing ‘gcc-4.5.3’

these paths will be fetched (20.00 MiB download):

/nix/store/...-gcc-wrapper-4.5.3

/nix/store/...-cloog-ppl-0.15.11

/nix/store/...-gcc-4.5.3

these derivations will be built:

/nix/store/...-gcc-wrapper-4.5.3.drv

/nix/store/...-gcc-4.5.3.drv

these paths will be fetched (30.00 MiB download):

/nix/store/...-cloog-ppl-0.15.11

/nix/store/...-gcc-4.5.3.tar.gz

Page 21: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

transparent binary/source deployment

alice@foo$ nix-env --install gcc-4.5

installing ‘gcc-4.5.3’

these derivations will be built:

/nix/store/...-gcc-wrapper-4.5.3.drv

/nix/store/...-gcc-4.5.3.drv

these paths will be fetched (30.00 MiB download):

/nix/store/...-cloog-ppl-0.15.11

/nix/store/...-gcc-4.5.3.tar.gz

Page 22: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

bells, whistles, and moreper-user package installationtransactional upgrades & rollbacksystem description & instantiation

the mechanicsbuild environmentsbuilding packagesputting it another way

from Nix to Guixrationaleusing ita GNU distro?

Page 23: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

atomic & transactional upgrades

$ nix-env --upgrade ’*’

upgrading ‘git-1.6.5’ to ‘git-1.7.1’

upgrading ‘gimp-2.6.8’ to ‘gimp-2.6.9’

upgrading ‘gnupg-2.0.12’ to ‘gnupg-2.0.15’

upgrading ‘gdb-7.0.1’ to ‘gdb-7.1’

upgrading ‘gnutls-2.8.5’ to ‘gnutls-2.10.0’

upgrading ‘openoffice.org-3.1.1’ to ‘openoffice.org-3.2.0’

upgrading ‘coccinelle-0.2.1’ to ‘coccinelle-0.2.2’

...

(interrupted right in the middle)

$ git --version ; gimp --version

git version

GNU Image Manipulation Program version

Page 24: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

atomic & transactional upgrades

$ nix-env --upgrade ’*’

upgrading ‘git-1.6.5’ to ‘git-1.7.1’

upgrading ‘gimp-2.6.8’ to ‘gimp-2.6.9’

upgrading ‘gnupg-2.0.12’ to ‘gnupg-2.0.15’

upgrading ‘gdb-7.0.1’ to ‘gdb-7.1’

upgrading ‘gnutls-2.8.5’ to ‘gnutls-2.10.0’

upgrading ‘openoffice.org-3.1.1’ to ‘openoffice.org-3.2.0’

upgrading ‘coccinelle-0.2.1’ to ‘coccinelle-0.2.2’

...

(interrupted right in the middle)

$ git --version ; gimp --version

git version 1.7.1

GNU Image Manipulation Program version 2.6.9

Page 25: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

atomic & transactional upgrades

$ nix-env --upgrade ’*’

upgrading ‘git-1.6.5’ to ‘git-1.7.1’

upgrading ‘gimp-2.6.8’ to ‘gimp-2.6.9’

upgrading ‘gnupg-2.0.12’ to ‘gnupg-2.0.15’

upgrading ‘gdb-7.0.1’ to ‘gdb-7.1’

upgrading ‘gnutls-2.8.5’ to ‘gnutls-2.10.0’

upgrading ‘openoffice.org-3.1.1’ to ‘openoffice.org-3.2.0’

upgrading ‘coccinelle-0.2.1’ to ‘coccinelle-0.2.2’

...

(interrupted right in the middle)

$ git --version ; gimp --version

git version

GNU Image Manipulation Program version

Page 26: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

atomic & transactional upgrades

$ nix-env --upgrade ’*’

upgrading ‘git-1.6.5’ to ‘git-1.7.1’

upgrading ‘gimp-2.6.8’ to ‘gimp-2.6.9’

upgrading ‘gnupg-2.0.12’ to ‘gnupg-2.0.15’

upgrading ‘gdb-7.0.1’ to ‘gdb-7.1’

upgrading ‘gnutls-2.8.5’ to ‘gnutls-2.10.0’

upgrading ‘openoffice.org-3.1.1’ to ‘openoffice.org-3.2.0’

upgrading ‘coccinelle-0.2.1’ to ‘coccinelle-0.2.2’

...

(interrupted right in the middle)

$ git --version ; gimp --version

git version 1.6.5

GNU Image Manipulation Program version 2.6.8

Page 27: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

atomic & transactional upgrades

$ nix-env --upgrade ’*’

upgrading ‘git-1.6.5’ to ‘git-1.7.1’

upgrading ‘gimp-2.6.8’ to ‘gimp-2.6.9’

upgrading ‘gnupg-2.0.12’ to ‘gnupg-2.0.15’

upgrading ‘gdb-7.0.1’ to ‘gdb-7.1’

upgrading ‘gnutls-2.8.5’ to ‘gnutls-2.10.0’

upgrading ‘openoffice.org-3.1.1’ to ‘openoffice.org-3.2.0’

upgrading ‘coccinelle-0.2.1’ to ‘coccinelle-0.2.2’

...

(interrupted right in the middle)

$ git --version ; gimp --version

git version 1.6.5

GNU Image Manipulation Program version 2.6.8

Page 28: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

per-user rollback

$ gimp --version

GNU Image Manipulation Program version 2.6.8

$ nix-env --upgrade gimp

upgrading ‘gimp-2.6.8’ to ‘gimp-2.6.9’

...

$ gimp --version

Segmentation Fault

$ nix-env --rollback

switching from generation 278 to 277

$ gimp --version

GNU Image Manipulation Program version 2.6.8

Page 29: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

per-user rollback

$ gimp --version

GNU Image Manipulation Program version 2.6.8

$ nix-env --upgrade gimp

upgrading ‘gimp-2.6.8’ to ‘gimp-2.6.9’

...

$ gimp --version

Segmentation Fault

$ nix-env --rollback

switching from generation 278 to 277

$ gimp --version

GNU Image Manipulation Program version 2.6.8

Page 30: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

per-user rollback

$ gimp --version

GNU Image Manipulation Program version 2.6.8

$ nix-env --upgrade gimp

upgrading ‘gimp-2.6.8’ to ‘gimp-2.6.9’

...

$ gimp --version

Segmentation Fault

$ nix-env --rollback

switching from generation 278 to 277

$ gimp --version

GNU Image Manipulation Program version 2.6.8

Page 31: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

per-user rollback

$ gimp --version

GNU Image Manipulation Program version 2.6.8

$ nix-env --upgrade gimp

upgrading ‘gimp-2.6.8’ to ‘gimp-2.6.9’

...

$ gimp --version

Segmentation Fault

$ nix-env --rollback

switching from generation 278 to 277

$ gimp --version

GNU Image Manipulation Program version 2.6.8

Page 32: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

per-user rollback

$ gimp --version

GNU Image Manipulation Program version 2.6.8

$ nix-env --upgrade gimp

upgrading ‘gimp-2.6.8’ to ‘gimp-2.6.9’

...

$ gimp --version

Segmentation Fault

$ nix-env --rollback

switching from generation 278 to 277

$ gimp --version

GNU Image Manipulation Program version 2.6.8

Page 33: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

bells, whistles, and moreper-user package installationtransactional upgrades & rollbacksystem description & instantiation

the mechanicsbuild environmentsbuilding packagesputting it another way

from Nix to Guixrationaleusing ita GNU distro?

Page 34: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

system description/etc/nixos/configuration.nix

{ pkgs, config, modulesPath, ... }:

{

boot = {

kernelPackages = pkgs.linuxPackages 2 6 31;

initrd.kernelModules = [ "uhci hcd" "ata piix" ];

kernelModules = [ "kvm-intel" "sdhci" "fuse" ];

loader.grub = {

device = "/dev/sda";

version = 2;

};

};

Page 35: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

system description/etc/nixos/configuration.nix

fileSystems =

[ { mountPoint = "/";

fsType = "ext3";

device = "/dev/sda1";

}

{ mountPoint = "/home";

fsType = "ext3";

device = "/dev/sda3";

}

];

swapDevices = [ device = "/dev/sda2"; ];

Page 36: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

system description/etc/nixos/configuration.nix

networking.hostName = "mylaptop";

security.extraSetuidPrograms =

[ "sudo" "xlaunch" "xscreensaver" "xlock" "wodim" ];

time.timeZone = "Europe/Paris";

users = {

extraUsers = [

{ name = "ludo";

group = "users";

extraGroups = [ "audio" "cdrom" "video" ];

}

];

};

Page 37: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

system description/etc/nixos/configuration.nix

services = {

lshd = {

enable = true;

rootLogin = true;

};

tor.enable = true;

avahi.enable = true;

xserver = {

enable = true;

videoDriver = "intel";

driSupport = true;

synaptics.enable = true;

};

};

}

Page 38: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

whole-system instantiation

$ sudo nixos-rebuild switch

...

Page 39: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

whole-system instantiation

$ nixos-rebuild build-vm

...

Page 40: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

whole-system instantiation

$ nixos-rebuild build-vm

...

Page 41: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

whole-system instantiation

$ nixos-rebuild build-vm

...

Done. The virtual machine can be

started by running ./result/bin/run-my-vm.

Page 42: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

whole-system instantiation

$ nixos-rebuild build-vm

...

Page 43: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

whole-system instantiation

$ sudo nixos-rebuild test

...

“activates” the configuration (restarts daemons, etc.)

Page 44: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

whole-system instantiation

$ sudo nixos-rebuild switch

...

activates the configuration & makes it the boot default

Page 45: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

whole-system instantiation

$ sudo nixos-rebuild

...

Page 46: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

system-wide rollback

$ nixos-rebuild switch --rollback

...

... and voila.

Page 47: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

system-wide rollback

$ nixos-rebuild switch --rollback

...

... and voila.

Page 48: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

so you’re already convinced...

Page 49: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

so you’re already convinced...

Yes!tell me more!

Page 50: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

bells, whistles, and moreper-user package installationtransactional upgrades & rollbacksystem description & instantiation

the mechanicsbuild environmentsbuilding packagesputting it another way

from Nix to Guixrationaleusing ita GNU distro?

Page 51: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

bells, whistles, and moreper-user package installationtransactional upgrades & rollbacksystem description & instantiation

the mechanicsbuild environmentsbuilding packagesputting it another way

from Nix to Guixrationaleusing ita GNU distro?

Page 52: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

build environments & reproducibility

I versions of the dependenciesI compilerI compilation options, and those of dependenciesI miscellaneous (locale, timezone, etc.)I paths

-I/path/to/headers $CPATH

-L/path/to/lib $LIBRARY PATH

$LD LIBRARY PATH

RPATH RUNPATH

$PYTHONPATH

$PERL5LIB$XML CATALOG FILES $GUILE LOAD PATH

$CLASSPATH

Page 53: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

build environments & reproducibility

I versions of the dependenciesI compilerI compilation options, and those of dependenciesI miscellaneous (locale, timezone, etc.)I paths

-I/path/to/headers $CPATH

-L/path/to/lib $LIBRARY PATH

$LD LIBRARY PATH

RPATH RUNPATH

$PYTHONPATH

$PERL5LIB$XML CATALOG FILES $GUILE LOAD PATH

$CLASSPATH

Page 54: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

build environments & reproducibility

I versions of the dependenciesI compilerI compilation options, and those of dependenciesI miscellaneous (locale, timezone, etc.)I paths

-I/path/to/headers $CPATH

-L/path/to/lib $LIBRARY PATH

$LD LIBRARY PATH

RPATH RUNPATH

$PYTHONPATH

$PERL5LIB$XML CATALOG FILES $GUILE LOAD PATH

$CLASSPATH

Page 55: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

build environments & reproducibility

I versions of the dependenciesI compilerI compilation options, and those of dependenciesI miscellaneous (locale, timezone, etc.)I paths

-I/path/to/headers $CPATH

-L/path/to/lib $LIBRARY PATH

$LD LIBRARY PATH

RPATH RUNPATH

$PYTHONPATH

$PERL5LIB$XML CATALOG FILES $GUILE LOAD PATH

$CLASSPATH

Page 56: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

build environments & reproducibility

I versions of the dependenciesI compilerI compilation options, and those of dependenciesI miscellaneous (locale, timezone, etc.)I paths

-I/path/to/headers $CPATH

-L/path/to/lib $LIBRARY PATH

$LD LIBRARY PATH

RPATH RUNPATH

$PYTHONPATH

$PERL5LIB$XML CATALOG FILES $GUILE LOAD PATH

$CLASSPATHahem, reproducible builds?

Page 57: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

how Nix controls the build environment

1. one directory per installed package2. immutable installation directories3. undeclared dependencies invisible to the build process

(POLA)4. build performed in chroot, with separate UID, PID name

space, etc.

Page 58: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

how Nix controls the build environment

1. one directory per installed package

2. immutable installation directories3. undeclared dependencies invisible to the build process

(POLA)4. build performed in chroot, with separate UID, PID name

space, etc.

Page 59: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

how Nix controls the build environment

1. one directory per installed package2. immutable installation directories

3. undeclared dependencies invisible to the build process(POLA)

4. build performed in chroot, with separate UID, PID namespace, etc.

Page 60: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

how Nix controls the build environment

1. one directory per installed package2. immutable installation directories3. undeclared dependencies invisible to the build process

(POLA)

4. build performed in chroot, with separate UID, PID namespace, etc.

Page 61: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

how Nix controls the build environment

1. one directory per installed package2. immutable installation directories3. undeclared dependencies invisible to the build process

(POLA)4. build performed in chroot, with separate UID, PID name

space, etc.

Page 62: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

bells, whistles, and moreper-user package installationtransactional upgrades & rollbacksystem description & instantiation

the mechanicsbuild environmentsbuilding packagesputting it another way

from Nix to Guixrationaleusing ita GNU distro?

Page 63: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

the store

/nix/store

c6jbqm2...-emacs-24.1 bin emacs

smkabrb...-gnutls-3.0.18 lib libgnutls.so

l9w6773...-lsh-2.0.4

bin lsh

sbin lshd

im276ak...-glibc-2.16 lib libc.so.6

Page 64: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

user environments

$PATH

/nix/.../profiles

current

42

/nix/storepp56i0a01si5...-user-env

binicecatssh

l9w6773m1msy...-openssh-4.6p1bin

sshrpdqxnilb0cg...-icecat-3.5.4

binicecat

Page 65: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

user environments

$PATH

/nix/.../profiles

current

42

/nix/storepp56i0a01si5...-user-env

binicecatssh

l9w6773m1msy...-openssh-4.6p1bin

sshrpdqxnilb0cg...-icecat-3.5.4

binicecat

aqn3wygq9jzk...-openssh-5.2p1bin

ssh

nix-env --upgrade openssh

Page 66: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

user environments

$PATH

/nix/.../profiles

current

42

/nix/storepp56i0a01si5...-user-env

binicecatssh

l9w6773m1msy...-openssh-4.6p1bin

sshrpdqxnilb0cg...-icecat-3.5.4

binicecat

aqn3wygq9jzk...-openssh-5.2p1bin

sshi3d9vh6d8ip1...-user-env

binsshicecat

nix-env --upgrade openssh

Page 67: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

user environments

$PATH

/nix/.../profiles

current

42

43

/nix/storepp56i0a01si5...-user-env

binicecatssh

l9w6773m1msy...-openssh-4.6p1bin

sshrpdqxnilb0cg...-icecat-3.5.4

binicecat

aqn3wygq9jzk...-openssh-5.2p1bin

sshi3d9vh6d8ip1...-user-env

binsshicecat

nix-env --upgrade openssh

Page 68: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

user environments

$PATH

/nix/.../profiles

current

42

43

/nix/storepp56i0a01si5...-user-env

binicecatssh

l9w6773m1msy...-openssh-4.6p1bin

sshrpdqxnilb0cg...-icecat-3.5.4

binicecat

aqn3wygq9jzk...-openssh-5.2p1bin

sshi3d9vh6d8ip1...-user-env

binsshicecat

nix-env --upgrade openssh

Page 69: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

user environments

$PATH

/nix/.../profiles

current

43

/nix/storepp56i0a01si5...-user-env

binicecatssh

l9w6773m1msy...-openssh-4.6p1bin

sshrpdqxnilb0cg...-icecat-3.5.4

binicecat

aqn3wygq9jzk...-openssh-5.2p1bin

sshi3d9vh6d8ip1...-user-env

binsshicecat

nix-env --remove-generations old

Page 70: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

user environments

$PATH

/nix/.../profiles

current

43

/nix/store

rpdqxnilb0cg...-icecat-3.5.4bin

icecataqn3wygq9jzk...-openssh-5.2p1

binssh

i3d9vh6d8ip1...-user-envbin

sshicecat

nix-collect-garbage

Page 71: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

store paths

$ nix-build -A guile

/nix/store/ h2g4sc09h4... -guile-2.0.6

$ nix-store -q --requisites ‘which guile‘

/nix/store/4jl83jgzaac...-glibc-2.16

/nix/store/iplay43cg58...-libunistring-0.9.3

/nix/store/47p47v92cj9...-libffi-3.0.9

/nix/store/drkwck2j965...-gmp-5.0.5

...

$ nix-copy-closure --to [email protected] ‘which guile‘

...

Page 72: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

store paths

$ nix-build -A guile

/nix/store/ h2g4sc09h4... -guile-2.0.6

$ nix-store -q --requisites ‘which guile‘

/nix/store/4jl83jgzaac...-glibc-2.16

/nix/store/iplay43cg58...-libunistring-0.9.3

/nix/store/47p47v92cj9...-libffi-3.0.9

/nix/store/drkwck2j965...-gmp-5.0.5

...

$ nix-copy-closure --to [email protected] ‘which guile‘

...

hash of all the dependencies

Page 73: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

store paths

$ nix-build -A guile

/nix/store/ h2g4sc09h4... -guile-2.0.6

$ nix-store -q --requisites ‘which guile‘

/nix/store/4jl83jgzaac...-glibc-2.16

/nix/store/iplay43cg58...-libunistring-0.9.3

/nix/store/47p47v92cj9...-libffi-3.0.9

/nix/store/drkwck2j965...-gmp-5.0.5

...

$ nix-copy-closure --to [email protected] ‘which guile‘

...

Page 74: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

store paths

$ nix-build -A guile

/nix/store/ h2g4sc09h4... -guile-2.0.6

$ nix-store -q --requisites ‘which guile‘

/nix/store/4jl83jgzaac...-glibc-2.16

/nix/store/iplay43cg58...-libunistring-0.9.3

/nix/store/47p47v92cj9...-libffi-3.0.9

/nix/store/drkwck2j965...-gmp-5.0.5

...

$ nix-copy-closure --to [email protected] ‘which guile‘

...

Page 75: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

complete dependency specification

hello-2.3.drv

default-builder.sh

bash-4.0-p17.drv

bison-2.3.drv

gnum4-1.4.13.drv

curl-7.19.4.drv

openssl-0.9.8k.drv

zlib-1.2.3.drvperl-5.10.0.drv

binutils-2.19.1.drv

texinfo-4.13a.drv gmp-4.3.1.drv

mpfr-2.4.1.drv

lzma-4.32.7.drvncurses-5.7.drv gnum4-1.4.13.drv

linux-headers-2.6.28.5.drv

perl-5.10.0.drv

gawk-3.1.6.drv

coreutils-7.2.drv

gnupatch-2.5.4.drv gnutar-1.22.drv

findutils-4.4.1.drv

replace-2.24.drv gnused-4.1.5.drv gnumake-3.81.drv

diffutils-2.8.1.drv

gnugrep-2.5.4.drv

patchelf-0.4.drv gzip-1.3.12.drv

acl-2.2.47.drv

attr-2.4.43.drv

gettext-0.17.drv

libtool-2.2.6a.drv

perl-5.10.0.drvlzma-4.32.7.drvpcre-7.8.drv

bootstrap-glibc.drv

hello-2.3.tar.bz2.drv

stdenv-linux.drv

mirrors-list.drv

gcc-wrapper-4.3.3.drv

bash40-006.drv bash40-002.drvbash-4.0.tar.gz.drv

stdenv-linux-boot.drv

bzip2-1.0.5.drv

bash40-009.drv

bootstrap-tools.drv

bash40-012.drv bash40-008.drvbash40-013.drv bash40-007.drvbash40-003.drvbash40-001.drvbash40-017.drv bash40-015.drv bash40-005.drvbash40-016.drv bash40-010.drv bash40-004.drv bash40-014.drvbash40-011.drv

mirrors-list.drv

stdenv-linux-boot.drv

bison-2.3.tar.bz2.drv

gcc-wrapper-4.3.3.drv

m4-1.4.13.tar.bz2.drv curl-7.19.4.tar.bz2.drvopenssl-0.9.8k.tar.gz.drvperl-5.10.0.tar.gz.drv zlib-1.2.3.tar.gz.drv

gcc-4.3.3.drv

glibc-2.9.drv

gcc-core-4.3.3.tar.bz2.drv

stdenv-linux-boot.drv

gcc-g++-4.3.3.tar.bz2.drvtexinfo-4.13a.tar.lzma.drvgmp-4.3.1.tar.bz2.drv lzma-4.32.7.tar.gz.drvncurses-5.7.tar.gz.drvglibc-2.9-20081208.tar.bz2.drv

stdenv-linux-boot.drv

bootstrap-gcc.drv

bootstrap-gcc.drv

linux-2.6.28.5.tar.bz2.drv gawk-3.1.6.tar.bz2.drvcoreutils-7.2.tar.gz.drvbzip2-1.0.5.tar.gz.drv patch-2.5.4.tar.gz.drvacl_2.2.47-1.tar.gz.drvattr_2.4.43-1.tar.gz.drv tar-1.22.tar.bz2.drvgettext-0.17.tar.gz.drv findutils-4.4.1.tar.gz.drvreplace-2.24-src-11.11.tar.gz.drvsed-4.1.5.tar.gz.drv libtool-2.2.6a.tar.lzma.drv make-3.81.tar.bz2.drvdiffutils-2.8.1.tar.gz.drvmpfr-2.4.1.tar.bz2.drv grep-2.5.4.tar.bz2.drvpcre-7.8.tar.bz2.drvbinutils-2.19.1.tar.bz2.drv patchelf-0.4.tar.bz2.drv gzip-1.3.12.tar.gz.drv

builder.sh

prehook.sh builder.sh setup.sh

bzip2

bootstrap-tools.cpio.bz2.drv unpack-bootstrap-tools.sh

mkdir curl.bz2 cpio sh

write-mirror-list.sh

connect-timeout.patch

no-sys-dirs.patch setup-hook.sh

builder.sh ld-wrapper.sh gcc-wrapper.shutils.sh setup-hook.sh add-flags

pass-cxxcpp.patch builder.sh no-sys-dirs.patch

locale-override.patch rpcgen-path.patchbuilder.sh nss-skip-unavail.patch

prehook.sh

builder.sh implausible.patch

findutils-path.patch change_echo_path.patch

malloc.patch gettext-fix.patch impure-dirs.patchlog.patch

new-dtags.patch

gnulib-futimens.patch

download.sh ln

run-time dependencies inferred by conservative scanning

build-time dependencies of GNU Hello

Page 76: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

complete dependency specification

hello-2.3.drv

default-builder.sh

bash-4.0-p17.drv

bison-2.3.drv

gnum4-1.4.13.drv

curl-7.19.4.drv

openssl-0.9.8k.drv

zlib-1.2.3.drvperl-5.10.0.drv

binutils-2.19.1.drv

texinfo-4.13a.drv gmp-4.3.1.drv

mpfr-2.4.1.drv

lzma-4.32.7.drvncurses-5.7.drv gnum4-1.4.13.drv

linux-headers-2.6.28.5.drv

perl-5.10.0.drv

gawk-3.1.6.drv

coreutils-7.2.drv

gnupatch-2.5.4.drv gnutar-1.22.drv

findutils-4.4.1.drv

replace-2.24.drv gnused-4.1.5.drv gnumake-3.81.drv

diffutils-2.8.1.drv

gnugrep-2.5.4.drv

patchelf-0.4.drv gzip-1.3.12.drv

acl-2.2.47.drv

attr-2.4.43.drv

gettext-0.17.drv

libtool-2.2.6a.drv

perl-5.10.0.drvlzma-4.32.7.drvpcre-7.8.drv

bootstrap-glibc.drv

hello-2.3.tar.bz2.drv

stdenv-linux.drv

mirrors-list.drv

gcc-wrapper-4.3.3.drv

bash40-006.drv bash40-002.drvbash-4.0.tar.gz.drv

stdenv-linux-boot.drv

bzip2-1.0.5.drv

bash40-009.drv

bootstrap-tools.drv

bash40-012.drv bash40-008.drvbash40-013.drv bash40-007.drvbash40-003.drvbash40-001.drvbash40-017.drv bash40-015.drv bash40-005.drvbash40-016.drv bash40-010.drv bash40-004.drv bash40-014.drvbash40-011.drv

mirrors-list.drv

stdenv-linux-boot.drv

bison-2.3.tar.bz2.drv

gcc-wrapper-4.3.3.drv

m4-1.4.13.tar.bz2.drv curl-7.19.4.tar.bz2.drvopenssl-0.9.8k.tar.gz.drvperl-5.10.0.tar.gz.drv zlib-1.2.3.tar.gz.drv

gcc-4.3.3.drv

glibc-2.9.drv

gcc-core-4.3.3.tar.bz2.drv

stdenv-linux-boot.drv

gcc-g++-4.3.3.tar.bz2.drvtexinfo-4.13a.tar.lzma.drvgmp-4.3.1.tar.bz2.drv lzma-4.32.7.tar.gz.drvncurses-5.7.tar.gz.drvglibc-2.9-20081208.tar.bz2.drv

stdenv-linux-boot.drv

bootstrap-gcc.drv

bootstrap-gcc.drv

linux-2.6.28.5.tar.bz2.drv gawk-3.1.6.tar.bz2.drvcoreutils-7.2.tar.gz.drvbzip2-1.0.5.tar.gz.drv patch-2.5.4.tar.gz.drvacl_2.2.47-1.tar.gz.drvattr_2.4.43-1.tar.gz.drv tar-1.22.tar.bz2.drvgettext-0.17.tar.gz.drv findutils-4.4.1.tar.gz.drvreplace-2.24-src-11.11.tar.gz.drvsed-4.1.5.tar.gz.drv libtool-2.2.6a.tar.lzma.drv make-3.81.tar.bz2.drvdiffutils-2.8.1.tar.gz.drvmpfr-2.4.1.tar.bz2.drv grep-2.5.4.tar.bz2.drvpcre-7.8.tar.bz2.drvbinutils-2.19.1.tar.bz2.drv patchelf-0.4.tar.bz2.drv gzip-1.3.12.tar.gz.drv

builder.sh

prehook.sh builder.sh setup.sh

bzip2

bootstrap-tools.cpio.bz2.drv unpack-bootstrap-tools.sh

mkdir curl.bz2 cpio sh

write-mirror-list.sh

connect-timeout.patch

no-sys-dirs.patch setup-hook.sh

builder.sh ld-wrapper.sh gcc-wrapper.shutils.sh setup-hook.sh add-flags

pass-cxxcpp.patch builder.sh no-sys-dirs.patch

locale-override.patch rpcgen-path.patchbuilder.sh nss-skip-unavail.patch

prehook.sh

builder.sh implausible.patch

findutils-path.patch change_echo_path.patch

malloc.patch gettext-fix.patch impure-dirs.patchlog.patch

new-dtags.patch

gnulib-futimens.patch

download.sh ln

... down to the compiler’s compiler!

run-time dependenciesinferred by conservative scanning

build-time dependencies of GNU Hello

Page 77: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

complete dependency specification

hello-2.3

glibc-2.11

linux-headers-2.6.28.5

run-time dependencies inferred by conservative scanning

run-time dependencies of GNU Hello

Page 78: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

packaging using the Nix language

{ fetchurl, stdenv } :

stdenv . mkDerivation {

name = "hello-2.3";

src = fetchurl {

url = mirror://gnu/hello/hello-2.3.tar.bz2;

sha256 = "0c7vijq8y68...";

};

buildInputs = [ gettext ];

preCheck = "echo ’Test suite coming up!’";

meta = {

description = "Produces a friendly greeting";

homepage = http://www.gnu.org/software/hello/;

license = "GPLv3+";

};

}

function definition

formal parameters

function call

Page 79: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

packaging using the Nix language

{ fetchurl, stdenv , gettext } :

stdenv . mkDerivation {

name = "hello-2.3";

src = fetchurl {

url = mirror://gnu/hello/hello-2.3.tar.bz2;

sha256 = "0c7vijq8y68...";

};

buildInputs = [ gettext ];

preCheck = "echo ’Test suite coming up!’";

meta = {

description = "Produces a friendly greeting";

homepage = http://www.gnu.org/software/hello/;

license = "GPLv3+";

};

}

dependency

gcc, make, etc.

Page 80: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

packaging using the Nix language

{ fetchurl, stdenv , gettext } :

stdenv . mkDerivation {

name = "hello-2.3";

src = fetchurl {

url = mirror://gnu/hello/hello-2.3.tar.bz2;

sha256 = "0c7vijq8y68...";

};

buildInputs = [ gettext ];

preCheck = "echo ’Test suite coming up!’";

meta = {

description = "Produces a friendly greeting";

homepage = http://www.gnu.org/software/hello/;

license = "GPLv3+";

};

}

Bash snippet

Page 81: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

package composition with the Nix languageall-packages.nix

gettext = import ../development/libraries/gettext {

inherit fetchurl stdenv libiconv;

};

...

hello = import ../applications/misc/hello {

inherit fetchurl stdenv ;

};

actual parameters function call

Page 82: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

The “Correspo

nding Source” f

or

a work in object

code formmeans

all thesource

code needed

to

generate, insta

ll, and (for an ex

-

ecutable work)

run theobject c

ode

and tomodify th

e work,includin

g

scripts to contro

l those activities

.

Page 83: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

The “Correspo

nding Source” f

or

a work in object

code formmeans

all thesource

code needed

to

generate, insta

ll, and (for an ex

-

ecutable work)

run theobject c

ode

and tomodify th

e work,includin

g

scripts to contro

l those activities

.

Nix makes sure users get theCorresponding Source

Page 84: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

bells, whistles, and moreper-user package installationtransactional upgrades & rollbacksystem description & instantiation

the mechanicsbuild environmentsbuilding packagesputting it another way

from Nix to Guixrationaleusing ita GNU distro?

Page 85: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

Nix implements a functional software deployment model.

I immutable software installationsI builds/installs have no side effectsI build & deployment ≡ calling the build functionI Nix store ≡ cache of function call resultsI garbage collection...

Page 86: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

Nix implements a functional software deployment model.

I immutable software installations

I builds/installs have no side effectsI build & deployment ≡ calling the build functionI Nix store ≡ cache of function call resultsI garbage collection...

Page 87: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

Nix implements a functional software deployment model.

I immutable software installationsI builds/installs have no side effects

I build & deployment ≡ calling the build functionI Nix store ≡ cache of function call resultsI garbage collection...

Page 88: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

Nix implements a functional software deployment model.

I immutable software installationsI builds/installs have no side effectsI build & deployment ≡ calling the build functionI Nix store ≡ cache of function call results

I garbage collection...

Page 89: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

Nix implements a functional software deployment model.

I immutable software installationsI builds/installs have no side effectsI build & deployment ≡ calling the build functionI Nix store ≡ cache of function call resultsI garbage collection...

Page 90: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

bells, whistles, and moreper-user package installationtransactional upgrades & rollbacksystem description & instantiation

the mechanicsbuild environmentsbuilding packagesputting it another way

from Nix to Guixrationaleusing ita GNU distro?

Page 91: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

bells, whistles, and moreper-user package installationtransactional upgrades & rollbacksystem description & instantiation

the mechanicsbuild environmentsbuilding packagesputting it another way

from Nix to Guixrationaleusing ita GNU distro?

Page 92: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

so what’s the point of Guix?

keeping Nix’s build &deployment model

using Scheme as the packaginglanguageadding GNU hackers to the mix

Page 93: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

so what’s the point of Guix?

keeping Nix’s build &deployment model

using Scheme as the packaginglanguage

adding GNU hackers to the mix

Page 94: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

so what’s the point of Guix?

keeping Nix’s build &deployment model

using Scheme as the packaginglanguageadding GNU hackers to the mix

Page 95: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

why Guile Scheme instead of the Nix language?

I because it rocks!

I because it’s GNU!I it has a compiler, Unicode, gettext, libraries, etc.I it supports embedded DSLs via macrosI can be used both for composition and build scripts

Page 96: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

why Guile Scheme instead of the Nix language?

I because it rocks!I because it’s GNU!

I it has a compiler, Unicode, gettext, libraries, etc.I it supports embedded DSLs via macrosI can be used both for composition and build scripts

Page 97: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

why Guile Scheme instead of the Nix language?

I because it rocks!I because it’s GNU!I it has a compiler, Unicode, gettext, libraries, etc.

I it supports embedded DSLs via macrosI can be used both for composition and build scripts

Page 98: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

why Guile Scheme instead of the Nix language?

I because it rocks!I because it’s GNU!I it has a compiler, Unicode, gettext, libraries, etc.I it supports embedded DSLs via macros

I can be used both for composition and build scripts

Page 99: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

why Guile Scheme instead of the Nix language?

I because it rocks!I because it’s GNU!I it has a compiler, Unicode, gettext, libraries, etc.I it supports embedded DSLs via macrosI can be used both for composition and build scripts

Page 100: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

bells, whistles, and moreper-user package installationtransactional upgrades & rollbacksystem description & instantiation

the mechanicsbuild environmentsbuilding packagesputting it another way

from Nix to Guixrationaleusing ita GNU distro?

Page 101: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

Guix’s declarative packaging layer

(define-public hello

(package

(name "hello")

(version "2.8")

(source (origin

(method http-fetch)

(uri (string-append

"http://ftp.gnu.org/.../hello-" version

".tar.gz"))

(sha256 (base32 "0wqd...dz6"))))(build-system gnu-build-system )

(arguments ’(#:configure-flags ’("--disable-silent-rules")))

(inputs ‘(("gawk" , gawk )))

(description "GNU Hello")

(long-description "GNUten Tag, Dusseldorf!")

(home-page "http://www.gnu.org/software/hello/")

(license "GPLv3+")))

Page 102: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

Guix’s declarative packaging layer

(define-public hello

(package

(name "hello")

(version "2.8")

(source (origin

(method http-fetch)

(uri (string-append

"http://ftp.gnu.org/.../hello-" version

".tar.gz"))

(sha256 (base32 "0wqd...dz6"))))(build-system gnu-build-system )

(arguments ’(#:configure-flags ’("--disable-silent-rules")))

(inputs ‘(("gawk" , gawk )))

(description "GNU Hello")

(long-description "GNUten Tag, Dusseldorf!")

(home-page "http://www.gnu.org/software/hello/")

(license "GPLv3+")))

dependencies

Page 103: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

Guix’s declarative packaging layer

(define-public hello

(package

(name "hello")

(version "2.8")

(source (origin

(method http-fetch)

(uri (string-append

"http://ftp.gnu.org/.../hello-" version

".tar.gz"))

(sha256 (base32 "0wqd...dz6"))))(build-system gnu-build-system )

(arguments ’(#:configure-flags ’("--disable-silent-rules")))

(inputs ‘(("gawk" , gawk )))

(description "GNU Hello")

(long-description "GNUten Tag, Dusseldorf!")

(home-page "http://www.gnu.org/software/hello/")

(license "GPLv3+")))

dependencies

reference to a variable

Page 104: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

Guix’s declarative packaging layer

(define-public hello

(package

(name "hello")

(version "2.8")

(source (origin

(method http-fetch)

(uri (string-append

"http://ftp.gnu.org/.../hello-" version

".tar.gz"))

(sha256 (base32 "0wqd...dz6"))))(build-system gnu-build-system )

(arguments ’(#:configure-flags ’("--disable-silent-rules")))

(inputs ‘(("gawk" , my-other-awk )))

(description "GNU Hello")

(long-description "GNUten Tag, Dusseldorf!")

(home-page "http://www.gnu.org/software/hello/")

(license "GPLv3+")))

reference to a variable

Page 105: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

Guix’s declarative packaging layer

(define-public hello

(package

(name "hello")

(version "2.8")

(source (origin

(method http-fetch)

(uri (string-append

"http://ftp.gnu.org/.../hello-" version

".tar.gz"))

(sha256 (base32 "0wqd...dz6"))))(build-system gnu-build-system )

(arguments ’(#:configure-flags ’("--disable-silent-rules")))

(inputs ‘(("gawk" , gawk )))

(description "GNU Hello")

(long-description "GNUten Tag, Dusseldorf!")

(home-page "http://www.gnu.org/software/hello/")

(license "GPLv3+")))

./configure && make install...

Page 106: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

Guix’s declarative packaging layer

(define-public hello

(package

(name "hello")

(version "2.8")

(source (origin

(method http-fetch)

(uri (string-append

"http://ftp.gnu.org/.../hello-" version

".tar.gz"))

(sha256 (base32 "0wqd...dz6"))))(build-system gnu-build-system )

(arguments ’(#:configure-flags ’("--disable-silent-rules")))

(inputs ‘(("gawk" , gawk )))

(description "GNU Hello")

(long-description "GNUten Tag, Dusseldorf!")

(home-page "http://www.gnu.org/software/hello/")

(license "GPLv3+")))

./configure && make install...

depends on gcc, make, bash, etc.

Page 107: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

customized package declaration(define-public gawk

(package

(name "gawk")

(version "4.0.0")

(source (origin (method http-fetch)

(uri "http://ftp.gnu.org/...")

(sha256 (base32 "0sss..."))))

(build-system gnu-build-system)

(arguments

(case-lambda

(( system ) ; native builds

(if (string=? system "i686-cygwin")

’(#:tests? #f) ; work around test failure

’(#:parallel-tests? #f))) ; seq. test suite

((system cross-system) ; cross builds

(arguments cross-system)))) ; same as above

(inputs ‘(("libsigsegv" ,libsigsegv)))

(home-page "http://www.gnu.org/software/gawk/")

(description "GNU Awk")))

Page 108: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

customized package declaration(define-public gawk

(package

(name "gawk")

(version "4.0.0")

(source (origin (method http-fetch)

(uri "http://ftp.gnu.org/...")

(sha256 (base32 "0sss..."))))

(build-system gnu-build-system)

(arguments

(case-lambda

(( system ) ; native builds

(if (string=? system "i686-cygwin")

’(#:tests? #f) ; work around test failure

’(#:parallel-tests? #f))) ; seq. test suite

((system cross-system) ; cross builds

(arguments cross-system)))) ; same as above

(inputs ‘(("libsigsegv" ,libsigsegv)))

(home-page "http://www.gnu.org/software/gawk/")

(description "GNU Awk")))

build options based on target

Page 109: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

customized package declaration(define-public guile-1.8

(package ...(arguments

’(#:configure-flags ’("--disable-error-on-warning")

#:patches (list (assoc-ref %build-inputs "patch/snarf"))

#:phases

( alist-cons-before ’configure ’patch-search-path

(lambda* (#:key outputs #:allow-other-keys)

( substitute* "libguile/dynl.c"

(("lt_dlinit.*$" match)

(format #f

" ~a~% lt dladdsearchdir(\"~a/lib\");~%"

match (assoc-ref outputs "out")))))

%standard-phases )

))

(inputs ‘(

("patch/snarf" "distro/guile-1.8.patch")

("gawk" ,gawk)

("readline" ,readline)))

...

Page 110: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

customized package declaration(define-public guile-1.8

(package ...(arguments

’(#:configure-flags ’("--disable-error-on-warning")

#:patches (list (assoc-ref %build-inputs "patch/snarf"))

#:phases

( alist-cons-before ’configure ’patch-search-path

(lambda* (#:key outputs #:allow-other-keys)

( substitute* "libguile/dynl.c"

(("lt_dlinit.*$" match)

(format #f

" ~a~% lt dladdsearchdir(\"~a/lib\");~%"

match (assoc-ref outputs "out")))))

%standard-phases )

))

(inputs ‘(("patch/snarf" "distro/guile-1.8.patch")

("gawk" ,gawk)

("readline" ,readline)))

...

Page 111: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

customized package declaration(define-public guile-1.8

(package ...(arguments

’(#:configure-flags ’("--disable-error-on-warning")

#:patches (list (assoc-ref %build-inputs "patch/snarf"))

#:phases

( alist-cons-before ’configure ’patch-search-path

(lambda* (#:key outputs #:allow-other-keys)

( substitute* "libguile/dynl.c"

(("lt_dlinit.*$" match)

(format #f

" ~a~% lt dladdsearchdir(\"~a/lib\");~%"

match (assoc-ref outputs "out")))))

%standard-phases )))

(inputs ‘(("patch/snarf" "distro/guile-1.8.patch")

("gawk" ,gawk)

("readline" ,readline)))

...

configure, build, check, install

Page 112: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

customized package declaration(define-public guile-1.8

(package ...(arguments

’(#:configure-flags ’("--disable-error-on-warning")

#:patches (list (assoc-ref %build-inputs "patch/snarf"))

#:phases

( alist-cons-before ’configure ’patch-search-path

(lambda* (#:key outputs #:allow-other-keys)

( substitute* "libguile/dynl.c"

(("lt_dlinit.*$" match)

(format #f

" ~a~% lt dladdsearchdir(\"~a/lib\");~%"

match (assoc-ref outputs "out")))))

%standard-phases )))

(inputs ‘(("patch/snarf" "distro/guile-1.8.patch")

("gawk" ,gawk)

("readline" ,readline)))

...

configure, build, check, install

add a phase before configure

Page 113: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

customized package declaration(define-public guile-1.8

(package ...(arguments

’(#:configure-flags ’("--disable-error-on-warning")

#:patches (list (assoc-ref %build-inputs "patch/snarf"))

#:phases

( alist-cons-before ’configure ’patch-search-path

(lambda* (#:key outputs #:allow-other-keys)

( substitute* "libguile/dynl.c"

(("lt_dlinit.*$" match)

(format #f

" ~a~% lt dladdsearchdir(\"~a/lib\");~%"

match (assoc-ref outputs "out")))))

%standard-phases )))

(inputs ‘(("patch/snarf" "distro/guile-1.8.patch")

("gawk" ,gawk)

("readline" ,readline)))

...

patch things up a la sed

Page 114: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

building packages

(use-modules (guix packages) (guix store)

(distro base))

(define store

(open-connection) )

(package? hello)

=> #t

(define drv ( package-derivation store hello))

drv

=> "/nix/store/xyz...-hello-2.8.drv"

(build-derivations (list drv))

... Nix daemon builds/downloads package on our behalf...

=> "/nix/store/pqr...-hello-2.8"

connect to the Nix build daemon

Page 115: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

building packages

(use-modules (guix packages) (guix store)

(distro base))

(define store

(open-connection) )

(package? hello)

=> #t

(define drv ( package-derivation store hello))

drv

=> "/nix/store/xyz...-hello-2.8.drv"

(build-derivations (list drv))

... Nix daemon builds/downloads package on our behalf...

=> "/nix/store/pqr...-hello-2.8"

compute “derivation”—i.e., build promise

Page 116: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

building packages

(use-modules (guix packages) (guix store)

(distro base))

(define store

(open-connection) )

(package? hello)

=> #t

(define drv ( package-derivation store hello))

drv

=> "/nix/store/xyz...-hello-2.8.drv"

(build-derivations (list drv))

... Nix daemon builds/downloads package on our behalf...

=> "/nix/store/pqr...-hello-2.8"

Page 117: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

building packages

(use-modules (guix packages) (guix store)

(distro base))

(define store

(open-connection) )

(package? hello)

=> #t

(define drv ( package-derivation store hello))

drv

=> "/nix/store/xyz...-hello-2.8.drv"

(build-derivations (list drv))

... Nix daemon builds/downloads package on our behalf...

=> "/nix/store/pqr...-hello-2.8"

Page 118: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

building packages

(use-modules (guix packages) (guix store)

(distro base))

(define store

(open-connection) )

(package? hello)

=> #t

(define drv ( package-derivation store hello))

drv

=> "/nix/store/xyz...-hello-2.8.drv"

(build-derivations (list drv))

... Nix daemon builds/downloads package on our behalf...=> "/nix/store/pqr...-hello-2.8"

Page 119: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

building packages

$ guix-build hello

the following derivations will be built:

/nix/store/4gy79...-gawk-4.0.0.drv/nix/store/7m2r9...-hello-2.8.drv

.../nix/store/71aj1...-hello-2.8

Page 120: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

building packages

$ guix-build hello

the following derivations will be built:

/nix/store/4gy79...-gawk-4.0.0.drv/nix/store/7m2r9...-hello-2.8.drv

.../nix/store/71aj1...-hello-2.8

Page 121: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

under the hood

(let* ((store (open-connection) )

(builder ’( begin

(mkdir %output)

(call-with-output-file

(string-append %output "/test")

(lambda (p)

(display ’(hello guix) p)))))

(drv ( build-expression->derivation

store "foo" "x86 64-linux"

builder

’(("HOME" . "/nowhere")))))

( build-derivations store (list drv)))

Page 122: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

under the hood

(let* ((store (open-connection) )

(builder ’( begin

(mkdir %output)

(call-with-output-file

(string-append %output "/test")

(lambda (p)

(display ’(hello guix) p)))))

(drv ( build-expression->derivation

store "foo" "x86 64-linux"

builder

’(("HOME" . "/nowhere")))))

( build-derivations store (list drv)))

connect to the build daemon

Page 123: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

under the hood

(let* ((store (open-connection) )

(builder ’( begin

(mkdir %output)

(call-with-output-file

(string-append %output "/test")

(lambda (p)

(display ’(hello guix) p)))))

(drv ( build-expression->derivation

store "foo" "x86 64-linux"

builder

’(("HOME" . "/nowhere")))))

( build-derivations store (list drv)))

build script, to be eval’d in chroot

Page 124: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

under the hood

(let* ((store (open-connection) )

(builder ’( begin

(mkdir %output)

(call-with-output-file

(string-append %output "/test")

(lambda (p)

(display ’(hello guix) p)))))

(drv ( build-expression->derivation

store "foo" "x86 64-linux"

builder

’(("HOME" . "/nowhere")))))

( build-derivations store (list drv)))

compute derivation forthis builder, system,and env. vars

Page 125: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

under the hood

(let* ((store (open-connection) )

(builder ’( begin

(mkdir %output)

(call-with-output-file

(string-append %output "/test")

(lambda (p)

(display ’(hello guix) p)))))

(drv ( build-expression->derivation

store "foo" "x86 64-linux"

builder

’(("HOME" . "/nowhere")))))

( build-derivations store (list drv)))

build it!

Page 126: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

derivation primitive

(let* ((store (open-connection))

(builder

(add-text-to-store store "my-builder.sh"

"echo hello > \"$out\""

’()))

(drv

(derivation store "foo" "x86 64-linux"

"/bin/sh" ‘(,builder)

’(("HOME" . "/homeless")

("PATH" . "/nothing:/here"))

‘((,builder)))))

(build-derivations store (list drv)))

Page 127: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

status

I good API/language support for builds & compositionI expressive enough to build weird packages

I mini Guix-based distro!I ... bootstrapped with Nixpkgs

Page 128: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

status

I good API/language support for builds & compositionI expressive enough to build weird packagesI mini Guix-based distro!I ... bootstrapped with Nixpkgs

Page 129: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

tentative road map

I user environment builders + guix-env commandI Guix distro bootstrappedI Guix support in HydraI distro supports whole-system configuration

I distro has a nameI you can help!

Page 130: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

tentative road map

I user environment builders + guix-env commandI Guix distro bootstrappedI Guix support in HydraI distro supports whole-system configurationI distro has a name

I you can help!

Page 131: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

tentative road map

I user environment builders + guix-env commandI Guix distro bootstrappedI Guix support in HydraI distro supports whole-system configurationI distro has a nameI you can help!

Page 132: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

bells, whistles, and moreper-user package installationtransactional upgrades & rollbacksystem description & instantiation

the mechanicsbuild environmentsbuilding packagesputting it another way

from Nix to Guixrationaleusing ita GNU distro?

Page 133: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

why would GNU need a distro?

I direct connection between GNU users & developersI direct bug streamI direct release stream

I improved integration & cooperationI GNU hackers know how to package their softwareI if GNU foo x.(y + 1) breaks GNU bar, address that directly

I following free software distro guidelinesI branding!

Page 134: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

why would GNU need a distro?

I direct connection between GNU users & developersI direct bug streamI direct release stream

I improved integration & cooperationI GNU hackers know how to package their softwareI if GNU foo x.(y + 1) breaks GNU bar, address that directly

I following free software distro guidelinesI branding!

Page 135: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

why would GNU need a distro?

I direct connection between GNU users & developersI direct bug streamI direct release stream

I improved integration & cooperationI GNU hackers know how to package their softwareI if GNU foo x.(y + 1) breaks GNU bar, address that directly

I following free software distro guidelines

I branding!

Page 136: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

why would GNU need a distro?

I direct connection between GNU users & developersI direct bug streamI direct release stream

I improved integration & cooperationI GNU hackers know how to package their softwareI if GNU foo x.(y + 1) breaks GNU bar, address that directly

I following free software distro guidelinesI branding!

Page 137: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

why Guix-based?

I technically superior model & featuresI traceable source-to-binary mappingI extensible, i18n’d

I Guile is the official packaging language? :-)

Page 138: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

why Guix-based?

I technically superior model & featuresI traceable source-to-binary mappingI extensible, i18n’dI Guile is the official packaging language? :-)

Page 139: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

summary

parentheses + weird paths

right, but more importantly...

Page 140: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

summary

parentheses + weird pathsright, but more importantly...

Page 141: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

summary

I featuresI per-user, unprivileged installationI transactional upgrades; rollbackI full power of Guile to build & compose packages

I foundationsI purely functional package managementI traceable package source & dependenciesI completely bootstrapped

Page 142: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

[email protected] http://gitorious.org/guix/

Page 143: Guix, Functional Package Management for the Peoplepeople.bordeaux.inria.fr/lcourtes/doc/guix-ghm-2012.20120721.pdf · Guix, Functional Package Management for the People Ludovic Courtes`

Copyright c© 2010, 2012 Ludovic Courtes [email protected] of user environments is:Copyright c© 2009 Eelco Dolstra [email protected] of other images included in this document is held by their respective owners.

This work is licensed under the Creative Commons Attribution-Share Alike 3.0 License. To view a copy of thislicense, visit http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative Commons, 171Second Street, Suite 300, San Francisco, California, 94105, USA.

At your option, you may instead copy, distribute and/or modify this document under the terms of the GNU Free

Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no

Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is available at

http://www.gnu.org/licenses/gfdl.html.