forked from rainlanguage/rain.orderbook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
139 lines (113 loc) · 6.63 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
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
{
description = "Flake for development workflows.";
inputs = {
rainix.url = "github:rainprotocol/rainix/c0ec270110349723cc26dbceb8f56d5c8d5ce8b7";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = {self, flake-utils, rainix }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = rainix.pkgs.${system};
in rec {
packages = rec {
tauri-release-env = rainix.tauri-release-env.${system};
ob-tauri-prelude = rainix.mkTask.${system} {
name = "ob-tauri-prelude";
body = ''
set -euxo pipefail
# Generate Typescript types from rust types
mkdir -p tauri-app/src/lib/typeshare;
typeshare crates/subgraph/src/types/vault_balance_changes_list.rs --lang=typescript --output-file=tauri-app/src/lib/typeshare/vaultBalanceChangesList.ts;
typeshare crates/subgraph/src/types/vault_balance_change.rs --lang=typescript --output-file=/tmp/vaultBalanceChange.ts;
cat /tmp/vaultBalanceChange.ts >> tauri-app/src/lib/typeshare/vaultBalanceChangesList.ts;
typeshare crates/subgraph/src/types/order_detail.rs --lang=typescript --output-file=tauri-app/src/lib/typeshare/orderDetail.ts;
typeshare crates/common/src/types/order_detail_extended.rs --lang=typescript --output-file=/tmp/orderDetailExtended.ts
cat /tmp/orderDetailExtended.ts >> tauri-app/src/lib/typeshare/orderDetail.ts;
typeshare crates/subgraph/src/types/vault_detail.rs --lang=typescript --output-file=tauri-app/src/lib/typeshare/vaultDetail.ts;
typeshare crates/subgraph/src/types/vaults_list.rs --lang=typescript --output-file=tauri-app/src/lib/typeshare/vaultsList.ts;
typeshare crates/subgraph/src/types/orders_list.rs --lang=typescript --output-file=tauri-app/src/lib/typeshare/ordersList.ts;
typeshare crates/subgraph/src/types/order_takes_list.rs --lang=typescript --output-file=tauri-app/src/lib/typeshare/orderTakesList.ts;
typeshare crates/subgraph/src/types/order_take_detail.rs --lang=typescript --output-file=tauri-app/src/lib/typeshare/orderTakeDetail.ts;
typeshare crates/settings/src/parse.rs --lang=typescript --output-file=tauri-app/src/lib/typeshare/appSettings.ts;
typeshare tauri-app/src-tauri/src/toast.rs --lang=typescript --output-file=tauri-app/src/lib/typeshare/toast.ts;
typeshare tauri-app/src-tauri/src/transaction_status.rs --lang=typescript --output-file=tauri-app/src/lib/typeshare/transactionStatus.ts;
# Fix linting of generated types
cd tauri-app && npm i && npm run lint
'';
additionalBuildInputs = [
pkgs.typeshare
pkgs.wasm-bindgen-cli
rainix.rust-toolchain.${system}
rainix.rust-build-inputs.${system}
];
};
ob-tauri-test = rainix.mkTask.${system} {
name = "ob-tauri-test";
body = ''
set -euxo pipefail
cd tauri-app && npm i && npm run test
'';
};
ob-tauri-before-build = rainix.mkTask.${system} {
name = "ob-tauri-before-build";
body = ''
set -euxo pipefail
npm i && npm run build
rm -rf lib
mkdir -p lib
if [ ${if pkgs.stdenv.isDarwin then "1" else "0" } -eq 1 ]; then
cp ${pkgs.libiconv}/lib/libcharset.1.dylib lib/libcharset.1.dylib
chmod +w lib/libcharset.1.dylib
install_name_tool -id @executable_path/../Frameworks/libcharset.1.dylib lib/libcharset.1.dylib
otool -L lib/libcharset.1.dylib
cp ${pkgs.libiconv}/lib/libiconv-nocharset.dylib lib/libiconv-nocharset.dylib
chmod +w lib/libiconv-nocharset.dylib
install_name_tool -id @executable_path/../Frameworks/libiconv-nocharset.dylib lib/libiconv-nocharset.dylib
otool -L lib/libiconv-nocharset.dylib
cp ${pkgs.libiconv}/lib/libiconv.dylib lib/libiconv.dylib
chmod +w lib/libiconv.dylib
install_name_tool -id @executable_path/../Frameworks/libiconv.dylib lib/libiconv.dylib
install_name_tool -change ${pkgs.libiconv}/lib/libiconv-nocharset.dylib @executable_path/../Frameworks/libiconv-nocharset.dylib lib/libiconv.dylib
install_name_tool -change ${pkgs.libiconv}/lib/libcharset.1.dylib @executable_path/../Frameworks/libcharset.1.dylib lib/libiconv.dylib
otool -L lib/libiconv.dylib
cp ${pkgs.gettext}/lib/libintl.8.dylib lib/libintl.8.dylib
chmod +w lib/libintl.8.dylib
install_name_tool -id @executable_path/../Frameworks/libintl.8.dylib lib/libintl.8.dylib
install_name_tool -change ${pkgs.libiconv}/lib/libiconv.dylib @executable_path/../Frameworks/libiconv.dylib lib/libintl.8.dylib
otool -L lib/libintl.8.dylib
fi
'';
};
ob-tauri-before-bundle = rainix.mkTask.${system} {
name = "ob-tauri-before-bundle";
body = ''
set -euxo pipefail
ls src-tauri/target/release
if [ ${if pkgs.stdenv.isDarwin then "1" else "0" } -eq 1 ]; then
install_name_tool -change ${pkgs.libiconv}/lib/libiconv.dylib @executable_path/../Frameworks/libiconv.dylib src-tauri/target/release/Rain\ Orderbook
install_name_tool -change ${pkgs.gettext}/lib/libintl.8.dylib @executable_path/../Frameworks/libintl.8.dylib src-tauri/target/release/Rain\ Orderbook
otool -L src-tauri/target/release/Rain\ Orderbook
grep_exit_code=0
otool -L src-tauri/target/release/Rain\ Orderbook | grep -q /nix/store || grep_exit_code=$?
if [ $grep_exit_code -eq 0 ]; then
exit 1
fi
fi
'';
};
} // rainix.packages.${system};
devShells.default = rainix.devShells.${system}.default;
devShells.tauri-shell = pkgs.mkShell {
packages = [
packages.ob-tauri-prelude
packages.ob-tauri-test
packages.ob-tauri-before-build
packages.ob-tauri-before-bundle
];
shellHook = rainix.devShells.${system}.tauri-shell.shellHook;
buildInputs = rainix.devShells.${system}.tauri-shell.buildInputs ++ [pkgs.clang-tools];
nativeBuildInputs = rainix.devShells.${system}.tauri-shell.nativeBuildInputs;
};
}
);
}