Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

{prisma,prisma-engines}: 5.16.1 -> 5.18.0 #337521

Merged
merged 2 commits into from
Aug 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions nixos/doc/manual/release-notes/rl-2411.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
6 changes: 4 additions & 2 deletions pkgs/applications/office/documenso/default.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{ lib
, fetchFromGitHub
, buildNpmPackage
, nodePackages
, prisma
, nix-update-script
}:
let
Expand All @@ -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=";
Expand Down
101 changes: 101 additions & 0 deletions pkgs/by-name/pr/prisma/package.nix
Original file line number Diff line number Diff line change
@@ -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;
};
})
Original file line number Diff line number Diff line change
@@ -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

Expand Down
1 change: 0 additions & 1 deletion pkgs/development/node-packages/node-packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@
, "prebuild-install"
, "prettier"
, "prettier-plugin-toml"
, "prisma"
, "@prisma/language-server"
szlend marked this conversation as resolved.
Show resolved Hide resolved
, "pscid"
, "pulp"
Expand Down
70 changes: 0 additions & 70 deletions pkgs/development/node-packages/node-packages.nix

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 0 additions & 27 deletions pkgs/development/node-packages/overrides.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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" ];
Expand Down
Loading