-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathflake.nix
More file actions
89 lines (82 loc) · 3.19 KB
/
Copy pathflake.nix
File metadata and controls
89 lines (82 loc) · 3.19 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
80
81
82
83
84
85
86
87
88
89
{
description = "Semantic diff layer for code review";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
outputs =
{ self, nixpkgs }:
let
# Linux-only: the package hard-depends on webkitgtk/gtk3.
systems = [
"x86_64-linux"
"aarch64-linux"
];
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f nixpkgs.legacyPackages.${system});
diffCoreFor = pkgs: pkgs.callPackage ./default.nix { };
diffCoreWebFor = pkgs: pkgs.callPackage ./default.nix { webMode = true; };
in
{
packages = forAllSystems (pkgs: rec {
diff-core = diffCoreFor pkgs;
diffcore-web = diffCoreWebFor pkgs;
default = diff-core;
});
# The three modes: `nix run .#cli|desktop|web`
apps = forAllSystems (
pkgs:
let
pkg = diffCoreFor pkgs;
app = program: {
type = "app";
program = "${pkg}/bin/${program}";
};
in
rec {
cli = app "diffcore";
desktop = app "diffcore-tauri";
web = {
type = "app";
program = "${diffCoreWebFor pkgs}/bin/diffcore-web";
};
default = desktop;
}
);
devShells = forAllSystems (pkgs: {
default = pkgs.mkShell {
inputsFrom = [ (diffCoreFor pkgs) ];
packages = [
pkgs.clippy
pkgs.rustfmt
pkgs.sccache
pkgs.mold
pkgs.rustfmt
pkgs.clippy
pkgs.nodejs
pkgs.playwright-driver.browsers
];
RUSTC_WRAPPER = "sccache";
# Playwright browsers come from nixpkgs, never from npm's downloader:
# the downloaded builds are not patched for NixOS and die on launch.
# `@playwright/test` in crates/diffcore-tauri/ui/package.json is pinned
# to exactly this driver's version — a mismatch makes playwright look
# for a browser revision these browsers do not contain.
PLAYWRIGHT_BROWSERS_PATH = pkgs.playwright-driver.browsers;
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD = "1";
shellHook = ''
export RUSTFLAGS="''${RUSTFLAGS:-} -Clink-arg=-fuse-ld=mold"
# Nothing else couples these two, so a nixpkgs bump would silently
# reintroduce the browser-revision mismatch this setup exists to fix.
# Resolved from the repo root, not $PWD, so entering the shell from a
# subdirectory does not fire a bogus warning.
_root=$(${pkgs.git}/bin/git rev-parse --show-toplevel 2>/dev/null || true)
_pj="$_root/crates/diffcore-tauri/ui/package.json"
if [ -n "$_root" ] && [ -f "$_pj" ]; then
_pinned=$(${pkgs.jq}/bin/jq -r '.devDependencies."@playwright/test"' "$_pj")
if [ "$_pinned" != "${pkgs.playwright-driver.version}" ]; then
echo "warning: @playwright/test is $_pinned but nixpkgs playwright-driver is ${pkgs.playwright-driver.version};" >&2
echo " E2E browsers will not match. Repin package.json to ${pkgs.playwright-driver.version}." >&2
fi
fi
'';
};
});
};
}