I’ve only been using NixOS for a couple of weeks, so I didn’t feel qualified putting this in Guides, but I felt I should post something to help out.
The Gleam programming language recently released Version 1.0.0, which got it some coverage from the usual suspects on YouTube. I was intrigued and wanted to try it out, only to discover that nixpkgs (for the current release anyway) is still using version 0.32.4! Undeterred, I learned how to use overlays to build Gleam 1.0.0 myself and include it in a Nix shell.
As I said, I’m pretty new to Nix in general, so if you have advice on a better way to write any of this, I’m all ears.
Here’s the overlay:
final: prev: {
gleam = prev.gleam.overrideAttrs (oldAttrs: rec {
src = prev.fetchFromGitHub {
owner = "gleam-lang";
repo = "gleam";
rev = "refs/tags/v1.0.0";
hash = "sha256-gPlRihwK+J7s1SeymfVdVo/KIV+eEqxlLVOgsDWW9yo=";
};
cargoDeps = oldAttrs.cargoDeps.overrideAttrs (prev.lib.const {
name = "gleam-vendor.tar.gz";
inherit src;
outputHash = "sha256-JE8XRbAn7Y4szud3m68K2GT9wz/4YBpwD5UhU7f1Wio=";
});
});
}
and here’s a basic shell.nix that uses the overlay, assuming they are in the same directory:
{ pkgs ? import <nixpkgs> { overlays = [(import ./gleam-overlay.nix)]; } }:
pkgs.mkShell {
buildInputs = with pkgs; [
erlang
gleam
];
}
Running gleam --version
inside the shell should show 1.0.0.