lambdabot: rework custom modules and configuration
This commit is contained in:
		
							parent
							
								
									c904dfa87c
								
							
						
					
					
						commit
						57c33c1c54
					
				
							
								
								
									
										49
									
								
								pkgs/development/tools/haskell/lambdabot/custom-config.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								pkgs/development/tools/haskell/lambdabot/custom-config.patch
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,49 @@
 | 
			
		||||
diff --git a/src/Main.hs b/src/Main.hs
 | 
			
		||||
index 61da2f3..39e5c9b 100644
 | 
			
		||||
--- a/src/Main.hs
 | 
			
		||||
+++ b/src/Main.hs
 | 
			
		||||
@@ -73,11 +73,14 @@ main = do
 | 
			
		||||
     config' <- sequence config
 | 
			
		||||
     dir <- P.getDataDir
 | 
			
		||||
     exitWith <=< lambdabotMain modulesInfo $
 | 
			
		||||
-        [dataDir ==> dir, lbVersion ==> P.version] ++ config'
 | 
			
		||||
+        [dataDir ==> dir, lbVersion ==> P.version] ++ configInfo ++ config'
 | 
			
		||||
 
 | 
			
		||||
 -- special online target for ghci use
 | 
			
		||||
 online :: [String] -> IO ()
 | 
			
		||||
 online strs = do
 | 
			
		||||
     dir <- P.getDataDir
 | 
			
		||||
-    void $ lambdabotMain modulesInfo
 | 
			
		||||
-        [dataDir ==> dir, lbVersion ==> P.version, onStartupCmds ==> strs]
 | 
			
		||||
+    void $ lambdabotMain modulesInfo $
 | 
			
		||||
+        [dataDir ==> dir, lbVersion ==> P.version, onStartupCmds ==> strs] ++ configInfo
 | 
			
		||||
+
 | 
			
		||||
+configInfo :: [DSum Config Identity]
 | 
			
		||||
+configInfo = @config@
 | 
			
		||||
diff --git a/src/Modules.hs b/src/Modules.hs
 | 
			
		||||
index 036ea1f..eaafa50 100644
 | 
			
		||||
--- a/src/Modules.hs
 | 
			
		||||
+++ b/src/Modules.hs
 | 
			
		||||
@@ -14,10 +14,15 @@ import Lambdabot.Plugin.Reference
 | 
			
		||||
 import Lambdabot.Plugin.Social
 | 
			
		||||
 
 | 
			
		||||
 modulesInfo :: Modules
 | 
			
		||||
-modulesInfo = $(modules $ corePlugins
 | 
			
		||||
-    ++ haskellPlugins
 | 
			
		||||
-    ++ ["irc", "localtime", "topic"] -- ircPlugins
 | 
			
		||||
-    ++ ["dummy", "fresh", "todo"] -- miscPlugins
 | 
			
		||||
-    ++ ["bf", "dice", "elite", "filter", "quote", "slap", "unlambda", "vixen"] -- noveltyPlugins
 | 
			
		||||
-    ++ referencePlugins
 | 
			
		||||
-    ++ socialPlugins)
 | 
			
		||||
+modulesInfo =
 | 
			
		||||
+  $(modules $
 | 
			
		||||
+    let oldDefaultModules =
 | 
			
		||||
+          corePlugins
 | 
			
		||||
+          ++ haskellPlugins
 | 
			
		||||
+          ++ ["irc", "localtime", "topic"] -- ircPlugins
 | 
			
		||||
+          ++ ["dummy", "fresh", "todo"] -- miscPlugins
 | 
			
		||||
+          ++ ["bf", "dice", "elite", "filter", "quote", "slap", "unlambda", "vixen"] -- noveltyPlugins
 | 
			
		||||
+          ++ referencePlugins
 | 
			
		||||
+          ++ socialPlugins
 | 
			
		||||
+    in @modules@
 | 
			
		||||
+   )
 | 
			
		||||
