-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathprisma.nix
More file actions
109 lines (107 loc) · 2.94 KB
/
prisma.nix
File metadata and controls
109 lines (107 loc) · 2.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
{
nixpkgs ? null,
# if both are set, prefer pkgs over nixpkgs
pkgs ? nixpkgs,
opensslVersion ? "3.0.x", # can be 3.0.x, 1.1.x or 1.0.x
openssl ? pkgs.openssl, # the openssl package to use
# new fetcher args
hash ? null,
versionString ? null,
version ? null,
npmLock ? null,
yarnLock ? null,
pnpmLock ? null,
bunLock ? null,
# legacy fetcher args
introspection-engine-hash ? null,
migration-engine-hash ? null,
prisma-fmt-hash ? null,
query-engine-hash ? null,
libquery-engine-hash ? null,
schema-engine-hash ? null,
binaryTargetBySystem ? {
x86_64-linux = "debian";
aarch64-linux = "linux-arm64";
x86_64-darwin = "darwin";
aarch64-darwin = "darwin-arm64";
},
}:
let
inherit (pkgs) lib;
parsers = pkgs.callPackage ./lib/parsers.nix { };
binaryTarget = binaryTargetBySystem.${pkgs.system};
fromVersionString =
versionString:
let
version = parsers.parseVersionString versionString;
in
fromVersion version;
fromVersion =
version:
if hash != null then
# use new fetcher
pkgs.callPackage ./lib/fetcher.nix {
inherit
openssl
opensslVersion
binaryTarget
hash
version
;
}
else
pkgs.callPackage ./lib/legacyFetcher.nix {
inherit
openssl
opensslVersion
binaryTarget
prisma-fmt-hash
query-engine-hash
libquery-engine-hash
introspection-engine-hash
migration-engine-hash
schema-engine-hash
version
;
};
fromNpmLock = file: fromVersionString (parsers.parseNpmLock file);
fromPnpmLock = file: fromVersionString (parsers.parsePnpmLock file);
fromYarnLock = file: fromVersionString (parsers.parseYarnLock file);
fromBunLock = file: fromVersionString (parsers.parseBunLock file);
in
lib.warnIf (nixpkgs != null)
''
`nixpkgs` argument in nix-prisma-utils is deprecated. please replace it with `pkgs`.
examples:
if your code has `inherit nixpkgs;`, replace it with `pkgs = nixpkgs;`.
if your code has `nixpkgs = pkgs;`, replace it with `pkgs = pkgs;` or `inherit pkgs;`.
''
(
if version != null then
fromVersion version
else if versionString != null then
fromVersionString versionString
else if npmLock != null then
fromNpmLock npmLock
else if yarnLock != null then
fromYarnLock yarnLock
else if pnpmLock != null then
fromPnpmLock pnpmLock
else if bunLock != null then
fromBunLock bunLock
else
{
# builder pattern
inherit
fromVersionString
fromVersion
fromNpmLock
fromYarnLock
fromPnpmLock
fromBunLock
;
fromCommit =
commit:
builtins.throw "nix-prisma-utils: fromCommit is no longer supported. please set either npmLock, yarnLock, pnpmLock, bunLock or use fromVersion instead.";
}
)