GNURadio ecosystem management with Nix

Tom Bereknyei

Intro

Ask questions!

Build problems - current state of affairs

Solutions

Challenge

What do we want?

Idea

Lets make package managers work like git!

Eelco Dolstra. The Purely Functional Software Deployment Model. PhD thesis, Faculty of Science, Utrecht, The Netherlands. January 2006. ISBN 90-393-4130-3.

https://nixos.org/~eelco/pubs/phd-thesis.pdf

Idea

Lets make package managers work like git!

PREFIX= sha256(sha256(deps(package)) + sha256(src(package)) + sha256(options(package))

$PREFIX/bin , $PREFIX/lib  $PREFIX/share
instead of:
/usr/bin, /usr/lib/, /usr/share

Nix

  • Package manager
  • Declarative lanuage to describe package builds
  • Isolated build environments
  • Over 10000 packages and counting
  • Mac OS X / GNU/Linux / BSD and Soon Windows Subsystem for Linux*
  • Source-based package manager (Like Gentoo)
  • But don't worry; also has a build cache

DEMO 0: Basic install of hello

Two styles

DEMO 1: Basic install of gnuradio

Important takeaways

The Nix Language in 1 minute

"hello"
1 + 3
./a/path
[ "i" 3 5 ]
{ x = "Hello"; y=42;}
a = 3
b = 4
thing = { x = a;, y = b;}
add_struct = {x, y}:  x + y
add_struct thing  # Results in 7

Graphical representation of our Derivation

Evaluated derivation

Evaluated derivation

If I update the source code

If I update the source code

...

If I update one of the dependencies ...

If I update one of the dependencies ...

DEMO2: Reliable builds

DEMO 2:

commit 993dadd2136ffca9a6f81d7e4d6acd5116da83a0 (HEAD)
Author: Franz Pletz <fpletz@fnordicwalking.de>
Date:   Fri May 13 02:31:33 2016 +0200

    gnuradio: 3.7.9.1 -> 3.7.9.2

How is a derivation built

How is a derivation built

Build Cache

nix-repl> "${gnuradio}"
"/nix/store/sqxmwvn33x39sjfr47spib74gi3cqffv-gnuradio-3.7.11"

Build Cache

DEMO 3:

GNURadio OOT

DEMO 4:

GNURadio OOT with integration

Same as demo3, but

DEMO 5: RFNoC

Continuous integration script

# .travis.yml
language: nix
script:
  - nix build . --store s3://company-bucket
after_success:
  - nix copy . --to s3://company-bucket

DEMO: Hydra

Solution? Docker

  • Docker is an ubiquitous distribution format.
  • Once it builds.. send it to the registry
  • Solves the "runs on my machine" problem
  • Does not solve the "builds on my machine" problem

Best of both worlds

  • Nix has support for building docker containers
  • Copies your package + all its dependencies in a docker image
  • Bare image, no FROM blah
  • Super small (not quite as small as Alpine)
  • You can easily integrate Nix in existing docker-compose or Kubernetes projects!
let
  pkgs = import ../nixpkgs.nix;
  some-service = import ./some-service.nix;
in
  pkgs.dockerTools.buildImage {
    name = "some-service";
    config = {
      Cmd = [ "${login-service}/bin/login-service" ];
      Expose = [ 8080 ];
    };
  }

Possibiliites

End state

Other thoughts:

Downsides

Recap

Thanks! Questions?

Bonus: Hey did gnuradio compile?