Allow building prisma-engines from source via nixpkgs derivation#32
Allow building prisma-engines from source via nixpkgs derivation#32Jakoma02 wants to merge 4 commits intoVanCoding:mainfrom
Conversation
|
Hi @Jakoma02 Thanks for taking the time to make this PR! I can see why you would want to add it, since apart from fetching & patching the binaries we also have code that can detect the engines version from various lockfiles (which is the part you're interested in here). As an alternative, nix-prisma-utils could probably also just expose these library functions for outside use, so that the rest can be handled in a separate flake. What makes me hesitate is that supporting building arbitrary versions of prisma-engines is a much harder task than just patching them. The demand for building from source probably is also smaller. This doesn't mean I'm completely against accepting this, but I think I need a bit more "convincing" work first :D |
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