2021-09-18 10:52:07 +00:00
{ fetchFromGitHub
, lib
2021-10-08 15:17:17 +00:00
, Security
2021-09-18 10:52:07 +00:00
, openssl
2023-01-20 10:41:00 +00:00
, git
2021-09-18 10:52:07 +00:00
, pkg-config
, protobuf
, rustPlatform
2021-09-26 12:46:18 +00:00
, stdenv
2021-09-18 10:52:07 +00:00
} :
2024-09-19 14:19:46 +00:00
# Updating this package will force an update for prisma. The
# version of prisma-engines and prisma must be the same for them to
2022-04-15 01:41:22 +00:00
# function correctly.
2021-10-14 00:43:12 +00:00
rustPlatform . buildRustPackage rec {
2021-09-18 10:52:07 +00:00
pname = " p r i s m a - e n g i n e s " ;
2024-09-19 14:19:46 +00:00
version = " 5 . 1 8 . 0 " ;
2021-09-18 10:52:07 +00:00
src = fetchFromGitHub {
owner = " p r i s m a " ;
repo = " p r i s m a - e n g i n e s " ;
rev = version ;
2024-09-19 14:19:46 +00:00
hash = " s h a 2 5 6 - u c A O z 0 0 d B g X 2 B b 6 3 u e a B b y u 1 X t V Q D + 9 6 E n c U y o 7 S T w A = " ;
2021-09-18 10:52:07 +00:00
} ;
# Use system openssl.
OPENSSL_NO_VENDOR = 1 ;
2023-03-27 19:17:25 +00:00
cargoLock = {
lockFile = ./Cargo.lock ;
outputHashes = {
" b a r r e l - 0 . 6 . 6 - a l p h a . 0 " = " s h a 2 5 6 - U S h 0 l Q 1 z + 3 S p g c 6 9 b R F y S U z h u Y 7 9 q p r L l E E x T m Y W F N 8 = " ;
2024-04-21 15:54:59 +00:00
" c u i d - 1 . 3 . 2 " = " s h a 2 5 6 - q B u 1 k / d J i A 6 r W B w k 4 n O O q o u I n e D 9 h 2 T T B T 8 t v s 0 T D f A = " ;
2023-03-27 19:17:25 +00:00
" g r a p h q l - p a r s e r - 0 . 3 . 0 " = " s h a 2 5 6 - 0 Z A s j 2 m W 6 f C L h w T E T u c j b u 4 r P N z f b N i H u 2 w V T B l T N e 4 = " ;
2024-04-21 15:54:59 +00:00
" m y s q l _ a s y n c - 0 . 3 1 . 3 " = " s h a 2 5 6 - 2 w O u p Q / L F V 9 p U i f q B L w T v A 0 t y S v + X W b x H i q s 7 i T z v v g = " ;
2023-10-19 13:55:26 +00:00
" p o s t g r e s - n a t i v e - t l s - 0 . 5 . 0 " = " s h a 2 5 6 - U Y P s x h C k X X W k 8 y P b q j N S 0 i l l w j S 5 m V m 3 Z / j F w p V w q f w = " ;
2023-03-27 19:17:25 +00:00
} ;
} ;
2021-09-18 10:52:07 +00:00
2023-01-20 10:41:00 +00:00
nativeBuildInputs = [ pkg-config git ] ;
2021-10-08 15:17:17 +00:00
buildInputs = [
openssl
protobuf
2024-09-26 11:04:55 +00:00
] ++ lib . optionals stdenv . hostPlatform . isDarwin [ Security ] ;
2021-09-18 10:52:07 +00:00
2024-09-19 14:19:46 +00:00
# FIXME: Workaround Rust 1.80 support by updating time to 0.3.36
# https://github.com/prisma/prisma-engines/issues/4989
postPatch = ''
ln - sfn $ { ./Cargo.lock } Cargo . lock
'' ;
2021-09-18 10:52:07 +00:00
preBuild = ''
export OPENSSL_DIR = $ { lib . getDev openssl }
2022-04-03 18:54:34 +00:00
export OPENSSL_LIB_DIR = $ { lib . getLib openssl } /lib
2021-09-18 10:52:07 +00:00
export PROTOC = $ { protobuf } /bin/protoc
export PROTOC_INCLUDE = " ${ protobuf } / i n c l u d e " ;
export SQLITE_MAX_VARIABLE_NUMBER = 250000
export SQLITE_MAX_EXPR_DEPTH = 10000
'' ;
2022-10-30 15:09:59 +00:00
cargoBuildFlags = [
" - p " " q u e r y - e n g i n e "
" - p " " q u e r y - e n g i n e - n o d e - a p i "
2023-04-29 16:46:19 +00:00
" - p " " s c h e m a - e n g i n e - c l i "
2022-10-30 15:09:59 +00:00
" - p " " p r i s m a - f m t "
] ;
2021-09-26 12:46:18 +00:00
2021-09-18 10:52:07 +00:00
postInstall = ''
2021-10-14 00:43:12 +00:00
mv $ out/lib/libquery_engine $ { stdenv . hostPlatform . extensions . sharedLibrary } $ out/lib/libquery_engine.node
2021-09-18 10:52:07 +00:00
'' ;
# Tests are long to compile
doCheck = false ;
meta = with lib ; {
2024-06-20 14:57:18 +00:00
description = " C o l l e c t i o n o f e n g i n e s t h a t p o w e r t h e c o r e s t a c k f o r P r i s m a " ;
2021-09-18 10:52:07 +00:00
homepage = " h t t p s : / / w w w . p r i s m a . i o / " ;
license = licenses . asl20 ;
2021-10-08 15:17:17 +00:00
platforms = platforms . unix ;
2024-07-31 10:19:44 +00:00
mainProgram = " p r i s m a " ;
maintainers = with maintainers ; [ pimeys tomhoule aqrln ] ;
2021-09-18 10:52:07 +00:00
} ;
}
2022-04-27 09:35:20 +00:00
### Troubleshooting
# Here's an example application using Prisma with Nix: https://github.com/pimeys/nix-prisma-example
# At example's `flake.nix` shellHook, notice the requirement of defining environment variables for prisma, it's values will show on `prisma --version`.
# Read the example's README: https://github.com/pimeys/nix-prisma-example/blob/main/README.md
2024-09-19 14:19:46 +00:00
# Prisma requires 2 packages, `prisma-engines` and `prisma`, to be at *exact* same versions.
2022-04-27 09:35:20 +00:00
# Certify at `package.json` that dependencies "@prisma/client" and "prisma" are equal, meaning no caret (`^`) in version.
# Configure NPM to use exact version: `npm config set save-exact=true`
# Delete `package-lock.json`, delete `node_modules` directory and run `npm install`.
# Run prisma client from `node_modules/.bin/prisma`.
# 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.
# Test prisma with `generate`, `db push`, etc. It should work. If not, open an issue.