about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/tools/haskell/lambdabot/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/tools/haskell/lambdabot/default.nix')
-rw-r--r--nixpkgs/pkgs/development/tools/haskell/lambdabot/default.nix41
1 files changed, 41 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/tools/haskell/lambdabot/default.nix b/nixpkgs/pkgs/development/tools/haskell/lambdabot/default.nix
new file mode 100644
index 000000000000..5e372b4f3874
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/haskell/lambdabot/default.nix
@@ -0,0 +1,41 @@
+{ lib, haskellLib, makeWrapper, haskellPackages
+, mueval
+, withDjinn ? true
+, aspell ? null
+, packages ? (pkgs: [])
+, modules ? "oldDefaultModules"
+, configuration ? "[]"
+}:
+
+let allPkgs = pkgs: mueval.defaultPkgs pkgs ++ [ pkgs.lambdabot-trusted ] ++ packages pkgs;
+    mueval' = mueval.override {
+      inherit haskellPackages;
+      packages = allPkgs;
+    };
+    bins = lib.makeBinPath ([ mueval'
+                              (haskellPackages.ghcWithHoogle 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 haskellLib.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}'
+  '';
+})