nix-shell is like virtualenv for everything

Posted on June 7, 2017

nix-shell can be use to make isolated environment with desired package installed.

It is better than installed everything globally which might lead to dependency conflicted. You should only installed what you need.

I’ve try nix-shell with ghc and python and it work.

The simple use case is just pass -i <packages> to nix-shell and you have python available to use.

$ nix-shell -i python
[nix-shell:]$ python --version
Python 2.7.13

$ nix-shell -p python3
[nix-shell:]$ python --version
Python 3.6.1

GHC example:

$ nix-shell -i python
[nix-shell:]$ python --version
Python 2.7.13

$ nix-shell -p python3
[nix-shell:]$ python --version
Python 3.6.1

nix-shell configuration is done via shell.nix or default.nix

Examples: Haskell, and Python


        
        title        nix-shell is like virtualenv for everything    
        url            /posts/nix-shell-virtualenv/      
        path          posts/nix-shell-virtualenv.tex     
        date          June  7, 2017     
        author   
        metadata 
        missing  
        teasers  
        teaser   
        snippet