Skip to content

Commit

Permalink
nix: add query-engine-bin, test-cli derivations (prisma#3634)
Browse files Browse the repository at this point in the history
These have overridable cargo profiles are specific to one binary, making
them a lot faster to compile than the full prisma-engines derivation.

This is useful for things like check scripts (wip).
  • Loading branch information
tomhoule authored Jan 31, 2023
1 parent 72a1092 commit 2160401
Showing 1 changed file with 46 additions and 3 deletions.
49 changes: 46 additions & 3 deletions nix/all-engines.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{ pkgs, flakeInputs, lib, ... }:
{ pkgs, flakeInputs, lib, self', ... }:

let
stdenv = pkgs.clangStdenv;
srcPath = ../.;
srcFilter = flakeInputs.gitignore.lib.gitignoreFilterWith {
basePath = srcPath;
Expand All @@ -16,11 +17,11 @@ let
};
craneLib = flakeInputs.crane.mkLib pkgs;
deps = craneLib.vendorCargoDeps { inherit src; };
libSuffix = if pkgs.stdenv.isDarwin then "dylib" else "so";
libSuffix = if stdenv.isDarwin then "dylib" else "so";
in
{
packages.prisma-engines-deps = deps;
packages.prisma-engines = pkgs.stdenv.mkDerivation {
packages.prisma-engines = stdenv.mkDerivation {
name = "prisma-engines";
inherit src;

Expand Down Expand Up @@ -52,4 +53,46 @@ in
cp target/release/libquery_engine.${libSuffix} $out/lib/libquery_engine.node
'';
};

packages.test-cli = lib.makeOverridable
({ profile }: stdenv.mkDerivation {
name = "test-cli";
inherit src;
inherit (self'.packages.prisma-engines) buildInputs nativeBuildInputs;

buildPhase = ''
mkdir .cargo
ln -s ${deps}/config.toml .cargo/config.toml
cargo build --profile=${profile} --bin=test-cli
'';

installPhase = ''
set -eu
mkdir -p $out/bin
QE_PATH=$(find target -name 'test-cli')
cp $QE_PATH $out/bin
'';
})
{ profile = "release"; };

packages.query-engine-bin = lib.makeOverridable
({ profile }: stdenv.mkDerivation {
name = "query-engine-bin";
inherit src;
inherit (self'.packages.prisma-engines) buildInputs nativeBuildInputs;

buildPhase = ''
mkdir .cargo
ln -s ${deps}/config.toml .cargo/config.toml
cargo build --profile=${profile} --bin=query-engine
'';

installPhase = ''
set -eu
mkdir -p $out/bin
QE_PATH=$(find target -name 'query-engine')
cp $QE_PATH $out/bin
'';
})
{ profile = "release"; };
}

0 comments on commit 2160401

Please sign in to comment.