Skip to content

Commit 05678f2

Browse files
committed
update hashes & format files
1 parent 28de217 commit 05678f2

File tree

6 files changed

+449
-411
lines changed

6 files changed

+449
-411
lines changed

flake.nix

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,39 @@
55
treefmt-nix.url = "github:numtide/treefmt-nix";
66
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
77
};
8-
outputs = {
9-
self,
10-
nixpkgs,
11-
flake-utils,
12-
treefmt-nix,
13-
}: let
14-
prisma-factory = import ./prisma.nix;
15-
in
8+
outputs =
9+
{
10+
self,
11+
nixpkgs,
12+
flake-utils,
13+
treefmt-nix,
14+
}:
15+
let
16+
prisma-factory = import ./prisma.nix;
17+
in
1618
flake-utils.lib.eachDefaultSystem (
17-
system: let
19+
system:
20+
let
1821
pkgs = nixpkgs.legacyPackages.${system};
1922

2023
yarn-v1 = pkgs.writeShellApplication {
2124
name = "yarn-v1";
2225
checkPhase = "";
23-
runtimeInputs = [pkgs.yarn];
26+
runtimeInputs = [ pkgs.yarn ];
2427
text = "yarn $@";
2528
};
2629
yarn-berry = pkgs.writeShellApplication {
2730
name = "yarn-berry";
2831
checkPhase = "";
29-
runtimeInputs = [pkgs.yarn-berry];
32+
runtimeInputs = [ pkgs.yarn-berry ];
3033
text = "yarn $@";
3134
};
3235
treefmt = treefmt-nix.lib.evalModule pkgs {
3336
# nixfmt is nixfmt-rfc-style
3437
programs.nixfmt.enable = true;
3538
};
36-
in {
39+
in
40+
{
3741
formatter = treefmt.config.build.wrapper;
3842
checks =
3943
(pkgs.callPackages ./tests.nix {
@@ -63,13 +67,14 @@
6367
hash = "sha256-R9PG286KQTbzF0r/PPcShUkMiYam2prRh/JICjmhCZA=";
6468
_commit = "6a3747c37ff169c90047725a05a6ef02e32ac97e";
6569
}).package;
66-
devShells.default = let
67-
prisma = prisma-factory {
68-
inherit pkgs;
69-
hash = "sha256-R9PG286KQTbzF0r/PPcShUkMiYam2prRh/JICjmhCZA=";
70-
_commit = "6a3747c37ff169c90047725a05a6ef02e32ac97e";
71-
};
72-
in
70+
devShells.default =
71+
let
72+
prisma = prisma-factory {
73+
inherit pkgs;
74+
hash = "sha256-R9PG286KQTbzF0r/PPcShUkMiYam2prRh/JICjmhCZA=";
75+
_commit = "6a3747c37ff169c90047725a05a6ef02e32ac97e";
76+
};
77+
in
7378
pkgs.mkShell {
7479
buildInputs = [
7580
pkgs.nodejs-18_x

lib/fetcher.nix

Lines changed: 64 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -14,73 +14,68 @@
1414
binaryTarget,
1515
hash,
1616
components,
17-
}: let
17+
}:
18+
let
1819
componentsToFetch =
19-
if components != null
20-
then components
21-
else [
22-
{
23-
url = "prisma-fmt.gz";
24-
path = "bin/prisma-fmt";
25-
env = "PRISMA_FMT_BINARY";
26-
}
27-
{
28-
url = "query-engine.gz";
29-
path = "bin/query-engine";
30-
env = "PRISMA_QUERY_ENGINE_BINARY";
31-
}
32-
{
33-
url =
34-
if isDarwin
35-
then "libquery_engine.dylib.node.gz"
36-
else "libquery_engine.so.node.gz";
37-
path = "lib/libquery_engine.node";
38-
env = "PRISMA_QUERY_ENGINE_LIBRARY";
39-
}
40-
{
41-
url = "schema-engine.gz";
42-
path = "bin/schema-engine";
43-
env = "PRISMA_SCHEMA_ENGINE_BINARY";
44-
}
45-
];
20+
if components != null then
21+
components
22+
else
23+
[
24+
{
25+
url = "prisma-fmt.gz";
26+
path = "bin/prisma-fmt";
27+
env = "PRISMA_FMT_BINARY";
28+
}
29+
{
30+
url = "query-engine.gz";
31+
path = "bin/query-engine";
32+
env = "PRISMA_QUERY_ENGINE_BINARY";
33+
}
34+
{
35+
url = if isDarwin then "libquery_engine.dylib.node.gz" else "libquery_engine.so.node.gz";
36+
path = "lib/libquery_engine.node";
37+
env = "PRISMA_QUERY_ENGINE_LIBRARY";
38+
}
39+
{
40+
url = "schema-engine.gz";
41+
path = "bin/schema-engine";
42+
env = "PRISMA_SCHEMA_ENGINE_BINARY";
43+
}
44+
];
4645
isDarwin = lib.strings.hasPrefix "darwin" binaryTarget;
47-
target =
48-
if isDarwin
49-
then binaryTarget
50-
else "${binaryTarget}-openssl-${opensslVersion}";
46+
target = if isDarwin then binaryTarget else "${binaryTarget}-openssl-${opensslVersion}";
5147
toUrl = url: "https://binaries.prisma.sh/all_commits/${commit}/${target}/${url}";
5248
deps =
53-
runCommand "prisma-deps-bin" {
54-
nativeBuildInputs = [
55-
curl
56-
cacert
57-
gzip
58-
];
59-
outputHashAlgo = "sha256";
60-
outputHashMode = "recursive";
61-
outputHash = hash;
62-
} ''
63-
export SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt
64-
export CURL_CA_BUNDLE=$SSL_CERT_FILE
65-
mkdir -p $out $out/lib $out/bin
66-
${lib.concatLines (
67-
map (component: ''
68-
curl "${toUrl component.url}" -L | gunzip > $out/${component.path}
69-
'')
70-
componentsToFetch
71-
)}
72-
'';
49+
runCommand "prisma-deps-bin"
50+
{
51+
nativeBuildInputs = [
52+
curl
53+
cacert
54+
gzip
55+
];
56+
outputHashAlgo = "sha256";
57+
outputHashMode = "recursive";
58+
outputHash = hash;
59+
}
60+
''
61+
export SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt
62+
export CURL_CA_BUNDLE=$SSL_CERT_FILE
63+
mkdir -p $out $out/lib $out/bin
64+
${lib.concatLines (
65+
map (component: ''
66+
curl "${toUrl component.url}" -L | gunzip > $out/${component.path}
67+
'') componentsToFetch
68+
)}
69+
'';
7370
package = stdenv.mkDerivation {
7471
pname = "prisma-bin";
7572
src = deps;
7673
version = commit;
77-
nativeBuildInputs =
78-
[
79-
zlib
80-
openssl
81-
stdenv.cc.cc.lib
82-
]
83-
++ lib.optionals (!isDarwin) [autoPatchelfHook];
74+
nativeBuildInputs = [
75+
zlib
76+
openssl
77+
stdenv.cc.cc.lib
78+
] ++ lib.optionals (!isDarwin) [ autoPatchelfHook ];
8479
phases = [
8580
"installPhase"
8681
"postFixupHooks"
@@ -93,18 +88,22 @@
9388
find $out/bin -type f -exec chmod +x {} +
9489
'';
9590
};
96-
toExportStyle = attrset:
97-
"\n" + (lib.concatMapAttrsStringSep "\n" (name: value: "export ${name}=\"${value}\"") attrset) + "\n";
98-
mkEnv = package:
91+
toExportStyle =
92+
attrset:
93+
"\n"
94+
+ (lib.concatMapAttrsStringSep "\n" (name: value: "export ${name}=\"${value}\"") attrset)
95+
+ "\n";
96+
mkEnv =
97+
package:
9998
builtins.listToAttrs (
10099
builtins.map (c: {
101100
name = c.env;
102101
value = "${package}/${c.path}";
103-
})
104-
componentsToFetch
102+
}) componentsToFetch
105103
);
106104
env = mkEnv package;
107-
in {
105+
in
106+
{
108107
inherit package env;
109108
shellHook = toExportStyle env;
110109
}

0 commit comments

Comments
 (0)