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 -p <packages> to nix-shell and you have python available to use.

$ nix-shell -p 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 -p ghc
[nix-shell:]$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.6.5

$ nix-shell -p haskell.compiler.ghc822
[nix-shell:]$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.2.2

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