How to use packages from different channels (in nix-shells)

Hi,

I was wondering how you would use packages from a specific channel (in this case: for Dhall)in a shell.nix file (or using nix-shell -p)? If it can’t be done directly, are there ways to make it work?

I’ve been looking around a bit, but I can’t find any documentation on how to do just this. Any help would be very appreciated!

Background

I started playing around with Dhall the other day, but found that the version in the channel nixos-unstable was too old to have certain features that I wanted: the available version is 1.24, but I need at least 1.27.

Luckily, I found that Dhall has it’s own channel that tracks the master branch.

Now the problem is that I can’t figure out how to use the channel.

The link provides instructions on how to install packages using nix-env, but that doesn’t work because of how I manage my env (using this gist, which forbids nix-env). I also don’t want to install it directly in my environment but use it in nix-shells.

However, I’ve not found any documentation on how to do that or if it is at all possible.


Any help would be very much appreciated. Cheers.

1 Like
let otherPkgs = import <other-channel> {} in

...

Just use otherPkgs where you would use pkgs otherwise.

Though personally I prefer to wrap those other channels into an overlay and just use a single channel.

1 Like

Ooh, this looks promising! I’ll give that a go!

About overlays, how would you organize that if you want everything self-contained within a repo? Have a separate folder where you specify them? I agree that that sounds more distributable and easier to deal with in general.

Thanks!

huh,

let
  dhall-latest = import (builtins.fetchTarball https://hydra.dhall-lang.org/jobset/dhall-haskell/master/channel/latest/nixexprs.tar.bz2) {};
  dhall = dhall-latest.linux-dhall;

because this is “latest” you can’t pinpoint it with hash - you’ll always get latest version (though Nix has caching of impure downloads). But builtins.fetchTarball has a variant with hash.

1 Like

So after quite a lot of research, I ended up writing a simple overlay for this, which was quite interesting as I’d never worked directly with overlays before.

Right now, I’m fetching a specific version of Dhall:

  dhall = builtins.fetchTarball {
    url =
      "https://github.com/dhall-lang/dhall-haskell/releases/download/1.30.0/dhall-1.30.0-x86_64-linux.tar.bz2";
    sha256 = "0c4q1ic19jm9c7acxqfizkzwzvcypnmkicv4c5da5fs4971rvmf8";
  };

I’d love to use the one that works directly off master, but I keep getting errors saying that

path '/nix/store/1h0y04kxmd470hkawskqn319hs4sfkib-dhall-1.30.0' does not exist and cannot be created

Would you happen to know anything about that error?

Anyway, thanks a lot for helping me out!

3 Likes

interesting, I get same. Maybe they use Hydra only as CI, and never publish binaries? I can’t find the binary cache URL.

1 Like