lol
at 23.11-beta 90 lines 3.2 kB view raw
1{ fetchFromGitHub 2, lib 3, Security 4, openssl 5, git 6, pkg-config 7, protobuf 8, rustPlatform 9, stdenv 10}: 11 12# Updating this package will force an update for nodePackages.prisma. The 13# version of prisma-engines and nodePackages.prisma must be the same for them to 14# function correctly. 15rustPlatform.buildRustPackage rec { 16 pname = "prisma-engines"; 17 version = "5.4.1"; 18 19 src = fetchFromGitHub { 20 owner = "prisma"; 21 repo = "prisma-engines"; 22 rev = version; 23 sha256 = "sha256-KYPDocC6S6YhJeneyI++UmmpuAYDoX6okqgOtGetilw="; 24 }; 25 26 # Use system openssl. 27 OPENSSL_NO_VENDOR = 1; 28 29 cargoLock = { 30 lockFile = ./Cargo.lock; 31 outputHashes = { 32 "barrel-0.6.6-alpha.0" = "sha256-USh0lQ1z+3Spgc69bRFySUzhuY79qprLlEExTmYWFN8="; 33 "graphql-parser-0.3.0" = "sha256-0ZAsj2mW6fCLhwTETucjbu4rPNzfbNiHu2wVTBlTNe4="; 34 "mysql_async-0.31.3" = "sha256-QIO9s0Upc0/1W7ux1RNJNGKqzO4gB4gMV3NoakAbxkQ="; 35 "postgres-native-tls-0.5.0" = "sha256-UYPsxhCkXXWk8yPbqjNS0illwjS5mVm3Z/jFwpVwqfw="; 36 }; 37 }; 38 39 nativeBuildInputs = [ pkg-config git ]; 40 41 buildInputs = [ 42 openssl 43 protobuf 44 ] ++ lib.optionals stdenv.isDarwin [ Security ]; 45 46 preBuild = '' 47 export OPENSSL_DIR=${lib.getDev openssl} 48 export OPENSSL_LIB_DIR=${lib.getLib openssl}/lib 49 50 export PROTOC=${protobuf}/bin/protoc 51 export PROTOC_INCLUDE="${protobuf}/include"; 52 53 export SQLITE_MAX_VARIABLE_NUMBER=250000 54 export SQLITE_MAX_EXPR_DEPTH=10000 55 ''; 56 57 cargoBuildFlags = [ 58 "-p" "query-engine" 59 "-p" "query-engine-node-api" 60 "-p" "schema-engine-cli" 61 "-p" "prisma-fmt" 62 ]; 63 64 postInstall = '' 65 mv $out/lib/libquery_engine${stdenv.hostPlatform.extensions.sharedLibrary} $out/lib/libquery_engine.node 66 ''; 67 68 # Tests are long to compile 69 doCheck = false; 70 71 meta = with lib; { 72 description = "A collection of engines that power the core stack for Prisma"; 73 homepage = "https://www.prisma.io/"; 74 license = licenses.asl20; 75 platforms = platforms.unix; 76 maintainers = with maintainers; [ pimeys tomhoule ivan aqrln ]; 77 }; 78} 79 80### Troubleshooting 81# Here's an example application using Prisma with Nix: https://github.com/pimeys/nix-prisma-example 82# At example's `flake.nix` shellHook, notice the requirement of defining environment variables for prisma, it's values will show on `prisma --version`. 83# Read the example's README: https://github.com/pimeys/nix-prisma-example/blob/main/README.md 84# Prisma requires 2 packages, `prisma-engines` and `nodePackages.prisma`, to be at *exact* same versions. 85# Certify at `package.json` that dependencies "@prisma/client" and "prisma" are equal, meaning no caret (`^`) in version. 86# Configure NPM to use exact version: `npm config set save-exact=true` 87# Delete `package-lock.json`, delete `node_modules` directory and run `npm install`. 88# Run prisma client from `node_modules/.bin/prisma`. 89# Run `./node_modules/.bin/prisma --version` and check if both prisma packages versions are equal, current platform is `linux-nixos`, and other keys equal to the prisma environment variables you defined for prisma. 90# Test prisma with `generate`, `db push`, etc. It should work. If not, open an issue.