NIX Package Manager:

This section gives overview of NIX package manager, and some basic commands for operations.

Introduction:

NIX is a functional package manager for UNIX like systems. similar to apt-get(debian model), rpm(fedora model). But this one is linux flavor agnostic. I mean, you can use it in debian, redhat etc.

Its reliable and reproducible. It provides atomic upgrades and rollbacks, side-by-side installation of multiple versions of a package, multi-user package management and easy setup of build environments.

How to Install

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

Once you installed, by default the global nix channel(https://nixos.org/channels/nixpkgs-unstable\ is added. so that you can install available packages and start use it.

Simillar to apt-get install from the public apt repository.

How to uninstall nix

rm -rf /nix
rm -rf $HOME/{.nix-channels,.nix-defexpr,.nix-profile,.config/nixpkgs}
remove the . "$HOME/.nix-profile/etc/profile.d/nix.sh" line in your ~/.profile or ~/.bash_profile

Ref: https://github.com/NixOS/nix/issues/1402

To list the available packages for installation:

nix-env -qa

To install the package:

nix-env -i  <package name>

It installs the package in /nix/store and create the symbolic links of the binary in your path.

cloud@cibuild:~$ nix-env -i hello
replacing old ‘hello-2.10’
installing ‘hello-2.10’
cloud@cibuild:~$ which hello
/home/cloud/.nix-profile/bin/hello
cloud@cibuild:~$ ls -lrt /home/cloud/.nix-profile/bin/hello
lrwxrwxrwx 1 cloud cloud 64 Jan  1  1970 /home/cloud/.nix-profile/bin/hello -> /nix/store/d8rcprx833qxrgyazr2w8qhs6rq7wmj4-hello-2.10/bin/hello
cloud@cibuild:~$

To uninsall the package:

nix-env -e <package name>

Garbage collection (clean up)

nix-collect-garbage -d

NIX Channels:

To list the configured channels:

cloud@cibuild:~$ nix-channel --list
nixpkgs https://nixos.org/channels/nixpkgs-unstable
cloud@cibuild:~$

Update the packages information:

nix-channel --update

Add a new channel:

nix-channel --add <channel url>  [name]

Ex:

nix-channel --add http://84.39.63.212/jobset/opencontrail/trunk/channel/latest contrail

Here contrail represents the name of this channlel. if we omits the name, the last part of the URL will be taken as name.

Remove a channel

nix-channel --remove <name>

Ex:

cloud@cibuild:~$ nix-channel --remove contrail
uninstalling ‘contrail’
building path(s) ‘/nix/store/64lk7y97ihxas5zybj4nfiik6iw2w9fa-user-environment’
created 5 symlinks in user environment
cloud@cibuild:~$

To list all the packages available :

nix-env -qa

To find the particular package with regular exp

nix-env -qa firefox 
nix-env -qa firefox.*

To know the status of the package

nix-env -qas firefox.*

Example output:

--S  firefox-57.0
I - Installed (first char)
P  - Package available in your system(can be easily installed)
S  -  substitute .  binary pacakge is available in the public internet. which can be download and installed.

Reference link:

https://nixos.org/nix/manual/

results matching ""

    No results matching ""