78 lines
2.3 KiB
Nix
78 lines
2.3 KiB
Nix
{ pkgs ? import <nixpkgs> {}
|
|
, unstable ? import <nixos-unstable> {}
|
|
}:
|
|
|
|
let
|
|
prisma-version = "5.13.0";
|
|
prisma-src = pkgs.fetchFromGitHub {
|
|
owner = "prisma";
|
|
repo = "prisma-engines";
|
|
rev = prisma-version;
|
|
hash = "sha256-8LC2RV3FRr1F0TZxQNxvvEoTyhKusgzB5omlxLAnHG0=";
|
|
};
|
|
new-prisma-engines = unstable.rustPlatform.buildRustPackage {
|
|
pname = "prisma-engines";
|
|
version = prisma-version;
|
|
|
|
src = builtins.storePath prisma-src;
|
|
|
|
# Use system openssl.
|
|
OPENSSL_NO_VENDOR = 1;
|
|
|
|
nativeBuildInputs = [ pkgs.pkg-config pkgs.git ];
|
|
|
|
buildInputs = [
|
|
pkgs.openssl
|
|
pkgs.protobuf
|
|
];
|
|
|
|
cargoLock = {
|
|
lockFile = "${prisma-src}/Cargo.lock";
|
|
outputHashes = {
|
|
"cuid-1.3.2" = "sha256-qBu1k/dJiA6rWBwk4nOOqouIneD9h2TTBT8tvs0TDfA=";
|
|
"barrel-0.6.6-alpha.0" = "sha256-USh0lQ1z+3Spgc69bRFySUzhuY79qprLlEExTmYWFN8=";
|
|
"graphql-parser-0.3.0" = "sha256-0ZAsj2mW6fCLhwTETucjbu4rPNzfbNiHu2wVTBlTNe4=";
|
|
"mysql_async-0.31.3" = "sha256-2wOupQ/LFV9pUifqBLwTvA0tySv+XWbxHiqs7iTzvvg=";
|
|
"postgres-native-tls-0.5.0" = "sha256-UYPsxhCkXXWk8yPbqjNS0illwjS5mVm3Z/jFwpVwqfw=";
|
|
};
|
|
};
|
|
|
|
preBuild = ''
|
|
export OPENSSL_DIR=${pkgs.lib.getDev pkgs.openssl}
|
|
export OPENSSL_LIB_DIR=${pkgs.lib.getLib pkgs.openssl}/lib
|
|
|
|
export PROTOC=${pkgs.protobuf}/bin/protoc
|
|
export PROTOC_INCLUDE="${pkgs.protobuf}/include";
|
|
|
|
export SQLITE_MAX_VARIABLE_NUMBER=250000
|
|
export SQLITE_MAX_EXPR_DEPTH=10000
|
|
'';
|
|
|
|
cargoBuildFlags = [
|
|
"-p" "query-engine"
|
|
"-p" "query-engine-node-api"
|
|
"-p" "schema-engine-cli"
|
|
"-p" "prisma-fmt"
|
|
];
|
|
|
|
postInstall = ''
|
|
mv $out/lib/libquery_engine${pkgs.stdenv.hostPlatform.extensions.sharedLibrary} $out/lib/libquery_engine.node
|
|
'';
|
|
|
|
# Tests are long to compile
|
|
doCheck = false;
|
|
};
|
|
in
|
|
pkgs.mkShell {
|
|
nativeBuildInputs = [
|
|
new-prisma-engines
|
|
pkgs.nodejs_18
|
|
pkgs.openssl
|
|
];
|
|
shellHook = ''
|
|
export PRISMA_SCHEMA_ENGINE_BINARY="${new-prisma-engines}/bin/schema-engine"
|
|
export PRISMA_QUERY_ENGINE_BINARY="${new-prisma-engines}/bin/query-engine"
|
|
export PRISMA_QUERY_ENGINE_LIBRARY="${new-prisma-engines}/lib/libquery_engine.node"
|
|
export PRISMA_FMT_BINARY="${new-prisma-engines}/bin/prisma-fmt"
|
|
'';
|
|
}
|