Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nix: install derivation directly from master branch

Tags:

nix

nixos

I was wondering, why some packages appear in older versions than in the github repo when querying them via nix-env -qa .. . I learned that this is due to the fact that the master branch has not been merged to the unstable-channel.

How would I manually install a derivation from the master branch, in order to get the latest version?

like image 636
Anton Harald Avatar asked Jun 29 '16 07:06

Anton Harald


People also ask

What is nix derivation?

Derivations are the building blocks of a Nix system, from a file system view point. The Nix language is used to describe such derivations.

What is Nixpkg?

The Nix Packages collection (Nixpkgs) is a set of thousands of packages for the Nix package manager, released under a permissive MIT/X11 license. Packages are available for several platforms, and can be used with the Nix package manager on most GNU/Linux distributions as well as NixOS.

What is nix Darwin?

What nix-darwin adds is configuration and service management using the same mechanism as NixOS and it's mostly intended for users that use or know NixOS and want to have some of the same features on a mac.


2 Answers

Going for the master branch can be a little risky as the binary substitutes might not be available and you can end building lot of packages.
That said, you can specify which nixpkgs will be used by nix-env with the -f flag.

So let's say you want to build hello from master, you can use the following:

$ nix-env -f https://github.com/NixOS/nixpkgs/archive/master.tar.gz -iA hello

It is also possible to try git branches packages in a nix shell by using -I nixpkgs=/path/to/nix/pkgs:

$ nix-shell -p hello -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/master.tar.gz
like image 105
Eric Avatar answered Sep 27 '22 19:09

Eric


The most flexible way is:

git clone https://github.com/nixos/nixpkgs
cd nixpkgs
nix-build -A hello
nix-env -i $(readlink result)
like image 22
David Grayson Avatar answered Sep 27 '22 19:09

David Grayson