How do I build a nix-shell which depends on some unstable packages?

I would recommend fetchFromGitHub as it can download a tarball for the revision instead of pulling the whole repo or fetchTarball with the standard channel url, e.g. https://nixos.org/channels/nixos-unstable/nixexprs.tar.xz.

You can import additional channels as local variables e.g. with:

let
  unstable = import (fetchTarball https://nixos.org/channels/nixos-unstable/nixexprs.tar.xz) { };
in
{ nixpkgs ? import <nixpkgs> {} }:
with nixpkgs; mkShell {
  buildInputs = [ hello unstable.elmPackages.elm ];
}

This also shows how to get the ‘standard’ tarball. Alternativly you can add channels with nixos-channels or to NIX_PATH. I.e if you’ve added a channel called nixos-unstable you can write in the expr. above (as @atanasi has hinted at)

unstable = <nixos-unstable> {};

Do you need dependencies from stable, build against unstable, or the other way around? I’d have to look that up, but let me know so I can add that later.

7 Likes