Guix(SD)

Table of Contents

1 Introduction

1.1 What's Guix?

  • "A functional package manager" ("wtf does that mean?" you say! we'll come back to it!)
  • Based on Nix
    • Nix pioneered most of the ideas of functional package management!
    • Most of Guix's design follows Nix
    • But not the same codebase (Only Guix's daemon comes from Nix)
      • and not the same language:
    • Guix uses a mishmash of languages, including its
    • Guix and
  • "The git of package management"????
  • Can build from source or use prebuilt binaries

1.2 What's GuixSD?

1.3 Ugh another package manager distro get out of here

1.4 How is Guix different from Nix?

1.5 Motivations

Has this ever happened to you?

1.5.1 My system failed mid-upgrade and now it's BORKED

Guix is atomic, aka "all or nothing"

This will never happen in Guix

1.5.2 Oh no I thought this upgrade was okay but now it isn't

You can safely roll back, and once you're comfortable, can drop old installs

1.5.3 One Package Manager Per Child Language

Yo dawg, I heard you like package managers

1.5.4 Special Snowflake installs

1.5.5 Network freedom is near-impossible current state of deployability

2 Prereq: Understanding "functional"

Or: "I'm not trying to trick you into learning monads, I promise!"

2.1 Understanding pure functions

2.1.1 A definition of pure functions

A pure function:

  1. Given the same arguments, must always produce the same output. (Can't rely on any data that might change!)
  2. Doesn't cause any observable "side effects". (Can't change anything that isn't its output!)

https://en.wikipedia.org/wiki/Pure_function

2.1.2 Your prescription: no side effects!

"Side effects" are not allowed:

  • It can't do any IO
    • It can't read or write from the filesystem
    • No network access
  • No changing global variables or relying on changing variables
  • No GUIs, no widgets
  • Definitely no "random" procedure
  • No beeps and boops
  • No mutating data that is accessed elsewhere

2.1.3 Functions vs procedures

# A function
def greet(name):
    return "Hello, " + name

# A procedure (NOT a function)
def greet_printer(name):
    print("Hello, " + name)

Printing to the screen is a "side effect"

2.1.4 This is as far from a pure function as you can get

def write_site_status_to_file(our_file, config):
    # mutation!
    urls = config.pop("urls")
    # iteration!
    for url in urls:
        # time-dependent variables!
        current_time = datetime.datetime.now().isoformat()
        # File IO!
        our_file.write("\n--Site status at %s--\n" % current_time)
        # Network IO!
        site_status = urlopen(url).read()
        # More file IO!
        our_file.write(site_status)

2.2 A purely functional program can't do anything

… Functional programs can't really do anything, since they can't have side effects. As Simon Peyton Jones, a well-known functional programmer, likes to say, "All you can do without side effects is push a button and watch the box get hot for a while." (Which isn't technically true, since even the box getting hot is a side effect.) – Land of Lisp, p. 300

2.3 So… what does it give you?

That sounds like a lot of "can't", but functional programming gives you some amazing properties:

  • GUARANTEED reproducibility. By definition!
  • Concurrent programming is easy. No mutation means no locking!
  • Most of the hardest bugs vanish (Ever heard of a heisenbug?)
  • Game engines which can "scrub" back and forth in time! Debug by setting that game to 20 seconds ago! (Elm and Sly)
  • Memoization means caching with no cache invalidation challenges
  • Optimized "immutable" datastructures are cooooooooool
  • Land of Lisp shows a cool "infinite functional lazy AI game tree" example (infinite tree of possible moves, only calculated once you need them!)
  • And much, much more

Unfortunately, this isn't a functional programming talk!

2.4 Functional programming strategy

Break your program into two parts:

  • The clean part: purely functional! Make as much of your program into this clean part as possible.
  • The dirty part: do side effects here. Make this as small and "quarantined" as possible.

3 Guix: a functional package manager

3.1 Let's try an install

3.2 Where'd that package go?

Enter the symlink forest!

3.3 So how's this

3.4 How deep does it go?

3.5 Multiple profiles!

3.6 What does writing a package look like?

3.7 Guix is a lot like Git

3.8 GUI alternatives?

3.8.1 You meant emacs right?

3.8.2 guix-web

3.8.3 .~~@YOUR GUI HERE!@~~.

4 GuixSD: a functional system distribution

4.1 Describe your system and go

4.2 Run it in a VM! On a container!

5 Cool demonstrations

6 Guile as a killer feature

This is where Guix diverges from Nix

6.1 What's Guile?

6.2 How much of Guix is written in Guile?

6.3 What can we do here?

6.4 How does this compare against Nix?

6.5 A word against "turing tarpits"

7 Wrapping up

7.1 Fun snippets

7.2

Date: 2015-09-30 Wed

Author: Christopher Allan Webber

Created: 2015-09-29 Tue 13:56

Emacs 24.4.1 (Org mode 8.2.10)

Validate