Skip to content
This repository was archived by the owner on Feb 19, 2026. It is now read-only.

Commit c183cc1

Browse files
committed
fix(flake): able to run gui
1 parent a91346d commit c183cc1

File tree

3 files changed

+97
-33
lines changed

3 files changed

+97
-33
lines changed

README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,31 @@ bms-resource-toolbox/
8888

8989
## Development
9090

91+
This project includes automatic Nix integration using rust-overlay for a consistent and up-to-date development environment.
92+
93+
### Quick Setup
94+
95+
#### With Nix (Recommended)
96+
```bash
97+
# Enter development environment (includes all dependencies)
98+
nix develop
99+
100+
# Build the project
101+
cargo build
102+
103+
# Run tests
104+
cargo test
105+
```
106+
107+
#### Without Nix
108+
```bash
109+
# Ensure LIBCLANG_PATH is set for bindgen
110+
export LIBCLANG_PATH=/path/to/llvm/lib
111+
112+
# Build the project
113+
cargo build
114+
```
115+
91116
### Run Tests
92117

93118
```bash
@@ -106,6 +131,20 @@ cargo run --example basic_usage
106131
cargo build --release
107132
```
108133

134+
### Cursor IDE Integration
135+
136+
This project includes Cursor rules for enhanced development experience:
137+
138+
- **Nix Integration**: Automatic Nix environment detection
139+
- **Rust Development**: Common cargo commands and workflows
140+
- **BMS Project**: Project-specific knowledge and workflows
141+
142+
Rules are located in `.cursor/rules/` and provide contextual assistance for:
143+
- Development environment setup
144+
- Build and test commands
145+
- BMS-specific workflows
146+
- Project structure understanding
147+
109148
## Dependencies
110149

111150
- **smol**: Async runtime

flake.lock

Lines changed: 25 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,36 @@
44
inputs = {
55
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
66
flake-utils.url = "github:numtide/flake-utils";
7+
rust-overlay = {
8+
url = "github:oxalica/rust-overlay";
9+
inputs.nixpkgs.follows = "nixpkgs";
10+
};
711
};
812

9-
outputs = { self, nixpkgs, flake-utils }:
10-
flake-utils.lib.eachDefaultSystem (system:
13+
outputs =
14+
{
15+
self,
16+
nixpkgs,
17+
flake-utils,
18+
rust-overlay,
19+
}:
20+
flake-utils.lib.eachDefaultSystem (
21+
system:
1122
let
12-
pkgs = nixpkgs.legacyPackages.${system};
23+
overlays = [
24+
# Rust
25+
(final: prev: {
26+
rust-bin = rust-overlay.lib.mkRustBin { distRoot = "https://rsproxy.cn/dist"; } prev;
27+
})
28+
];
29+
pkgs = import nixpkgs {
30+
inherit system overlays;
31+
};
1332

1433
# System dependencies for unrar and other libraries
1534
buildInputs = with pkgs; [
16-
# Core build tools
17-
rustc
18-
cargo
19-
rust-analyzer
20-
rustfmt
21-
clippy
35+
# Rust toolchain from rust-overlay
36+
pkgs.rust-bin.stable.latest.complete
2237

2338
# C/C++ build tools for native dependencies
2439
clang
@@ -33,25 +48,17 @@
3348
gcc
3449
gcc-unwrapped
3550

36-
# GUI/X11 libraries for iced applications
51+
# Essential GUI libraries for iced applications
3752
xorg.libX11
3853
xorg.libXcursor
3954
xorg.libXrandr
4055
xorg.libXi
41-
xorg.libXext
42-
xorg.libXfixes
43-
xorg.libXrender
44-
xorg.libXinerama
45-
xorg.libXft
46-
xorg.libXcomposite
47-
xorg.libXdamage
48-
xorg.libXtst
49-
xorg.libXScrnSaver
5056

5157
# Wayland libraries
5258
wayland
5359
wayland-protocols
5460
libxkbcommon
61+
xkeyboard_config
5562

5663
# Additional libraries that might be needed
5764
openssl
@@ -64,7 +71,6 @@
6471
libGL
6572
libglvnd
6673
mesa
67-
libdrm
6874
];
6975

7076
# Native build inputs for linking
@@ -86,14 +92,12 @@
8692
export LIBCLANG_PATH="${pkgs.llvmPackages.libclang.lib}/lib"
8793
export LD_LIBRARY_PATH="${pkgs.llvmPackages.libclang.lib}/lib:$LD_LIBRARY_PATH"
8894
89-
# GUI application library paths for Hyprland/Wayland
90-
export LD_LIBRARY_PATH="${pkgs.libGL}/lib:${pkgs.fontconfig}/lib:${pkgs.freetype}/lib:$LD_LIBRARY_PATH"
91-
92-
# Don't override existing display environment variables in Hyprland
93-
# Let the native Hyprland/Wayland environment take precedence
95+
# Essential GUI library paths including Wayland
96+
export LD_LIBRARY_PATH="${pkgs.wayland}/lib:${pkgs.libxkbcommon}/lib:${pkgs.libGL}/lib:${pkgs.fontconfig}/lib:${pkgs.freetype}/lib:$LD_LIBRARY_PATH"
97+
export XKB_CONFIG_ROOT="${pkgs.xkeyboard_config}/share/X11/xkb"
9498
95-
echo "GUI libraries loaded. Ready for Hyprland/Wayland environment."
96-
echo "Run: cargo run --bin bms-resource-toolbox-gui"
99+
echo "Ready to run GUI application."
100+
echo "Run: cargo run"
97101
'';
98102
in
99103
{
@@ -103,12 +107,12 @@
103107

104108
# Environment variables for Rust development
105109
env = {
106-
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
110+
RUST_SRC_PATH = "${pkgs.rust-bin.stable.latest.complete}/lib/rustlib/src/rust/library";
107111
};
108112
};
109113

110114
# Formatter for nix files
111-
formatter = pkgs.nixpkgs-fmt;
115+
formatter = pkgs.nixfmt-tree;
112116
}
113117
);
114118
}

0 commit comments

Comments
 (0)