Skip to content
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
13 changes: 13 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,19 @@
(prisma-legacy.fromNpmLock ./npm/package-lock.json).env
== (prisma-new "npmLock" ./npm/package-lock.json).env;
pkgs.hello;
prisma-next =
(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};
}).package;
};
packages.default =
(prisma-factory {
Expand Down
14 changes: 9 additions & 5 deletions lib/fetcher.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
binaryTarget,
hash,
components,
isv7,
}:
let
componentsToFetch =
Expand All @@ -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";
Expand All @@ -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}";
Expand All @@ -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
)}
Expand Down
29 changes: 16 additions & 13 deletions lib/legacyFetcher.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
commit,
opensslVersion,
binaryTarget,
isv7,
# = hashes
prisma-fmt-hash,
query-engine-hash,
Expand All @@ -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;
Expand Down Expand Up @@ -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:
Expand Down
12 changes: 10 additions & 2 deletions prisma.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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.strings.removePrefix "next-" _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
Expand All @@ -43,16 +50,17 @@ let
binaryTarget
hash
components
isv7
;
}
# use new fetcher
else
pkgs.callPackage ./lib/legacyFetcher.nix {
inherit
commit
openssl
opensslVersion
binaryTarget
isv7
prisma-fmt-hash
query-engine-hash
libquery-engine-hash
Expand Down
Loading