Guest User

Untitled

a guest
Jun 17th, 2025
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. {
  2. lib,
  3. stdenv,
  4. bun,
  5. nodejs,
  6. vips,
  7. makeWrapper,
  8. fetchBunDeps,
  9. bunConfigHook,
  10. bunInstallHook,
  11. bunBuildHook,
  12. ...
  13. }: let
  14. packageJson = builtins.fromJSON (builtins.readFile ../package.json);
  15. in
  16. stdenv.mkDerivation (finalAttrs: {
  17. pname = packageJson.name;
  18. version = packageJson.version;
  19.  
  20. src = ../.;
  21.  
  22. bunOfflineCache = fetchBunDeps {
  23. bunLock = finalAttrs.src + "/bun.lock";
  24. hash = "sha256-8R+LzgqAiqRGCMDBw2R7QO6hbdNrtIwzSjR3A8xhfVw=";
  25. };
  26.  
  27. bunBuildScript = "packages/api/build.ts";
  28.  
  29. nativeBuildInputs = [
  30. bun
  31. nodejs
  32. makeWrapper
  33. bunConfigHook
  34. bunInstallHook
  35. bunBuildHook
  36. ];
  37.  
  38. entrypointPath = "packages/api/index.js";
  39.  
  40. installPhase = let
  41. libPath = lib.makeLibraryPath [
  42. vips
  43. stdenv.cc.cc.lib
  44. ];
  45.  
  46. binPath = lib.makeBinPath [
  47. bun
  48. ];
  49. in ''
  50. runHook preInstall
  51.  
  52. mkdir -p $out
  53. cp -r dist $out/${finalAttrs.pname}
  54.  
  55. makeWrapper ${lib.getExe bun} $out/bin/${finalAttrs.pname} \
  56. --add-flags "run $out/${finalAttrs.pname}/${finalAttrs.entrypointPath}" \
  57. --set NODE_PATH $out/${finalAttrs.pname}/node_modules \
  58. --set MSGPACKR_NATIVE_ACCELERATION_DISABLED true \
  59. --prefix PATH : ${binPath} \
  60. --prefix LD_LIBRARY_PATH : ${libPath}
  61.  
  62.  
  63. runHook postInstall
  64. '';
  65.  
  66. meta = with lib; {
  67. description = packageJson.description;
  68. homepage = packageJson.homepage;
  69. license = licenses.agpl3Only;
  70. maintainers = [
  71. {
  72. name = "CPlusPatch";
  73. email = "[email protected]";
  74. github = "CPlusPatch";
  75. githubId = 42910258;
  76. matrix = "@jesse:cpluspatch.dev";
  77. }
  78. ];
  79. platforms = ["x86_64-linux" "aarch64-linux"];
  80. mainProgram = finalAttrs.pname;
  81. };
  82. })
Advertisement
Add Comment
Please, Sign In to add comment