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

#1

I am attempting to get an environment up and running so I can develop against elm 0.19.0 which is on the unstable channel. I will also need some dependencies from the stable channel - is it possible to have both?

I see one way of using the unstable channel here. Is this good nix style ?

Thank you in advance,
Jono.

#2

I have not found need to import a particular git revision, but that is one alternative. I usually reference nixpkgs paths defined in NIX_PATH: import <unstable> {} or something.

Is there a reason that either of these would not work? Could you take a package straight out of a nixpkgs channel, packages having dependencies from different nixpkgs versions, or do you need a package from unstable with its dependencies changed to the stable versions, for example?

1 Like
#3

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.

1 Like
#4

You also might want to have a look at https://nixos.wiki/wiki/FAQ#How_can_I_install_a_package_from_unstable_while_remaining_on_the_stable_channel.3F

1 Like