running the nix package manager in a prefix as the home directory

21 jan 2011

motivation

this posting is about how to setup a nix prefix installation on gentoo linux. if you do not have permission to install software on your server you can install a package manager in your home directory.

prefix distros:

  • [1] gentoo prefix (using portage)
  • [2] nix prefix (using nixpkgs)
  • source deployment (done manually)

gentoo prefix

  • pros:

    • contains many packages
    • great documentation
    • works in prefix on: linux|mac|cygwin/interix
    • security related tools available
    • Xorg stuff as qt programs will work
  • cons:

    • time consuming installation
    • complicated
    • linux prefix setup uses the sun solaris guide, which is …. strange at first

nix prefix

  • pros:

    • binary deployment (when not altering: –with-store-dir OR –localstatedir) this is only possible if root assists installation
    • assisted binary deployment (when using self-made channel & a build robot as hydra) i have not tested this but it should be possible
    • it is very easy to experiment with several different versions of a single program
    • Xorg stuff as qt programs will work
  • cons:

    • because you need to change the /store path, it is mainly source deployment at first
    • no security tools
    • compared to other linux distros a very small subset of packages available (as in ebuilds)

nix prefix - setup

download the software from [2], then follow this guide:

tar xf nix-0.16.tar
cd nix-0.16
./bootstrap
./configure --prefix=~/nix **--localstatedir**=~nix/state **--with-store-di**r=~/nix/store
make
make install

NOTE: –localstatedir is not visible when doing ./configure –help!

nix prefix - how to use

next you have to add it to your PATH, do:

bash

export PATH=~/.nix-profile/bin:$PATH

NOTE: you have to do this every time you want to use your prefixed nix.

this will alter your path to use program you install using ‘nix-env’ as:

nix-env -i wget

this should download about 10-40 software components as gcc, binutils, libraries and finally wget. afterwards do:

which wget

which should report: ~/.nix-profile/bin/wget

article source