lol
at 23.05-pre 82 lines 2.8 kB view raw
1{ fetchFromGitHub 2, lib 3, Security 4, openssl 5, pkg-config 6, protobuf 7, rustPlatform 8, stdenv 9}: 10 11# Updating this package will force an update for nodePackages.prisma. The 12# version of prisma-engines and nodePackages.prisma must be the same for them to 13# function correctly. 14rustPlatform.buildRustPackage rec { 15 pname = "prisma-engines"; 16 version = "4.6.0"; 17 18 src = fetchFromGitHub { 19 owner = "prisma"; 20 repo = "prisma-engines"; 21 rev = version; 22 sha256 = "sha256-tgU/QI6YwWeFPXh6VVPV3iLUGVwoxdG7YQwHBVobXH8="; 23 }; 24 25 # Use system openssl. 26 OPENSSL_NO_VENDOR = 1; 27 28 cargoSha256 = "sha256-LeE9biQDQ+aj0kKBrkIy3aGt5rgOu6O7w7xI/CjBUMA="; 29 30 nativeBuildInputs = [ pkg-config ]; 31 32 buildInputs = [ 33 openssl 34 protobuf 35 ] ++ lib.optionals stdenv.isDarwin [ Security ]; 36 37 preBuild = '' 38 export OPENSSL_DIR=${lib.getDev openssl} 39 export OPENSSL_LIB_DIR=${lib.getLib openssl}/lib 40 41 export PROTOC=${protobuf}/bin/protoc 42 export PROTOC_INCLUDE="${protobuf}/include"; 43 44 export SQLITE_MAX_VARIABLE_NUMBER=250000 45 export SQLITE_MAX_EXPR_DEPTH=10000 46 ''; 47 48 cargoBuildFlags = [ 49 "-p" "query-engine" 50 "-p" "query-engine-node-api" 51 "-p" "migration-engine-cli" 52 "-p" "introspection-core" 53 "-p" "prisma-fmt" 54 ]; 55 56 postInstall = '' 57 mv $out/lib/libquery_engine${stdenv.hostPlatform.extensions.sharedLibrary} $out/lib/libquery_engine.node 58 ''; 59 60 # Tests are long to compile 61 doCheck = false; 62 63 meta = with lib; { 64 description = "A collection of engines that power the core stack for Prisma"; 65 homepage = "https://www.prisma.io/"; 66 license = licenses.asl20; 67 platforms = platforms.unix; 68 maintainers = with maintainers; [ pamplemousse pimeys tomhoule ]; 69 }; 70} 71 72### Troubleshooting 73# Here's an example application using Prisma with Nix: https://github.com/pimeys/nix-prisma-example 74# At example's `flake.nix` shellHook, notice the requirement of defining environment variables for prisma, it's values will show on `prisma --version`. 75# Read the example's README: https://github.com/pimeys/nix-prisma-example/blob/main/README.md 76# Prisma requires 2 packages, `prisma-engines` and `nodePackages.prisma`, to be at *exact* same versions. 77# Certify at `package.json` that dependencies "@prisma/client" and "prisma" are equal, meaning no caret (`^`) in version. 78# Configure NPM to use exact version: `npm config set save-exact=true` 79# Delete `package-lock.json`, delete `node_modules` directory and run `npm install`. 80# Run prisma client from `node_modules/.bin/prisma`. 81# 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. 82# Test prisma with `generate`, `db push`, etc. It should work. If not, open an issue.