-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
96 lines (83 loc) · 3.19 KB
/
flake.nix
File metadata and controls
96 lines (83 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
90
91
92
93
94
95
96
{
description = "ZipURL - URL shortening service with UTM tracking and Open Graph support";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=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;
};
in
{
devShells.default = with pkgs; mkShell {
buildInputs = [
# System dependencies
openssl
pkg-config
# Rust toolchain with rust-analyzer, clippy, and wasm32 target
((rust-bin.selectLatestNightlyWith
(toolchain: toolchain.default)).override {
extensions = [ "rust-analyzer" "rust-src" ];
targets = [ "wasm32-unknown-unknown" ];
})
# Development tools
cargo-watch # Auto-rebuild on file changes
cargo-edit # Cargo add/rm/upgrade commands
just # Justfile task runner
# CSS tooling
tailwindcss_4 # Tailwind CSS v4 CLI
];
# Environment variables for Rust development
RUST_BACKTRACE = "1";
RUST_SRC_PATH = "${pkgs.rust-bin.selectLatestNightlyWith (toolchain: toolchain.default)}/lib/rustlib/src/rust/library";
shellHook = ''
# Add ~/.cargo/bin to PATH for cargo-installed tools (cargo-leptos, wasm-bindgen-cli, leptosfmt)
export PATH="$HOME/.cargo/bin:$PATH"
# Configure Zed editor for Nix-managed Rust toolchain
mkdir -p .zed
# Create stable symlink to rust-analyzer
ln -sf $(command -v rust-analyzer) .zed/rust-analyzer
# Generate Zed settings.json if it doesn't exist
if [ ! -f .zed/settings.json ]; then
cat > .zed/settings.json <<'EOF'
{
"lsp": {
"rust-analyzer": {
"binary": {
"path": ".zed/rust-analyzer"
}
}
}
}
EOF
fi
# Add .zed/ to .gitignore if not already present
if [ -f .gitignore ] && ! grep -q '^\.zed/' .gitignore; then
echo '.zed/' >> .gitignore
fi
# Install leptosfmt if not already installed
if ! command -v leptosfmt &> /dev/null; then
echo "📦 Installing leptosfmt..."
cargo install leptosfmt
fi
echo "🔗 ZipURL development environment loaded"
echo ""
echo "🦀 Rust: $(rustc --version)"
echo "📊 Tools: cargo-watch, cargo-edit, just, leptosfmt"
echo ""
echo "💡 Quick start:"
echo " - List tasks: just --list"
echo " - Development: just dev"
echo " - Test: just test"
echo " - Format: just fmt"
echo " - Help: just help"
'';
};
}
);
}