|
14 | 14 | binaryTarget, |
15 | 15 | hash, |
16 | 16 | components, |
17 | | -}: let |
| 17 | +}: |
| 18 | +let |
18 | 19 | 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 | + ]; |
46 | 45 | 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}"; |
51 | 47 | toUrl = url: "https://binaries.prisma.sh/all_commits/${commit}/${target}/${url}"; |
52 | 48 | 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 | + ''; |
73 | 70 | package = stdenv.mkDerivation { |
74 | 71 | pname = "prisma-bin"; |
75 | 72 | src = deps; |
76 | 73 | 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 ]; |
84 | 79 | phases = [ |
85 | 80 | "installPhase" |
86 | 81 | "postFixupHooks" |
|
93 | 88 | find $out/bin -type f -exec chmod +x {} + |
94 | 89 | ''; |
95 | 90 | }; |
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: |
99 | 98 | builtins.listToAttrs ( |
100 | 99 | builtins.map (c: { |
101 | 100 | name = c.env; |
102 | 101 | value = "${package}/${c.path}"; |
103 | | - }) |
104 | | - componentsToFetch |
| 102 | + }) componentsToFetch |
105 | 103 | ); |
106 | 104 | env = mkEnv package; |
107 | | -in { |
| 105 | +in |
| 106 | +{ |
108 | 107 | inherit package env; |
109 | 108 | shellHook = toExportStyle env; |
110 | 109 | } |
0 commit comments