prisma: init at 5.18.0

This commit is contained in:
Simon Žlender 2024-08-27 20:14:29 +02:00
parent c14b2eeae8
commit dcbcaee4cf
9 changed files with 129 additions and 114 deletions

View File

@ -233,6 +233,8 @@
and `nodePackages.vscode-json-languageserver-bin` were dropped due to an unmaintained upstream.
The `vscode-langservers-extracted` package is a maintained drop-in replacement.
- `nodePackages.prisma` has been replaced by `prisma`.
- `fetchNextcloudApp` has been rewritten to use `fetchurl` rather than
`fetchzip`. This invalidates all existing hashes but you can restore the old
behavior by passing it `unpack = true`.

View File

@ -1,7 +1,7 @@
{ lib
, fetchFromGitHub
, buildNpmPackage
, nodePackages
, prisma
, nix-update-script
}:
let
@ -18,12 +18,14 @@ buildNpmPackage {
hash = "sha256-uKOJVZ0GRHo/CYvd/Ix/tq1WDhutRji1tSGdcITsNlo=";
};
nativeBuildInputs = [ prisma ];
preBuild = ''
# somehow for linux, npm is not finding the prisma package with the
# packages installed with the lockfile.
# This generates a prisma version incompatibility warning and is a kludge
# until the upstream package-lock is modified.
${nodePackages.prisma}/bin/prisma generate
prisma generate
'';
npmDepsHash = "sha256-+JbvFMi8xoyxkuL9k96K1Vq0neciCGkkyZUPd15ES2E=";

View File

@ -0,0 +1,101 @@
{
lib,
fetchFromGitHub,
stdenv,
nodejs,
pnpm_8,
prisma-engines,
jq,
makeWrapper,
moreutils,
callPackage,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "prisma";
version = "5.18.0";
src = fetchFromGitHub {
owner = "prisma";
repo = "prisma";
rev = finalAttrs.version;
hash = "sha256-BLD2nKryigXr03BCgGwb3PnCcBLMyDfSFb9Snj0VPKI=";
};
nativeBuildInputs = [
nodejs
pnpm_8.configHook
jq
makeWrapper
moreutils
];
pnpmDeps = pnpm_8.fetchDeps {
inherit (finalAttrs) pname version src;
hash = "sha256-lgdJk7HCfX3cAvdEI8xG/IVBiLWezdUN0q+e/0LtVUQ=";
};
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
rm -rf node_modules
pnpm install --offline --ignore-scripts --frozen-lockfile --prod --filter ./packages/cli
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
cp -r packages/$package/node_modules $out/lib/prisma/packages/$package
tar xf $filename --strip-components=1 -C $out/lib/prisma/packages/$package
done
makeWrapper "${lib.getExe nodejs}" "$out/bin/prisma" \
--add-flags "$out/lib/prisma/packages/cli/build/index.js" \
--set PRISMA_SCHEMA_ENGINE_BINARY ${prisma-engines}/bin/schema-engine \
--set PRISMA_QUERY_ENGINE_BINARY ${prisma-engines}/bin/query-engine \
--set PRISMA_QUERY_ENGINE_LIBRARY ${lib.getLib prisma-engines}/lib/libquery_engine.node
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 ];
platforms = platforms.unix;
};
})

View File

@ -1,21 +1,29 @@
{ lib, pkgs, runCommand, prisma }:
{
lib,
runCommand,
prisma,
prisma-engines,
sqlite-interactive,
}:
let
inherit (prisma) packageName;
prismaMajorVersion = lib.versions.majorMinor prisma.version;
enginesMajorVersion = lib.versions.majorMinor pkgs.prisma-engines.version;
enginesMajorVersion = lib.versions.majorMinor prisma-engines.version;
in
runCommand "${packageName}-tests" {
nativeBuildInputs = with pkgs; [ prisma sqlite-interactive ];
meta.timeout = 60;
}
runCommand "prisma-cli-tests"
{
nativeBuildInputs = [
prisma
sqlite-interactive
];
meta.timeout = 60;
}
''
mkdir $out
cd $out
if [ "${prismaMajorVersion}" != "${enginesMajorVersion}" ]; then
echo "nodePackages.prisma in version ${prismaMajorVersion} and prisma-engines in ${enginesMajorVersion}. Major versions must match."
echo "prisma in version ${prismaMajorVersion} and prisma-engines in ${enginesMajorVersion}. Major versions must match."
exit 1
fi

