1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
{ depot, pkgs, lib, ... }:

let
  #   bins = depot.nix.getBins pkgs.sqlite ["sqlite3"];

  hps = pkgs.haskellPackages.override {
    overrides = hself: hsuper: {
      xmonad = pkgs.haskell.lib.appendPatch hsuper.xmonad ./xmonad-env.patch;
    };
  };

  my-xmonad = hps.mkDerivation {
    pname = "my-xmonad";
    version = "0.1.0";

    src = depot.users.Profpatsch.exactSource ./. [
      ./my-xmonad.cabal
      ./xmonad.hs
    ];

    libraryHaskellDepends = [
      hps.xmonad-contrib
    ];

    executableSystemDepends = [
      pkgs.makeWrapper
    ];
    postInstall = ''
      wrapProgram $out/bin/xmonad \
        --prefix PATH : ${ghcEnviron}/bin \
        --set XMONAD_CONFIG_DIR ${toString ./.}
    '';

    passthru.ghcEnvironment = ghcEnviron;

    isExecutable = true;
    isLibrary = false;
    license = lib.licenses.mit;
  };

  ghcEnviron = ((hps.ghcWithPackages.override {
    # remove everything but the ghc executables, because otherwis we have the vanilla xmonad binary in PATH inside the xmonad session argh
    postBuild = ''
      for f in $out/bin/*; do
        if [[ ! "$(basename $f)" =~ ghc ]]; then
          echo removing $f
          rm $f
        fi
      done
      ls $out/bin
    '';
  }) (pkgs: [ pkgs.xmonad pkgs.xmonad-contrib ])).overrideAttrs (_old: {
    name = "xmonad-ghc-environment";
  });

in
my-xmonad