forked from QwikDev/qwik
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
67 lines (61 loc) · 2.41 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# This is a Nix configuration file. It is used to define the environment
# for the project. It is a declarative way to define the dependencies.
# It is used by the `nix develop` command to create a development environment
# with all the dependencies needed for the project.
# To update the dependencies, run `nix flake update`.
# Note: keep the playwright version in package.json syncpack the same as the nix version
# We don't need to have the latest playwright all the time so not having to download
# all the browsers on every version bump is a good thing.
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
rust-overlay.url = "github:oxalica/rust-overlay";
};
outputs = { self, rust-overlay, nixpkgs }:
let
b = builtins;
devShell = system: _pkgs:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs {
inherit system overlays;
};
in
{
default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
bashInteractive
gitMinimal
nodejs_20
corepack_20
# Playwright for the end-to-end tests
playwright-driver.browsers
# Qwik optimizer deps
wasm-pack
# Provides rustc and cargo
((rust-bin.fromRustupToolchainFile
./rust-toolchain).override {
# For rust-analyzer
extensions = [ "rust-src" ];
# For building wasm
targets = [ "wasm32-unknown-unknown" ];
})
];
# https://github.com/microsoft/playwright/issues/5501
shellHook = ''
export PATH=$PWD/node_modules/.bin:$PATH
export PLAYWRIGHT_BROWSERS_PATH=${pkgs.playwright-driver.browsers}
export PLAYWRIGHT_SKIP_VALIDATE_HOST_REQUIREMENTS=true
pwNixVersion=${pkgs.playwright-driver.version}
pwNpmVersion=$(${pkgs.jq}/bin/jq -r .version node_modules/@playwright/test/package.json 2>/dev/null)
if [ -n "$pwNpmVersion" ] && [ "$pwNpmVersion" != "$pwNixVersion" ]; then
echo "!!! Playwright version mismatch: $pwNpmVersion (nodejs) != $pwNixVersion (nix). Please fix." >&2
fi
'';
};
};
in
{
devShells = b.mapAttrs (devShell) nixpkgs.legacyPackages;
};
}