From c718dede153e3c32b7c06c2b2d6f9909448ec0b3 Mon Sep 17 00:00:00 2001 From: aster <137767097+aster-void@users.noreply.github.com> Date: Thu, 20 Nov 2025 18:34:24 +0900 Subject: [PATCH 1/4] hack: fix new prisma commit parsing failure --- flake.nix | 15 +++++++++++++++ lib/fetcher.nix | 14 +++++++++----- lib/legacyFetcher.nix | 29 ++++++++++++++++------------- prisma.nix | 12 ++++++++++-- 4 files changed, 50 insertions(+), 20 deletions(-) diff --git a/flake.nix b/flake.nix index 07827cd..7fbfc37 100644 --- a/flake.nix +++ b/flake.nix @@ -85,6 +85,21 @@ (prisma-legacy.fromNpmLock ./npm/package-lock.json).env == (prisma-new "npmLock" ./npm/package-lock.json).env; pkgs.hello; + prisma-next = + let + # force download debian for consistent hash across systems + binaryTargetBySystem = { + x86_64-linux = "debian"; + aarch64-linux = "debian"; + x86_64-darwin = "debian"; + aarch64-darwin = "debian"; + }; + in + (self.lib.prisma-factory { + inherit pkgs binaryTargetBySystem; + _commit = "next-0c19ccc313cf9911a90d99d2ac2eb0280c76c513"; + hash = "sha256-JWX+N/mmp9uJLcv4XFbQ3yg34fFf2BLIUpOLrrfTjEM="; + }).package; }; packages.default = (prisma-factory { diff --git a/lib/fetcher.nix b/lib/fetcher.nix index c5dd463..c23eb6d 100644 --- a/lib/fetcher.nix +++ b/lib/fetcher.nix @@ -14,6 +14,7 @@ binaryTarget, hash, components, + isv7, }: let componentsToFetch = @@ -26,6 +27,13 @@ let path = "bin/prisma-fmt"; env = "PRISMA_FMT_BINARY"; } + { + url = "schema-engine.gz"; + path = "bin/schema-engine"; + env = "PRISMA_SCHEMA_ENGINE_BINARY"; + } + ] + ++ lib.optionals (!isv7) [ { url = "query-engine.gz"; path = "bin/query-engine"; @@ -36,11 +44,6 @@ let path = "lib/libquery_engine.node"; env = "PRISMA_QUERY_ENGINE_LIBRARY"; } - { - url = "schema-engine.gz"; - path = "bin/schema-engine"; - env = "PRISMA_SCHEMA_ENGINE_BINARY"; - } ]; isDarwin = lib.strings.hasPrefix "darwin" binaryTarget; target = if isDarwin then binaryTarget else "${binaryTarget}-openssl-${opensslVersion}"; @@ -63,6 +66,7 @@ let mkdir -p $out $out/lib $out/bin ${lib.concatLines ( map (component: '' + echo '[nix-prisma-utils] fetching ${toUrl component.url} to $out/${component.path}' curl "${toUrl component.url}" -L | gunzip > $out/${component.path} '') componentsToFetch )} diff --git a/lib/legacyFetcher.nix b/lib/legacyFetcher.nix index 70ea33a..b747335 100644 --- a/lib/legacyFetcher.nix +++ b/lib/legacyFetcher.nix @@ -10,6 +10,7 @@ commit, opensslVersion, binaryTarget, + isv7, # = hashes prisma-fmt-hash, query-engine-hash, @@ -32,6 +33,21 @@ let path = "bin/prisma-fmt"; variable = "PRISMA_FMT_BINARY"; } + ] + ++ ( + if schema-engine-hash == null then + [ ] + else + [ + { + name = "schema-engine"; + hash = schema-engine-hash; + path = "bin/schema-engine"; + variable = "PRISMA_SCHEMA_ENGINE_BINARY"; + } + ] + ) + ++ lib.optionals (!isv7) [ { name = "query-engine"; hash = query-engine-hash; @@ -70,19 +86,6 @@ let variable = "PRISMA_MIGRATION_ENGINE_BINARY"; } ] - ) - ++ ( - if schema-engine-hash == null then - [ ] - else - [ - { - name = "schema-engine"; - hash = schema-engine-hash; - path = "bin/schema-engine"; - variable = "PRISMA_SCHEMA_ENGINE_BINARY"; - } - ] ); downloadedFiles = builtins.map ( file: diff --git a/prisma.nix b/prisma.nix index e1f9954..b274b09 100644 --- a/prisma.nix +++ b/prisma.nix @@ -31,10 +31,17 @@ let parsers = pkgs.callPackage ./lib/parsers.nix { }; binaryTarget = binaryTargetBySystem.${pkgs.system}; fromCommit = - commit: + _commit: + let + # HACK: _commit may be "next-0c19ccc313cf9911a90d99d2ac2eb0280c76c513" instead of "0c19ccc313cf9911a90d99d2ac2eb0280c76c513" + commit = lib.lists.last (lib.splitString "-" _commit); + # prisma >= v7 has fewer components; + isv7 = lib.strings.hasPrefix "next-" _commit; + in if builtins.stringLength commit != 40 then throw "invalid commit: got ${commit}" else if hash != null then + # use new fetcher pkgs.callPackage ./lib/fetcher.nix { inherit commit @@ -43,9 +50,9 @@ let binaryTarget hash components + isv7 ; } - # use new fetcher else pkgs.callPackage ./lib/legacyFetcher.nix { inherit @@ -53,6 +60,7 @@ let openssl opensslVersion binaryTarget + isv7 prisma-fmt-hash query-engine-hash libquery-engine-hash From 9c5315d913102ceeddec7895bbec1fbdc06f0bcd Mon Sep 17 00:00:00 2001 From: aster-void <137767097+aster-void@users.noreply.github.com> Date: Thu, 20 Nov 2025 21:09:16 +0900 Subject: [PATCH 2/4] safety: only remove prefix if prefix = "next-" --- prisma.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/prisma.nix b/prisma.nix index b274b09..386ff81 100644 --- a/prisma.nix +++ b/prisma.nix @@ -34,8 +34,8 @@ let _commit: let # HACK: _commit may be "next-0c19ccc313cf9911a90d99d2ac2eb0280c76c513" instead of "0c19ccc313cf9911a90d99d2ac2eb0280c76c513" - commit = lib.lists.last (lib.splitString "-" _commit); - # prisma >= v7 has fewer components; + commit = lib.strings.removePrefix "next-" _commit; + # prisma >= v7 has fewer components isv7 = lib.strings.hasPrefix "next-" _commit; in if builtins.stringLength commit != 40 then From d83828c7aae1cd357055b7342b972162352a265e Mon Sep 17 00:00:00 2001 From: aster-void <137767097+aster-void@users.noreply.github.com> Date: Thu, 20 Nov 2025 22:35:53 +0900 Subject: [PATCH 3/4] fix: specify correct hash for each system --- flake.nix | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/flake.nix b/flake.nix index 7fbfc37..e18c293 100644 --- a/flake.nix +++ b/flake.nix @@ -86,19 +86,15 @@ == (prisma-new "npmLock" ./npm/package-lock.json).env; pkgs.hello; prisma-next = - let - # force download debian for consistent hash across systems - binaryTargetBySystem = { - x86_64-linux = "debian"; - aarch64-linux = "debian"; - x86_64-darwin = "debian"; - aarch64-darwin = "debian"; - }; - in (self.lib.prisma-factory { - inherit pkgs binaryTargetBySystem; + pkgs = pkgs; _commit = "next-0c19ccc313cf9911a90d99d2ac2eb0280c76c513"; - hash = "sha256-JWX+N/mmp9uJLcv4XFbQ3yg34fFf2BLIUpOLrrfTjEM="; + hash = { + x86_64-linux = "sha256-JWX+N/mmp9uJLcv4XFbQ3yg34fFf2BLIUpOLrrfTjEM=" ; + x86_64-darwin = "sha256-WNwFOoeDOebbfAh4y/NvZCyE9otaJdg2hHb4ifEFD+Y="; + aarch64-linux = "sha256-f9FuPZaGx0FwKo4pA9f8g82MTcAzYLwWslxjb7oqk6E="; + aarch64-darwin = "sha256-NMI+JcP3epBO3V37D19TDgzivMnPekgrYqUrXB6qNV0="; + }.${pkgs.system}; }).package; }; packages.default = From 6fa91a481a0f12e4018d96f8c2c2e5af49d97342 Mon Sep 17 00:00:00 2001 From: aster-void <137767097+aster-void@users.noreply.github.com> Date: Thu, 20 Nov 2025 22:40:22 +0900 Subject: [PATCH 4/4] chore: format --- flake.nix | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/flake.nix b/flake.nix index e18c293..1aa1d3d 100644 --- a/flake.nix +++ b/flake.nix @@ -89,12 +89,14 @@ (self.lib.prisma-factory { pkgs = pkgs; _commit = "next-0c19ccc313cf9911a90d99d2ac2eb0280c76c513"; - hash = { - x86_64-linux = "sha256-JWX+N/mmp9uJLcv4XFbQ3yg34fFf2BLIUpOLrrfTjEM=" ; - x86_64-darwin = "sha256-WNwFOoeDOebbfAh4y/NvZCyE9otaJdg2hHb4ifEFD+Y="; - aarch64-linux = "sha256-f9FuPZaGx0FwKo4pA9f8g82MTcAzYLwWslxjb7oqk6E="; - aarch64-darwin = "sha256-NMI+JcP3epBO3V37D19TDgzivMnPekgrYqUrXB6qNV0="; - }.${pkgs.system}; + hash = + { + x86_64-linux = "sha256-JWX+N/mmp9uJLcv4XFbQ3yg34fFf2BLIUpOLrrfTjEM="; + x86_64-darwin = "sha256-WNwFOoeDOebbfAh4y/NvZCyE9otaJdg2hHb4ifEFD+Y="; + aarch64-linux = "sha256-f9FuPZaGx0FwKo4pA9f8g82MTcAzYLwWslxjb7oqk6E="; + aarch64-darwin = "sha256-NMI+JcP3epBO3V37D19TDgzivMnPekgrYqUrXB6qNV0="; + } + .${pkgs.system}; }).package; }; packages.default =