Loading
FretLink / @clementd && @haitlah

Dev Envs: Use The Nix, Luke

$ whoami

dev haskell, former CTO, I've worked with several langages, I used scala a lot (not anymore). Nowadays, haskell, rust, JS (a bit)

$ whoami

Makes shipment simpler (logistics platform for shipment planning and tracking). Started with nodeJS / MongoDB, new services are using Haskell / PostgreSQL

Let’s build an AI

Clementd

… in python

Keras / tensorflow

“just install anaconda”

“yeah you can choose miniconda as well”

“but you can still use pip”

“you know what? just use docker”

“actually, run this VM image on AWS, it’ll be easier”

cancel skynet

Python dev environments

Python is one of the worst offenders: global packages, lots of system deps

Python solutions

virtualenv. Works ok for python deps, but what about system deps?

meh :/

What if I just don’t want to bother with that? Running scripts was supposed to be simple

#magic

Hussein
small demo, just nix-shell -p

Nix

Clémentd
functional package manager
cross platform (GNU/Linux, MacOS)

Nix store

clementd
Content adressable store (data indexed by hash)
no global mutable root
just like git

Deterministic builds

hussein
data structures, not scripts

Deterministic builds

hussein
No side effects => good for cache / reuse

$PATH & patchelf magic

hussein
a special environment is created with all the needed resources in the path
if needed, the binaries themselves are patched

No deJS / No problem

clementd
we started with python because it was the easiest target. Node, no problem, thanks to npm, right. Right?

“just use nvm”

clementd
multiple node & npm versions in parallel

System deps / compiled deps are a PITA

clementd
nice and easy… until you have C bindings either you have to install libs through your system package manager, or the JS package downloads pre-built versions for some OSs

Let’s have a lookie

hussein
node js demo shell.nix et mkShell

node2nix

hussein
what we’ve done: use nix for node, npm & system deps, and npm for js deps but we can also use nix for js deps as well

nix all the things?

hussein
autogen nix files for whole dep tree (node, haskell, python as well?) much more work, out of scope for this project but can provide interesting things, especially for CI in polyglot orgs

clementd

Rust is nice

clementd
rustup works well, cargo is nice to use

… system deps aren’t

clementd
C dependencies

oxydize

clementd
rust depo
+ direnv integration

Why not docker?

clementd

Docker cache is… well…

clementd
docker cache is not really good
takes disk space, hard to reuse

Dockerfiles are… well…

clementd
dockerfile builds are not deterministic
dockerfiles are linear

step 1: docker-compose up

step 2