-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
166 lines (135 loc) · 4.69 KB
/
flake.nix
File metadata and controls
166 lines (135 loc) · 4.69 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
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
{
description = "Dioxus development environment";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
rust-overlay.url = "github:oxalica/rust-overlay";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, rust-overlay, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs {
inherit system overlays;
};
rustToolchain = pkgs.rust-bin.stable.latest.default.override {
extensions = [ "rust-src" "rust-analyzer" ];
targets = [ "wasm32-unknown-unknown" ];
};
# Platform-specific packages
darwinPackages = with pkgs; lib.optionals stdenv.isDarwin [
apple-sdk_15
];
linuxPackages = with pkgs; lib.optionals stdenv.isLinux [
# For web/desktop rendering
webkitgtk
gtk3
libsoup
# X11 dependencies
xorg.libX11
xorg.libXcursor
xorg.libXrandr
xorg.libXi
];
cargoOutputHashes = {
"iroh-proxy-utils-0.1.0" = "sha256-tI26vv7fvNR18KsUJvBTXZ0c7Wc/63Qq88NAWuWMoHs=";
"dioxus-primitives-0.0.1" = "sha256-tI26vv7fvNR18KsUJvBTXZ0c7Wc/63Qq88NAWuWMoHs=";
};
in
{
packages.default = pkgs.rustPlatform.buildRustPackage {
pname = "datum-connect";
version = "0.1.0";
src = ./.;
cargoLock = {
lockFile = ./Cargo.lock;
outputHashes = cargoOutputHashes;
};
nativeBuildInputs = with pkgs; [
pkg-config
];
buildInputs = with pkgs; [
openssl
] ++ lib.optionals stdenv.isDarwin [
libiconv
];
cargoBuildFlags = [ "--workspace" ];
doCheck = false; # tests require network (iroh STUN/relay); run with `cargo test` locally
meta = with pkgs.lib; {
description = "Datum Connect - A tunneling solution built on iroh";
homepage = "https://github.com/datum-cloud/datum-connect";
license = licenses.agpl3Only;
maintainers = [ ];
};
};
packages.cli = pkgs.rustPlatform.buildRustPackage {
pname = "datum-connect-cli";
version = "0.1.0";
src = ./.;
cargoLock = {
lockFile = ./Cargo.lock;
outputHashes = cargoOutputHashes;
};
nativeBuildInputs = with pkgs; [
pkg-config
];
buildInputs = with pkgs; [
openssl
] ++ lib.optionals stdenv.isDarwin [
libiconv
];
cargoBuildFlags = [ "-p" "datum-connect" ];
doCheck = false; # tests require network (iroh STUN/relay); run with `cargo test` locally
meta = with pkgs.lib; {
description = "Datum Connect CLI";
mainProgram = "datum-connect";
};
};
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
# Rust toolchain with WASM support
rustToolchain
# Dioxus CLI for hot reloading and bundling
dioxus-cli
# Build tools
pkg-config
openssl
# npm
nodejs
# For serving web apps locally
simple-http-server
# Useful tools
cargo-watch
cargo-edit
] ++ darwinPackages ++ linuxPackages;
# Environment variables
RUST_SRC_PATH = "${rustToolchain}/lib/rustlib/src/rust/library";
# For OpenSSL on macOS
PKG_CONFIG_PATH = "${pkgs.openssl.dev}/lib/pkgconfig";
shellHook = ''
echo "🚀 Dioxus development environment loaded"
echo " rustc: $(rustc --version)"
echo " cargo: $(cargo --version)"
echo " dx: $(dx --version 2>/dev/null || echo 'not found')"
echo ""
echo "Quick start:"
echo " dx new myapp # Create new project"
echo " dx serve # Start dev server with hot reload"
echo " dx build --release # Build for production"
'';
};
formatter = pkgs.nixpkgs-fmt;
apps.desktop = let
script = pkgs.writeShellScriptBin "desktop-app" ''
cd "$PWD/ui"
export DATUM_CONNECT_PUBLISH_TICKETS=1
export RUST_LOG=info,lib::heartbeat=debug,lib::tunnels=debug
exec ${pkgs.dioxus-cli}/bin/dx serve --platform desktop
'';
in {
type = "app";
program = "${script}/bin/desktop-app";
};
}
);
}