prisma, prisma-engines: 6.19.0 -> 7.0.1

This commit is contained in:
Jon Seager
2025-12-19 14:17:47 +00:00
parent d677ffb53a
commit 36b304952f
6 changed files with 277 additions and 1 deletions
@@ -0,0 +1,81 @@
{
fetchFromGitHub,
lib,
openssl,
pkg-config,
protobuf,
rustPlatform,
}:
# Updating this package will force an update for prisma. The
# version of prisma-engines and prisma must be the same for them to
# function correctly.
rustPlatform.buildRustPackage rec {
pname = "prisma-engines_7";
version = "7.0.1";
src = fetchFromGitHub {
owner = "prisma";
repo = "prisma-engines";
rev = version;
hash = "sha256-+8k+M2+WySR2CeywYlhU/jd3av/4UeUoEOlO/qHUk5o=";
};
cargoHash = "sha256-n83hJfSlvuaoBb3w9Rk8+q2emjGCoPDHhFdoVzhf4sM=";
# Use system openssl.
OPENSSL_NO_VENDOR = 1;
nativeBuildInputs = [ pkg-config ];
buildInputs = [ openssl ];
preBuild = ''
export OPENSSL_DIR=${lib.getDev openssl}
export OPENSSL_LIB_DIR=${lib.getLib openssl}/lib
export PROTOC=${protobuf}/bin/protoc
export PROTOC_INCLUDE="${protobuf}/include";
export SQLITE_MAX_VARIABLE_NUMBER=250000
export SQLITE_MAX_EXPR_DEPTH=10000
export GIT_HASH=0000000000000000000000000000000000000000
'';
cargoBuildFlags = [
"-p"
"schema-engine-cli"
"-p"
"prisma-fmt"
];
# Tests are long to compile
doCheck = false;
setupHook = ./setup-hook.sh;
meta = with lib; {
description = "Collection of engines that power the core stack for Prisma";
homepage = "https://www.prisma.io/";
license = licenses.asl20;
platforms = platforms.unix;
mainProgram = "prisma";
maintainers = with maintainers; [
tomhoule
aqrln
];
};
}
### 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
# Prisma requires 2 packages, `prisma-engines` and `prisma`, to be at *exact* same versions.
# 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.
@@ -0,0 +1,2 @@
export PRISMA_SCHEMA_ENGINE_BINARY="@out@/bin/schema-engine"
export PRISMA_FMT_BINARY="@out@/bin/prisma-fmt"
+108
View File
@@ -0,0 +1,108 @@
{
lib,
fetchFromGitHub,
stdenv,
nodejs,
pnpm_10,
prisma-engines_7,
jq,
makeWrapper,
moreutils,
callPackage,
pnpmConfigHook,
fetchPnpmDeps,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "prisma_7";
version = "7.0.1";
src = fetchFromGitHub {
owner = "prisma";
repo = "prisma";
rev = finalAttrs.version;
hash = "sha256-bmmthEFMBMJAracWUCU/6Nyic05JglP5t1VAWPVKFnU=";
};
nativeBuildInputs = [
nodejs
pnpmConfigHook
jq
makeWrapper
moreutils
pnpm_10
];
pnpmDeps = fetchPnpmDeps {
inherit (finalAttrs) pname version src;
fetcherVersion = 1;
hash = "sha256-sJmlMF8nay4/3LTHEWzBWaS8Xq91JRZlzKBfeMnJEMM=";
};
patchPhase = ''
runHook prePatch
for package in packages/*; do
jq --arg version $version '.version = $version' $package/package.json | sponge $package/package.json
done
runHook postPatch
'';
buildPhase = ''
runHook preBuild
pnpm build
runHook postBuild
'';
# FIXME: Use pnpm deploy: https://github.com/pnpm/pnpm/issues/5315
installPhase = ''
runHook preInstall
mkdir -p $out/lib/prisma
# Fetch CLI workspace dependencies
deps_json=$(pnpm list --filter ./packages/cli --prod --depth Infinity --json)
deps=$(jq -r '[.. | strings | select(startswith("link:../")) | sub("^link:../"; "")] | unique[]' <<< "$deps_json")
# Remove unnecessary external dependencies
find . -name node_modules -type d -prune -exec rm -rf {} +
pnpm install --offline --ignore-scripts --frozen-lockfile --prod
cp -r node_modules $out/lib/prisma
# Only install cli and its workspace dependencies
for package in cli $deps; do
filename=$(npm pack --json ./packages/$package | jq -r '.[].filename')
mkdir -p $out/lib/prisma/packages/$package
[ -d "packages/$package/node_modules" ] && \
cp -r packages/$package/node_modules $out/lib/prisma/packages/$package
tar xf $filename --strip-components=1 -C $out/lib/prisma/packages/$package
done
# Remove dangling symlinks to packages we didn't copy to $out
find $out/lib/prisma/node_modules/.pnpm/node_modules -type l -exec test ! -e {} \; -delete
makeWrapper "${lib.getExe nodejs}" "$out/bin/prisma" \
--add-flags "$out/lib/prisma/packages/cli/build/index.js" \
--set PRISMA_SCHEMA_ENGINE_BINARY ${prisma-engines_7}/bin/schema-engine
runHook postInstall
'';
dontStrip = true;
passthru.tests = {
cli = callPackage ./test-cli.nix { };
};
meta = with lib; {
description = "Next-generation ORM for Node.js and TypeScript";
homepage = "https://www.prisma.io/";
license = licenses.asl20;
maintainers = with maintainers; [ aqrln ];
mainProgram = "prisma";
platforms = platforms.unix;
};
})
+83
View File
@@ -0,0 +1,83 @@
{
lib,
runCommand,
prisma_7,
prisma-engines_7,
sqlite-interactive,
openssl,
}:
let
prismaMajorVersion = lib.versions.majorMinor prisma_7.version;
enginesMajorVersion = lib.versions.majorMinor prisma-engines_7.version;
in
runCommand "prisma-cli-tests"
{
nativeBuildInputs = [
prisma_7
sqlite-interactive
openssl
];
meta.timeout = 60;
}
''
mkdir $out
cd $out
# Set HOME to a writable directory (Nix sandbox sets it to /homeless-shelter)
export HOME=$TMPDIR
if [ "${prismaMajorVersion}" != "${enginesMajorVersion}" ]; then
echo "prisma in version ${prismaMajorVersion} and prisma-engines in ${enginesMajorVersion}. Major versions must match."
exit 1
fi
# Ensure CLI runs
prisma --help > /dev/null
# Create project structure manually (prisma init requires network access)
mkdir -p prisma node_modules
# The config file needs to be able to import from 'prisma/config'
# so we symlink the prisma package into node_modules
ln -s ${prisma_7}/lib/prisma/packages/cli node_modules/prisma
cat << 'EOF' > prisma.config.ts
import { defineConfig } from 'prisma/config'
export default defineConfig({
schema: 'prisma/schema.prisma',
datasource: {
url: 'file:prisma/test.db',
},
})
EOF
# Create a simple data model
cat << 'EOF' > prisma/schema.prisma
datasource db {
provider = "sqlite"
}
generator client {
provider = "prisma-client"
}
model A {
id Int @id @default(autoincrement())
b String @default("foo")
}
EOF
# Format
prisma format > /dev/null
# Create the database
prisma db push > /dev/null
# The database file should exist and be a SQLite database
sqlite3 prisma/test.db "SELECT id, b FROM A" > /dev/null
# Introspect the database
prisma db pull > /dev/null
''
+1 -1
View File
@@ -287,7 +287,7 @@ mapAliases {
inherit (pkgs) prettier; # added 2025-05-31
prettier_d_slim = pkgs.prettier-d-slim; # added 2023-09-14
prettier-plugin-toml = throw "prettier-plugin-toml was removed because it provides no executable"; # added 2025-03-23
inherit (pkgs) prisma_6; # added 2024-08-31
inherit (pkgs) prisma; # added 2024-08-31
pscid = throw "'pscid' has been removed because it was unmaintained upstream"; # Added 2025-12-07
pulp = throw "'pulp' has been removed because it was unmaintained upstream"; # Added 2025-12-07
purescript-language-server = throw "'purescript-language-server' has been removed because it was unmaintained within nixpkgs"; # Added 2025-12-12
+2
View File
@@ -1331,6 +1331,8 @@ mapAliases {
preload = throw "'preload' has been removed due to lack of usage and being broken since its introduction into nixpkgs"; # Added 2025-11-29
presage = throw "presage has been removed, as it has been unmaintained since 2018"; # Added 2025-06-19
preserves-nim = throw "'preserves-nim' has been removed due to a hostile upstream moving tags and breaking src FODs"; # Added 2025-09-01
prisma = prisma_7; # Added 2025-12-19
prisma-engines = prisma-engines_7; # Added 2025-12-19
private-gpt = throw "'private-gpt' has been removed from nixpkgs, as it was broken and unmaintained"; # Added 2025-07-28
probe-rs = throw "'probe-rs' has been renamed to/replaced by 'probe-rs-tools'"; # Converted to throw 2025-10-27
proj_7 = throw "proj_7 has been removed, as it was broken and unused"; # Added 2025-09-16