summary refs log tree commit diff
path: root/pkgs/development/tools/haskell/lambdabot/default.nix
blob: 01dfe339d141bb6c1d3d1875d42b2e5802e2ec3e (plain) (blame)
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
{ lib, haskell-lib, fetchpatch, makeWrapper, haskellPackages
, mueval
, withDjinn ? true
, aspell ? null
, packages ? (pkgs: [])
, modules ? "oldDefaultModules"
, configuration ? "[]"
}:

# FIXME: fix hoogle search

let allPkgs = pkgs: mueval.defaultPkgs pkgs ++ [ pkgs.lambdabot-trusted ] ++ packages pkgs;
    mueval' = mueval.override {
      inherit haskellPackages;
      packages = allPkgs;
    };
    bins = lib.makeSearchPath "bin" ([ mueval'
                                       (haskellPackages.ghcWithPackages allPkgs)
                                       haskellPackages.unlambda
                                       haskellPackages.brainfuck
                                     ]
                                     ++ lib.optional withDjinn haskellPackages.djinn
                                     ++ lib.optional (aspell != null) aspell
                                    );
    modulesStr = lib.replaceChars ["\n"] [" "] modules;
    configStr = lib.replaceChars ["\n"] [" "] configuration;

in haskell-lib.overrideCabal haskellPackages.lambdabot (self: {
  patches = (self.patches or []) ++ [ ./custom-config.patch ];
  postPatch = (self.postPatch or "") + ''
    substituteInPlace src/Main.hs \
      --replace '@config@' '${configStr}'
    substituteInPlace src/Modules.hs \
      --replace '@modules@' '${modulesStr}'
  '';

  buildTools = (self.buildTools or []) ++ [ makeWrapper ];

  postInstall = (self.postInstall or "") + ''
    wrapProgram $out/bin/lambdabot \
      --prefix PATH ":" '${bins}'
  '';
})