-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 8b492c2
Showing
14 changed files
with
469 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
use flake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
inputs.pkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; | ||
inputs.flake-utils.url = "github:numtide/flake-utils"; | ||
outputs = {pkgs, flake-utils, ...}: flake-utils.lib.eachDefaultSystem (system: let | ||
prisma-factory = import ./prisma.nix; | ||
nixpkgs = import pkgs {inherit system;}; | ||
in { | ||
lib = { inherit prisma-factory; }; | ||
packages = import ./tests.nix { | ||
inherit prisma-factory nixpkgs; | ||
}; | ||
devShells.default = let | ||
prisma = ((prisma-factory { | ||
inherit nixpkgs; | ||
prisma-fmt-hash = "sha256-4zsJv0PW8FkGfiiv/9g0y5xWNjmRWD8Q2l2blSSBY3s="; | ||
query-engine-hash = "sha256-6ILWB6ZmK4ac6SgAtqCkZKHbQANmcqpWO92U8CfkFzw="; | ||
libquery-engine-hash = "sha256-n9IimBruqpDJStlEbCJ8nsk8L9dDW95ug+gz9DHS1Lc="; | ||
schema-engine-hash = "sha256-j38xSXOBwAjIdIpbSTkFJijby6OGWCoAx+xZyms/34Q="; | ||
}).fromCommit "6a3747c37ff169c90047725a05a6ef02e32ac97e"); | ||
in nixpkgs.mkShell { | ||
buildInputs = [ | ||
nixpkgs.nodejs-18_x | ||
nixpkgs.nodePackages.pnpm | ||
nixpkgs.stdenv.cc.cc.lib | ||
prisma.package | ||
]; | ||
shellHook = prisma.shellHook; | ||
}; | ||
}); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "npm-test", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"@prisma/client": "^5.1.1", | ||
"prisma": "^5.1.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// This is your Prisma schema file, | ||
// learn more about it in the docs: https://pris.ly/d/prisma-schema | ||
|
||
generator client { | ||
provider = "prisma-client-js" | ||
} | ||
|
||
datasource db { | ||
provider = "sqlite" | ||
url = env("DATABASE_URL") | ||
} | ||
|
||
model User { | ||
id Int @id @default(autoincrement()) | ||
createdAt DateTime @default(now()) | ||
email String @unique | ||
name String? | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules | ||
# Keep environment variables out of version control | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "pnpm", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"@prisma/client": "5.1.1", | ||
"prisma": "^5.1.1" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// This is your Prisma schema file, | ||
// learn more about it in the docs: https://pris.ly/d/prisma-schema | ||
|
||
generator client { | ||
provider = "prisma-client-js" | ||
} | ||
|
||
datasource db { | ||
provider = "sqlite" | ||
url = env("DATABASE_URL") | ||
} | ||
|
||
model User { | ||
id Int @id @default(autoincrement()) | ||
createdAt DateTime @default(now()) | ||
email String @unique | ||
name String? | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
{ | ||
nixpkgs, | ||
openssl3 ? true, | ||
openssl ? nixpkgs.openssl, | ||
introspection-engine-hash?null, | ||
migration-engine-hash?null, | ||
prisma-fmt-hash, | ||
query-engine-hash, | ||
libquery-engine-hash, | ||
schema-engine-hash?null | ||
} : rec { | ||
fromCommit = commit : let | ||
hostname = "binaries.prisma.sh"; | ||
channel = "all_commits"; | ||
target = "debian-openssl-${if openssl3 then "3.0.x" else "1.1.x"}"; | ||
baseUrl = "https://${hostname}/${channel}"; | ||
files = [ | ||
{ name = "prisma-fmt"; hash=prisma-fmt-hash;path="bin/prisma-fmt"; variable = "PRISMA_FMT_BINARY"; } | ||
{ name = "query-engine"; hash=query-engine-hash;path="bin/query-engine"; variable = "PRISMA_QUERY_ENGINE_BINARY"; } | ||
{ name = "libquery_engine.so.node"; hash=libquery-engine-hash;path="lib/libquery_engine.node"; variable = "PRISMA_QUERY_ENGINE_LIBRARY"; } | ||
] ++ ( | ||
if introspection-engine-hash == null | ||
then [] | ||
else [{ name = "introspection-engine"; hash=introspection-engine-hash;path="bin/introspection-engine"; variable = "PRISMA_INTROSPECTION_ENGINE_BINARY"; }] | ||
) ++ ( | ||
if migration-engine-hash == null | ||
then [] | ||
else [{ name = "migration-engine"; hash=migration-engine-hash;path="bin/migration-engine"; 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: file // {file = nixpkgs.fetchurl { | ||
name = "${baseUrl}/${commit}/${target}/${file.name}.gz"; | ||
url = "${baseUrl}/${commit}/${target}/${file.name}.gz"; | ||
hash = file.hash; | ||
};}) files; | ||
unzipCommands = builtins.map (file: "gunzip -c ${file.file} > $out/${file.path}") downloadedFiles; | ||
exportCommands = package: builtins.map (file: "export ${file.variable}=${package}/${file.path}") files; | ||
in rec { | ||
package = nixpkgs.stdenv.mkDerivation { | ||
pname = "prisma-bin"; | ||
version = commit; | ||
nativeBuildInputs = [ | ||
nixpkgs.autoPatchelfHook | ||
nixpkgs.zlib | ||
openssl | ||
nixpkgs.stdenv.cc.cc.lib | ||
]; | ||
phases = ["buildPhase" "postFixupHooks" ]; | ||
buildPhase = '' | ||
mkdir -p $out/bin | ||
mkdir -p $out/lib | ||
${nixpkgs.lib.concatStringsSep "\n" unzipCommands} | ||
chmod +x $out/bin/* | ||
''; | ||
}; | ||
shellHook = nixpkgs.lib.concatStringsSep "\n" (exportCommands package); | ||
}; | ||
fromPnpmLock = path: let | ||
pnpmLock = builtins.readFile path; | ||
version = builtins.elemAt (builtins.split ":" (builtins.elemAt (builtins.split "engines-version/" pnpmLock) 2)) 0; | ||
commit = nixpkgs.lib.lists.last (nixpkgs.lib.strings.splitString "." version); | ||
in fromCommit commit; | ||
fromNpmLock = path: let | ||
packageLock = builtins.fromJSON (builtins.readFile path); | ||
version = if builtins.hasAttr "dependencies" packageLock | ||
then packageLock.dependencies.${"@prisma/engines-version"}.version | ||
else packageLock.packages.${"node_modules/@prisma/engines-version"}.version; | ||
commit = nixpkgs.lib.lists.last (nixpkgs.lib.strings.splitString "." version); | ||
in builtins.trace commit (fromCommit commit); | ||
} |
Oops, something went wrong.