-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
79 lines (67 loc) · 2.56 KB
/
flake.nix
File metadata and controls
79 lines (67 loc) · 2.56 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
{
description = "debug-browser: React debugging CLI with headless browser introspection";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
crane.url = "github:ipetkov/crane";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, crane, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
craneLib = crane.mkLib pkgs;
# --- Derivation 1: Node.js daemon ---
daemon = pkgs.buildNpmPackage {
pname = "debug-browser-daemon";
version = "0.1.0";
src = ./daemon;
npmDeps = pkgs.importNpmLock {
npmRoot = ./daemon;
};
npmConfigHook = pkgs.importNpmLock.npmConfigHook;
# DO NOT set dontNpmBuild -- we need npm run build (tsc + copy scripts)
# TypeScript is in devDependencies and buildNpmPackage installs them during build
installPhase = ''
runHook preInstall
mkdir -p $out/lib/daemon
cp -r dist $out/lib/daemon/dist
cp -r node_modules $out/lib/daemon/node_modules
cp package.json $out/lib/daemon/package.json
runHook postInstall
'';
};
# --- Derivation 2: Rust CLI ---
commonArgs = {
src = craneLib.cleanCargoSource ./.;
strictDeps = true;
buildInputs = pkgs.lib.optionals pkgs.stdenv.isDarwin [
pkgs.libiconv
];
};
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
cli = craneLib.buildPackage (commonArgs // {
inherit cargoArtifacts;
});
# --- Derivation 3: Composed wrapper ---
wrapperArgs = [
"--prefix PATH : ${pkgs.lib.makeBinPath [ pkgs.nodejs ]}"
"--set DEBUG_BROWSER_DAEMON_PATH ${daemon}/lib/daemon/dist/daemon.js"
] ++ pkgs.lib.optionals pkgs.stdenv.isLinux [
"--set PLAYWRIGHT_BROWSERS_PATH ${pkgs.playwright-driver.browsers}"
"--set PLAYWRIGHT_SKIP_VALIDATE_HOST_REQUIREMENTS true"
];
in {
packages.default = pkgs.symlinkJoin {
name = "debug-browser-${cli.version or "0.1.0"}";
paths = [ cli ];
nativeBuildInputs = [ pkgs.makeWrapper ];
postBuild = ''
wrapProgram $out/bin/debug-browser \
${builtins.concatStringsSep " \\\n " wrapperArgs}
'';
};
devShells.default = craneLib.devShell {
packages = with pkgs; [ nodejs ];
};
});
}