Allow building prisma-engines from source via nixpkgs derivation #32
+569
−38
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR enables building
prisma-enginesfrom source using the Nixpkgs derivation instead of relying on prebuilt binaries. This is useful to me because I am trying to use prisma on thearmv7-linuxsystem, which is not officially supported by prisma (so there are no official prebuilt binaries for it), but it can be built successfully using the derivation in nixpkgs.Building from source can be enabled by using
prisma-factorylike this:Building from source works by using the
prisma-engines_6package in nixpkgs and overriding the source with the specified commit from GitHub, overriding the rust toolchain with the one specified in therust-toolchain.tomlfile in theprisma-enginessource code, and overriding cargo dependencies with ones specified in the source code. For overriding the rust toolchain, the oxalica/rust-overlay flake is used to obtain the toolchain corresponding to therust-toolchain.tomlfile. This is necessary because newer versions of prisma-engines might require a newer toolchain than the one present in nixpkgs.It must be noted that because the build process might vary between various versions of prisma, this approach is not always guaranteed to work and will only work for versions of prisma that successfully build using the nixpkgs derivation. Most notably, only major version 6 of prisma-engines is supported right now, as I do not have the bandwidth right now to fully test it for prisma-engines 7 which I am myself not using at the moment (nixpkgs has
prisma-engines_7, but it seems that it does not build all the components that are expected incomponents.nixand as is it will probably not work together with prisma 6).Because the tests for existing fetchers use version 5.1.1 of prisma-engines, and building from source is only supported for major version 6, it is not possible to use the same for lockfiles for testing. For this reason, I include the directory
pnpm-prisma-6, which contains a pnpm lockfile with prisma-engines 6.18.0, used to test building from source.Included Changes
prismaFromPkgs.nixprisma.nixto recognize and handleusePrismaFromPkgs = true;toExportStyleandmkEnvhelper function to a separate fileenv.nixrust-overlayas flake input and passedrust-binas an argument toprisma-factorypnpm-prisma-6with a pnpm package depending on prisma-engines 6.18.0pkgs.nodejs-18_xwithpkgs.nodejs_24