@ -1,16 +1,9 @@
 | 
			
		||||
{ lib, makeWrapper, haskellngPackages
 | 
			
		||||
{ lib, haskell-lib, fetchpatch, makeWrapper, haskellPackages
 | 
			
		||||
, mueval
 | 
			
		||||
, withDjinn ? true
 | 
			
		||||
, aspell ? null
 | 
			
		||||
, packages ? (pkgs: [])
 | 
			
		||||
, modules ? ''
 | 
			
		||||
    haskellPlugins
 | 
			
		||||
    ++ ["irc", "localtime", "topic"]
 | 
			
		||||
    ++ ["dummy", "fresh", "todo"]
 | 
			
		||||
    ++ ["bf", "dice", "elite", "filter", "quote", "slap", "unlambda", "vixen"]
 | 
			
		||||
    ++ referencePlugins
 | 
			
		||||
    ++ socialPlugins
 | 
			
		||||
''
 | 
			
		||||
, modules ? "oldDefaultModules"
 | 
			
		||||
, configuration ? "[]"
 | 
			
		||||
}:
 | 
			
		||||
 | 
			
		||||
@ -18,34 +11,32 @@
 | 
			
		||||
 | 
			
		||||
let allPkgs = pkgs: mueval.defaultPkgs pkgs ++ [ pkgs.lambdabot-trusted ] ++ packages pkgs;
 | 
			
		||||
    mueval' = mueval.override {
 | 
			
		||||
      inherit haskellngPackages;
 | 
			
		||||
      inherit haskellPackages;
 | 
			
		||||
      packages = allPkgs;
 | 
			
		||||
    };
 | 
			
		||||
    bins = lib.makeSearchPath "bin" ([ mueval'
 | 
			
		||||
                                       (haskellngPackages.ghcWithPackages allPkgs)
 | 
			
		||||
                                       haskellngPackages.unlambda
 | 
			
		||||
                                       haskellngPackages.brainfuck
 | 
			
		||||
                                       (haskellPackages.ghcWithPackages allPkgs)
 | 
			
		||||
                                       haskellPackages.unlambda
 | 
			
		||||
                                       haskellPackages.brainfuck
 | 
			
		||||
                                     ]
 | 
			
		||||
                                     ++ lib.optional withDjinn haskellngPackages.djinn
 | 
			
		||||
                                     ++ lib.optional withDjinn haskellPackages.djinn
 | 
			
		||||
                                     ++ lib.optional (aspell != null) aspell
 | 
			
		||||
                                    );
 | 
			
		||||
    modulesStr = lib.replaceChars ["\n"] [" "] ("corePlugins ++ " + modules);
 | 
			
		||||
    modulesStr = lib.replaceChars ["\n"] [" "] modules;
 | 
			
		||||
    configStr = lib.replaceChars ["\n"] [" "] configuration;
 | 
			
		||||
 | 
			
		||||
in lib.overrideDerivation haskellngPackages.lambdabot (self: {
 | 
			
		||||
in haskell-lib.overrideCabal haskellPackages.lambdabot (self: {
 | 
			
		||||
  patches = (self.patches or []) ++ [ ./custom-config.patch ];
 | 
			
		||||
  postPatch = (self.postPatch or "") + ''
 | 
			
		||||
    sed -i 's/\(\$(modules \$ \).*/\1@modules@)/; /@modules@/q' src/Modules.hs
 | 
			
		||||
    # not via sed to avoid escaping issues
 | 
			
		||||
    substituteInPlace src/Modules.hs \
 | 
			
		||||
      --replace '@modules@' '${modulesStr}'
 | 
			
		||||
    sed -i 's/\[dataDir :=> dir\]/@config@ ++ \0/' src/Main.hs
 | 
			
		||||
    substituteInPlace src/Main.hs \
 | 
			
		||||
      --replace '@config@' '${configStr}'
 | 
			
		||||
    substituteInPlace src/Modules.hs \
 | 
			
		||||
      --replace '@modules@' '${modulesStr}'
 | 
			
		||||
  '';
 | 
			
		||||
 | 
			
		||||
  buildInputs = self.buildInputs ++ [ makeWrapper ];
 | 
			
		||||
  buildTools = (self.buildTools or []) ++ [ makeWrapper ];
 | 
			
		||||
 | 
			
		||||
  postInstall = (self.postInstall or "") + lib.optionalString (bins != "") ''
 | 
			
		||||
  postInstall = (self.postInstall or "") + ''
 | 
			
		||||
    wrapProgram $out/bin/lambdabot \
 | 
			
		||||
      --prefix PATH ":" '${bins}'
 | 
			
		||||
  '';
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,4 @@
 | 
			
		||||
{ stdenv, makeWrapper, haskellngPackages, packages ? (pkgs: [])
 | 
			
		||||
{ stdenv, makeWrapper, haskellPackages, packages ? (pkgs: [])
 | 
			
		||||
}:
 | 
			
		||||
 | 
			
		||||
let defaultPkgs = pkgs: [ pkgs.show
 | 
			
		||||
@ -6,14 +6,14 @@ let defaultPkgs = pkgs: [ pkgs.show
 | 
			
		||||
                          pkgs.QuickCheck
 | 
			
		||||
                          pkgs.mtl
 | 
			
		||||
                        ];
 | 
			
		||||
    env = haskellngPackages.ghcWithPackages
 | 
			
		||||
    env = haskellPackages.ghcWithPackages
 | 
			
		||||
           (pkgs: defaultPkgs pkgs ++ packages pkgs);
 | 
			
		||||
    libDir = "${env}/lib/ghc-${env.version}";
 | 
			
		||||
 | 
			
		||||
in stdenv.mkDerivation {
 | 
			
		||||
  name = "mueval-env";
 | 
			
		||||
 | 
			
		||||
  inherit (haskellngPackages) mueval;
 | 
			
		||||
  inherit (haskellPackages) mueval;
 | 
			
		||||
 | 
			
		||||
  nativeBuildInputs = [ makeWrapper ];
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -8064,7 +8064,9 @@ let
 | 
			
		||||
 | 
			
		||||
  readosm = callPackage ../development/libraries/readosm { };
 | 
			
		||||
 | 
			
		||||
  lambdabot = callPackage ../development/tools/haskell/lambdabot { };
 | 
			
		||||
  lambdabot = callPackage ../development/tools/haskell/lambdabot {
 | 
			
		||||
    haskell-lib = haskell.lib;
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  leksah = callPackage ../development/tools/haskell/leksah {
 | 
			
		||||
    inherit (haskellPackages) ghcWithPackages;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user