Hacking on XMonad

I’d like to be able to contribute to xmonad, so I wrote a shell.nix to construct a dev environment the project can be built in.

It took some trial and error, and I haven’t gotten cabal v2-repl working, due to the problems that ghc.environment files introduce. This means ghcid is not currently working either. However, I can build successfully, and can do so for any of the ghc versions mentioned in the project’s .travis.yml file:

nix-shell --pure --run 'cabal v2-build'
nix-shell --pure --argstr compiler ghc822 --run 'cabal v2-build'

The shell.nix looks like:

{ nixpkgs ? import <nixpkgs>, compiler ? "ghc861" }:

let
  pkgs = nixpkgs { };

  compilers = {
    ghc861 = (import (builtins.fetchTarball {
      url    = "https://github.com/NixOS/nixpkgs/archive/1f212565d2fcfe2c880e739d4462731a6ec19654.tar.gz";
      sha256 = "1fcrpfj98khlaxygy2vz2lm94xyir29rvv9pw2i7xdb7xymvrwar";
    }) { }).haskell.compiler.ghc861;

    ghc843 = (import (builtins.fetchTarball {
      url    = "https://github.com/NixOS/nixpkgs/archive/32dcb6051a9a2fa687283f4883d3552c3a46c081.tar.gz";
      sha256 = "1dvgk1cvai79yxn9lk9fnzqsqwi236y99ldxky6v999dx33nzygb";
    }) { }).haskell.compiler.ghc843;

    ghc822 = (import (builtins.fetchTarball {
      url    = "https://github.com/NixOS/nixpkgs/archive/8746c77a383f5c76153c7a181f3616d273acfa2a.tar.gz";
      sha256 = "1dvhx9hcij3j94yv102f7bhqy73k50sr3lazn28zzj8yg5lbahar";
    }) { }).haskell.compiler.ghc822;

    ghc802 = (import (builtins.fetchTarball {
      url    = "https://github.com/NixOS/nixpkgs/archive/32dcb6051a9a2fa687283f4883d3552c3a46c081.tar.gz";
      sha256 = "1dvgk1cvai79yxn9lk9fnzqsqwi236y99ldxky6v999dx33nzygb";
    }) { }).haskell.compiler.ghc802;
  };

in with pkgs; mkShell {
  buildInputs = [
    xorg.libX11
    xorg.libXinerama
    xorg.libXext
    xorg.libXrandr
    xorg.libXScrnSaver
    cabal-install
    compilers.${compiler}
  ];

  shellHook = ''
    rm -rf dist dist-newstyle .ghc.environment.*
  '';
}
1 Like