Advertisement
Guest User

mylib.nix

a guest
Jun 14th, 2024
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. { lib, ... }:
  2. {
  3. relativeToRoot = lib.path.append ../.;
  4. relativeToConfD = lib.path.append ../conf.d;
  5. myMkPlugin =
  6. { plugin
  7. , requires ? [ ]
  8. , extraPackages ? [ ]
  9. , extraNodePackages ? [ ]
  10. , extraLuaPackages ? (_: [ ])
  11. , runtime ? { }
  12. , initPre ? null
  13. , initPost ? null
  14. , disabled ? false
  15. }:
  16. let
  17. pkg = plugin.overrideAttrs (_final: prev: {
  18. dependencies = (prev.dependencies or [ ]) ++ requires;
  19. propagatedBuildInputs = (prev.propagatedBuildInputs or [ ]) ++ extraPackages;
  20. });
  21. in
  22. lib.mkIf (! disabled) {
  23. inherit extraLuaPackages;
  24. extraPackages = extraPackages ++ extraNodePackages;
  25. plugins = [{ inherit runtime; type = "lua"; plugin = pkg; }];
  26. extraWrapperArgs = builtins.concatMap (p: [ "--prefix" "NODE_PATH" ":" "${p}/lib/node_modules" ]) extraNodePackages;
  27. extraLuaConfig = lib.mkMerge [
  28. (lib.mkIf ((builtins.typeOf initPre) == "string") (lib.mkBefore initPre))
  29. (lib.mkIf ((builtins.typeOf initPost) == "string") (lib.mkAfter initPost))
  30. ];
  31. };
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement