Install Dhall 1.32.0 on NixOS

I need the with feature which was introduced in Dhall 1.31.0. The Dhall version in Nixpkgs unstable is 1.30.0 though. I tried installing it for a Nix shell with the following where the sources point at the most recent Dhall

let
  sources = import ./nix/sources.nix;
  pkgs = import sources.nixpkgs {};
  dhall-json = builtins.fetchTarball {
    url = sources.dhall-haskell.url;
    sha256 = sources.dhall-haskell.sha256;
  };
  foo = import "${dhall-json}";
in
pkgs.mkShell {
  buildInputs = [
    foo.dhall-json
  ];
}

The problem is that this seems to rebuild the entire world.

Is there some easy but still Nix-y way of installing the most recent Dhall version without having to recompile everything?

You could try https://github.com/justinwoo/easy-dhall-nix.

I saw that but it looks like a bit of a last resort thing. Another thing I tried was just installing the haskellPackages.dhall-json_1_6_4 derivation but it fails because it has a dependency on dhall wasn’t satisfied. So I guess overriding that specific Haskell package would be an option. But based on what I’ve seen so far that’s also not super straight forward.

This is undoubtedly one of my most triumphant moments but I was able to cobble something together without actually understanding that much about Nix

let
  sources = import ./nix/sources.nix;
  pkgs = import sources.nixpkgs {};
  haskellPackages = pkgs.haskellPackages.override {
    overrides = self: super: {
      dhall = pkgs.haskell.lib.dontCheck (self.callHackageDirect { 
        pkg = "dhall"; 
        ver = "1.32.0"; 
        sha256 = "1qx7n2jyb9h1082434r90hfrjw5fab2j1yg0qzxh856fpksbh81n";
      } {}); 
    };
  };
in
  pkgs.mkShell {
    buildInputs = [
      haskellPackages.dhall-json_1_6_4
    ];
  }

To my surprise, this actually works. The dontCheck appears to be necessary since some of the checksum checks otherwise fail. I assume that’s simply due to me overriding a single package from the Dhall ecosystem.

2 Likes

@yuuki Yeah, that solution looks sane, but you can also just use

dhall = pkgs.haskell.lib.dontCheck super.dhall_1_32_0

if you are using nixpkgs unstable.

Regarding the tests: I believe the problem is, that dhall does use the network for loading resources, but the network is on purpose not accessable in nixos tests.
But it doesn‘t matter. Nice that you got it to work!