Python

Python meetup Oct 2015

and

Nix

#nixos

Rok Garbas, @garbas

Ever heard somebody complaining about python packaging?

What is Nix?

TO INSTALL

  % curl https://nixos.org/nix/install | sh


TO UNINSTALL

  % rm -Rf /nix
  % rm -Rf ~/.nix*

Why Nix?

Features or

Nix protects me against me.
Nix exposes the things I forget.
Nix let's me do things multiple times consistently, even on different machines.
Nix, the one language to rule them all.

Quotes by Rob Vermas - http://nixer.ghost.io/why/

Nix protects me, against me

UPDATE CHANNELS (look at this as apt-get update)

  % nix-channel --update


INSTALL "tig" application

  % nix-env --list-generations
  1002   2015-01-23 04:29:40   
  1003   2015-01-23 04:44:51

  % nix-env -i tig

  % nix-env --list-generations
  1002   2015-01-23 04:29:40   
  1003   2015-01-23 04:44:51   
  1004   2015-01-23 04:50:11

UNDO / ROLLBACK

  % nix-env --rollback   <or  nix-env --switch-generation 1003>

  % nix-env --list-generations
  1002   2015-01-23 04:29:40   
  1003   2015-01-23 04:44:51   

How can Nix do this?

HOOKS INTO BASH

  % echo $PATH
  /home/rok/.nix-profile/bin:/home/rok/.nix-profile/sbin:...

  % tree -L 2 `realpath ~/.nix-profile`
  /nix/store/xj8592ssnmcsn1kvbf87nm1acllwcqan-user-environment
  ├── bin
  │   ├── tig -> /nix/store/j3scw814k79mj3mm6x6yj9svvcq1plx4-tig-2.0.3/bin/tig
  │   ├── tree -> /nix/store/g75lq2kmfwx5sdqni6khv04kdklh3kq9-tree-1.7.0/bin/tree
  ├── etc
  │   ├── bash_completion.d -> /nix/store/j3scw814k79mj3mm6x6yj9svvcq1plx4-tig-2.0.3/etc/bash_completion.d
  │   └── tigrc -> /nix/store/j3scw814k79mj3mm6x6yj9svvcq1plx4-tig-2.0.3/etc/tigrc
  └── manifest.nix -> /nix/store/gjia0lic4v117fm3la3c4wkk6ig2iw3q-env-manifest.nix

/nix/store/j3scw814k79mj3mm6x6yj9svvcq1plx4-tig-2.0.3

/nix/store/

+

<hash>

+

<name>

+

<version>

How can we use Nix with Python?


  % nix-virtualenv path/to/folder -p pypy


JUST LIKE VIRTUALENV! ACTUALLY MORE...

  % nix-virtualenv path/to/folder -P postgresql -P lxml

nix-virtualenv

pypi2nix


  % pypi2nix requirements.txt
  Generating default.nix

  % nix-shell

Is this all that Nix can do?

Hydra

NixOS

NixOps

source / binary model

multi-user

reproducable

multi-version

portable

Thank you

and stay "pure"

NixOS conference

14. - 15. November

http://conf.nixos.org

final wors...

Rok Garbas, @garbas

Nix and Python

By Rok Garbas

Nix and Python

  • 2,189