-
Notifications
You must be signed in to change notification settings - Fork 0
/
tauri-app.nix
113 lines (99 loc) · 3.81 KB
/
tauri-app.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
{ inputs, ... }:
{
perSystem = { inputs', pkgs, lib, self', system, ... }:
let
tauriConfig =
builtins.fromJSON (builtins.readFile ./src-tauri/tauri.conf.json);
cargoToml = builtins.fromTOML (builtins.readFile ./src-tauri/Cargo.toml);
pname = cargoToml.package.name;
version = tauriConfig.version;
craneLib = (inputs.holonix.inputs.crane.mkLib pkgs).overrideToolchain
inputs'.holonix.packages.rust;
src = inputs.p2p-shipyard.outputs.lib.cleanTauriSource { inherit lib; }
(craneLib.path ./.);
ui = pkgs.stdenv.mkDerivation (finalAttrs: {
inherit version;
pname = "${pname}-ui";
pnpmWorkspace = "ui";
src =
(inputs.tnesh-stack.outputs.lib.cleanPnpmDepsSource { inherit lib; })
./.;
nativeBuildInputs =
with inputs.tnesh-stack.inputs.pnpmnixpkgs.outputs.legacyPackages.${system}; [
nodejs
pnpm.configHook
git
];
pnpmDeps =
inputs.tnesh-stack.inputs.pnpmnixpkgs.outputs.legacyPackages.${system}.pnpm.fetchDeps {
inherit (finalAttrs) pnpmWorkspace version pname src;
hash = "sha256-mZfJwjdA70wLsjgBIH5+bOq0pkY3AkWTMienq4YkjxU=";
buildInputs = [ pkgs.git ];
};
buildPhase = ''
runHook preBuild
pnpm --filter=ui build
runHook postBuild
mkdir $out
cp -R ui/dist $out
'';
});
commonArgs = {
inherit pname version src;
doCheck = false;
cargoBuildCommand =
"cargo build --bins --release --locked --features tauri/custom-protocol,tauri/native-tls";
cargoCheckCommand = "";
cargoExtraArgs = "";
buildInputs =
inputs.p2p-shipyard.outputs.dependencies.${system}.tauriHapp.buildInputs
++ (lib.optionals pkgs.stdenv.isLinux [ pkgs.udev ]);
nativeBuildInputs =
inputs.p2p-shipyard.outputs.dependencies.${system}.tauriHapp.nativeBuildInputs;
postPatch = ''
mkdir -p "$TMPDIR/nix-vendor"
cp -Lr "$cargoVendorDir" -T "$TMPDIR/nix-vendor"
sed -i "s|$cargoVendorDir|$TMPDIR/nix-vendor/|g" "$TMPDIR/nix-vendor/config.toml"
chmod -R +w "$TMPDIR/nix-vendor"
cargoVendorDir="$TMPDIR/nix-vendor"
'';
stdenv = if pkgs.stdenv.isDarwin then
pkgs.overrideSDK pkgs.stdenv "11.0"
else
pkgs.stdenv;
};
#cargoArtifacts = craneLib.buildDepsOnly commonArgs;
tauriApp = craneLib.buildPackage (commonArgs // {
#inherit cargoArtifacts;
cargoBuildCommand = ''
if [ -f "src-tauri/tauri.conf.json" ]; then
substituteInPlace src-tauri/tauri.conf.json \
--replace-fail '"frontendDist": "../ui/dist"' '"frontendDist": "${ui}/dist"' \
--replace-fail '"beforeBuildCommand": "pnpm -F ui build",' '"beforeBuildCommand": "",'
cp ${self'.packages.messenger_demo_happ} workdir/messenger-demo.happ
cp ${self'.packages.messenger_demo_dna.hash} workdir/messenger_demo_dna-hash
fi
${commonArgs.cargoBuildCommand}'';
});
in rec {
packages = {
inherit ui;
messenger-demo = pkgs.runCommandNoCC "messenger-demo" {
buildInputs = [ pkgs.makeWrapper ];
} ''
mkdir $out
mkdir $out/bin
# Because we create this ourself, by creating a wrapper
makeWrapper ${tauriApp}/bin/messenger-demo $out/bin/messenger-demo \
--set WEBKIT_DISABLE_DMABUF_RENDERER 1
'';
};
apps.default.program = pkgs.writeShellApplication {
name = "${pname}-${version}";
runtimeInputs = [ packages.messenger-demo ];
text = ''
messenger-demo
'';
};
};
}