View File

@ -168,7 +168,6 @@
, "prebuild-install"
, "prettier"
, "prettier-plugin-toml"
, "prisma"
, "@prisma/language-server"
, "pscid"
, "pulp"

View File

@ -8707,51 +8707,6 @@ let
sha512 = "j7P6Rgr3mmtdkeDGTe0E/aYyWEWVtc5yFXtHCRHs28/jptDEWfaVOc5T7cblqy1XKPPfCxJc/8DwQ5YgLOZOVQ==";
};
};
"@prisma/debug-5.17.0" = {
name = "_at_prisma_slash_debug";
packageName = "@prisma/debug";
version = "5.17.0";
src = fetchurl {
url = "https://registry.npmjs.org/@prisma/debug/-/debug-5.17.0.tgz";
sha512 = "l7+AteR3P8FXiYyo496zkuoiJ5r9jLQEdUuxIxNCN1ud8rdbH3GTxm+f+dCyaSv9l9WY+29L9czaVRXz9mULfg==";
};
};
"@prisma/engines-5.17.0" = {
name = "_at_prisma_slash_engines";
packageName = "@prisma/engines";
version = "5.17.0";
src = fetchurl {
url = "https://registry.npmjs.org/@prisma/engines/-/engines-5.17.0.tgz";
sha512 = "+r+Nf+JP210Jur+/X8SIPLtz+uW9YA4QO5IXA+KcSOBe/shT47bCcRMTYCbOESw3FFYFTwe7vU6KTWHKPiwvtg==";
};
};
"@prisma/engines-version-5.17.0-31.393aa359c9ad4a4bb28630fb5613f9c281cde053" = {
name = "_at_prisma_slash_engines-version";
packageName = "@prisma/engines-version";
version = "5.17.0-31.393aa359c9ad4a4bb28630fb5613f9c281cde053";
src = fetchurl {
url = "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-5.17.0-31.393aa359c9ad4a4bb28630fb5613f9c281cde053.tgz";
sha512 = "tUuxZZysZDcrk5oaNOdrBnnkoTtmNQPkzINFDjz7eG6vcs9AVDmA/F6K5Plsb2aQc/l5M2EnFqn3htng9FA4hg==";
};
};
"@prisma/fetch-engine-5.17.0" = {
name = "_at_prisma_slash_fetch-engine";
packageName = "@prisma/fetch-engine";
version = "5.17.0";
src = fetchurl {
url = "https://registry.npmjs.org/@prisma/fetch-engine/-/fetch-engine-5.17.0.tgz";
sha512 = "ESxiOaHuC488ilLPnrv/tM2KrPhQB5TRris/IeIV4ZvUuKeaicCl4Xj/JCQeG9IlxqOgf1cCg5h5vAzlewN91Q==";
};
};
"@prisma/get-platform-5.17.0" = {
name = "_at_prisma_slash_get-platform";
packageName = "@prisma/get-platform";
version = "5.17.0";
src = fetchurl {
url = "https://registry.npmjs.org/@prisma/get-platform/-/get-platform-5.17.0.tgz";
sha512 = "UlDgbRozCP1rfJ5Tlkf3Cnftb6srGrEQ4Nm3og+1Se2gWmCZ0hmPIi+tQikGDUVLlvOWx3Gyi9LzgRP+HTXV9w==";
};
};
"@prisma/prisma-schema-wasm-5.17.0-31.393aa359c9ad4a4bb28630fb5613f9c281cde053" = {
name = "_at_prisma_slash_prisma-schema-wasm";
packageName = "@prisma/prisma-schema-wasm";
@ -81407,31 +81362,6 @@ in
bypassCache = true;
reconstructLock = true;
};
prisma = nodeEnv.buildNodePackage {
name = "prisma";
packageName = "prisma";
version = "5.17.0";
src = fetchurl {
url = "https://registry.npmjs.org/prisma/-/prisma-5.17.0.tgz";
sha512 = "m4UWkN5lBE6yevqeOxEvmepnL5cNPEjzMw2IqDB59AcEV6w7D8vGljDLd1gPFH+W6gUxw9x7/RmN5dCS/WTPxA==";
};
dependencies = [
sources."@prisma/debug-5.17.0"
sources."@prisma/engines-5.17.0"
sources."@prisma/engines-version-5.17.0-31.393aa359c9ad4a4bb28630fb5613f9c281cde053"
sources."@prisma/fetch-engine-5.17.0"
sources."@prisma/get-platform-5.17.0"
];
buildInputs = globalBuildInputs;
meta = {
description = "Prisma is an open-source database toolkit. It includes a JavaScript/TypeScript ORM for Node.js, migrations and a modern GUI to view and edit the data in your database. You can use Prisma in new projects or add it to an existing one.";
homepage = "https://www.prisma.io";
license = "Apache-2.0";
};
production = true;
bypassCache = true;
reconstructLock = true;
};
"@prisma/language-server" = nodeEnv.buildNodePackage {
name = "_at_prisma_slash_language-server";
packageName = "@prisma/language-server";

View File

@ -268,33 +268,6 @@ final: prev: {
};
});
# To update prisma, please first update prisma-engines to the latest
# version. Then change the correct hash to this package. The PR should hold
# two commits: one for the engines and the other one for the node package.
prisma = prev.prisma.override rec {
nativeBuildInputs = [ pkgs.buildPackages.makeWrapper ];
inherit (pkgs.prisma-engines) version;
src = fetchurl {
url = "https://registry.npmjs.org/prisma/-/prisma-${version}.tgz";
hash = "sha256-TlwKCuDQRFM6+Hhx9eFCfXbtLZq6RwBTIFCWzE4D8N8=";
};
postInstall = with pkgs; ''
wrapProgram "$out/bin/prisma" \
--set PRISMA_SCHEMA_ENGINE_BINARY ${prisma-engines}/bin/schema-engine \
--set PRISMA_QUERY_ENGINE_BINARY ${prisma-engines}/bin/query-engine \
--set PRISMA_QUERY_ENGINE_LIBRARY ${lib.getLib prisma-engines}/lib/libquery_engine.node \
--set PRISMA_FMT_BINARY ${prisma-engines}/bin/prisma-fmt
'';
passthru.tests = {
simple-execution = pkgs.callPackage ./package-tests/prisma.nix {
inherit (final) prisma;
};
};
};
pulp = prev.pulp.override {
# tries to install purescript
npmFlags = builtins.toString [ "--ignore-scripts" ];

View File

@ -9,8 +9,8 @@
, stdenv
}:
# Updating this package will force an update for nodePackages.prisma. The
# version of prisma-engines and nodePackages.prisma must be the same for them to
# 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";
@ -89,7 +89,7 @@ rustPlatform.buildRustPackage rec {
# 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 `nodePackages.prisma`, to be at *exact* same versions.
# 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`.

View File

@ -3,7 +3,7 @@
buildNpmPackage,
vips,
pkg-config,
nodePackages,
prisma,
src,
version,
nixosTests,
@ -28,7 +28,7 @@ buildNpmPackage {
buildInputs = [ vips ];
nativeBuildInputs = [
pkg-config
nodePackages.prisma
prisma
];
npmDepsHash = "sha256-btjvX+2krSc0/bJqeLcVTqHBVWqiTFipp3MidO9wApY=";