Honza Pokorný

A personal blog


Bootstrapping a Hare development environment with Nix

Hare is a new systems programming language. The stable nix channel already provides packages for it but those become outdated pretty quickly with a work-in-progress language. Bootstrapping Hare is actually simple, and fast, and so it’s possible to do it often. Here are the steps:

  • Compile the latest QBE
  • Compile the latest harec
  • Compile the latest hare

Clone the Hare repo, cd into it, and create a shell.nix file with the following:

{ pkgs ? import <nixpkgs> {} }:

with pkgs;

let

myqbe = (stdenv.mkDerivation {
  pname = "qbe";
  version = "HEAD";

  src = fetchGit {
    url = "git://c9x.me/qbe.git";
  };

  makeFlags = [ "PREFIX=$(out)" ];
});

myharec = (stdenv.mkDerivation {
  pname = "harec";
  version = "HEAD";

  src = fetchGit {
    url = "https://git.sr.ht/~sircmpwn/harec";
  };

  buildInputs = [
    myqbe
  ];

});


in

mkShell {
  buildInputs = [
    myqbe
    myharec
  ];
}

Then you can open a new shell with:

$ nix-shell

And the compile Hare with

$ make

The Hare command is then available here:

$ .bin/hare
Usage: .bin/hare
	 <build | cache | deps | release | run | test | version> args...

Happy hacking!


This article was first published on March 3, 2023. As you can see, there are no comments. I invite you to email me with your comments, criticisms, and other suggestions. Even better, write your own article as a response. Blogging is awesome.