Skip to content

Commit

Permalink
nix: fix and update flake (#4224)
Browse files Browse the repository at this point in the history
- Update the Nix flake to get new things (especially newer Node.js and pnpm, current pnpm version was older than what driver-adapters required)
- Switch from Node.js 18 to Node.js 20 to match .nvmrc
- Fix the flake after updating to latest nixpkgs due to changes in cargo-auditable. The problem was that we were overriding cargo and rustc packages using our own overlay on top of rust-overlay, but the packages from rust-overlay do not accept the same arguments as those in nixpkgs. That's probably the reason why rust-overlay doesn't do that and defines new packages instead. The `rustToolchain` package we were defining was fine but I moved it to module arguments instead and got rid of the overlay completely.
- Add a way to opt-out of nix for gitpod
  • Loading branch information
aqrln authored Sep 13, 2023
1 parent 6ff772f commit f4104c0
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 47 deletions.
4 changes: 3 additions & 1 deletion .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ fi

# Set up env vars and build inputs from flake.nix automatically for nix users.
# If you don't use nix, you can safely ignore this.
if command -v nix &> /dev/null
# You can set the DISABLE_NIX environment variable if you're in an environment
# where nix is pre-installed (e.g. gitpod) but you don't want to use it.
if command -v nix &> /dev/null && [ -z ${DISABLE_NIX+x} ]
then
if nix flake metadata > /dev/null; then
if type nix_direnv_watch_file &> /dev/null; then
Expand Down
24 changes: 12 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 18 additions & 18 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 8 additions & 5 deletions nix/all-engines.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ pkgs, flakeInputs, lib, self', ... }:
{ pkgs, flakeInputs, lib, self', rustToolchain, ... }:

let
stdenv = pkgs.clangStdenv;
Expand All @@ -15,7 +15,7 @@ let
src = srcPath;
name = "prisma-engines-source";
};
craneLib = flakeInputs.crane.mkLib pkgs;
craneLib = (flakeInputs.crane.mkLib pkgs).overrideToolchain rustToolchain.default;
deps = craneLib.vendorCargoDeps { inherit src; };
libSuffix = stdenv.hostPlatform.extensions.sharedLibrary;
in
Expand All @@ -34,6 +34,7 @@ in
] ++ lib.optionals stdenv.isDarwin [
perl # required to build openssl
darwin.apple_sdk.frameworks.Security
iconv
];

configurePhase = ''
Expand All @@ -53,13 +54,15 @@ in
cp target/release/prisma-fmt $out/bin/
cp target/release/libquery_engine${libSuffix} $out/lib/libquery_engine.node
'';

dontStrip = true;
};

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

buildPhase = "cargo build --profile=${profile} --bin=test-cli";

Expand All @@ -76,7 +79,7 @@ in
({ profile }: stdenv.mkDerivation {
name = "query-engine-bin";
inherit src;
inherit (self'.packages.prisma-engines) buildInputs nativeBuildInputs configurePhase;
inherit (self'.packages.prisma-engines) buildInputs nativeBuildInputs configurePhase dontStrip;

buildPhase = "cargo build --profile=${profile} --bin=query-engine";

Expand All @@ -96,7 +99,7 @@ in
({ profile }: stdenv.mkDerivation {
name = "query-engine-bin-and-lib";
inherit src;
inherit (self'.packages.prisma-engines) buildInputs nativeBuildInputs configurePhase;
inherit (self'.packages.prisma-engines) buildInputs nativeBuildInputs configurePhase dontStrip;

buildPhase = ''
cargo build --profile=${profile} --bin=query-engine
Expand Down
10 changes: 5 additions & 5 deletions nix/args.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
let
overlays = [
flakeInputs.rust-overlay.overlays.default
(self: super:
let toolchain = super.rust-bin.stable.latest; in
{ cargo = toolchain.minimal; rustc = toolchain.minimal; rustToolchain = toolchain; })
];
in
{ pkgs = import flakeInputs.nixpkgs { inherit system overlays; }; };
in rec
{
pkgs = import flakeInputs.nixpkgs { inherit system overlays; };
rustToolchain = pkgs.rust-bin.stable.latest;
};
}
11 changes: 6 additions & 5 deletions nix/shell.nix
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
{ self', pkgs, ... }:
{ self', pkgs, rustToolchain, ... }:

let
devToolchain = pkgs.rustToolchain.default.override { extensions = [ "rust-analyzer" "rust-src" ]; };
devToolchain = rustToolchain.default.override { extensions = [ "rust-analyzer" "rust-src" ]; };
nodejs = pkgs.nodejs_latest;
in
{
devShells.default = pkgs.mkShell {
packages = [
devToolchain
pkgs.llvmPackages_latest.bintools

pkgs.nodejs
pkgs.nodePackages.typescript-language-server
pkgs.nodePackages.pnpm
nodejs
nodejs.pkgs.typescript-language-server
nodejs.pkgs.pnpm
];
inputsFrom = [ self'.packages.prisma-engines ];
shellHook = pkgs.lib.optionalString pkgs.stdenv.isLinux
Expand Down
2 changes: 1 addition & 1 deletion prisma-schema-wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ edition = "2021"
crate-type = ["cdylib"]

[dependencies]
wasm-bindgen = "=0.2.84"
wasm-bindgen = "=0.2.87"
wasm-logger = { version = "0.2.0", optional = true }
prisma-fmt = { path = "../prisma-fmt" }

0 comments on commit f4104c0

Please sign in to comment.