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
, 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-10-11 05:15:48 +00:00
version = " 5 . 2 1 . 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-10-11 05:15:48 +00:00
hash = " s h a 2 5 6 - X 5 a B r n y Z / t M y k J F i f y Y 1 L e R / n S h B l x m 9 H a z V E 0 L 7 R J k = " ;
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 = " ;
2024-10-11 05:15:48 +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 - 4 C f t i e I m s G 2 m B q p o J F f y q 0 R 2 y d 2 E y Q X 4 o d d A w y X M D Z c = " ;
" m o n g o d b - 3 . 0 . 0 " = " s h a 2 5 6 - 1 W Q g Y 0 z S Z h F j t 1 n r L Y T U B r p q B x p C C g K R S e G J L t k E 6 p w = " ;
2023-03-27 19:17:25 +00:00
} ;
} ;
2021-09-18 10:52:07 +00:00
2024-10-11 05:15:48 +00:00
nativeBuildInputs = [ pkg-config ] ;
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-10-11 05:15:48 +00:00
# FIXME: fix this upstream and remove this patch with the next version update.
2024-09-19 14:19:46 +00:00
postPatch = ''
2024-10-11 05:15:48 +00:00
file = libs/user-facing-errors/src/schema_engine.rs
echo " # ! [ a l l o w ( d e a d _ c o d e ) ] " | cat - $ file > $ file . new
mv $ file . new $ file
2024-09-19 14:19:46 +00:00
'' ;
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
2024-10-11 05:15:48 +00:00
export GIT_HASH = 0000000000000000000000000000000000000000
2021-09-18 10:52:07 +00:00
'' ;
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.