-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
144 lines (126 loc) · 5.59 KB
/
flake.nix
File metadata and controls
144 lines (126 loc) · 5.59 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
{
description = "Clojkstra — ClojureScript + re-frame starter template";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
# ---------------------------------------------------------------------------
# JDK — shadow-cljs requires a JVM to compile ClojureScript.
# JDK 21 (LTS) is used here; swap for pkgs.jdk17 if preferred.
# ---------------------------------------------------------------------------
jdk = pkgs.jdk21;
# ---------------------------------------------------------------------------
# Bun — the JS runtime used for all package management and script running.
# NEVER use npm or node directly; always use bun / bunx.
# ---------------------------------------------------------------------------
bun = pkgs.bun;
# Tauri v2 on Linux requires a set of system libraries for WebKit / GTK.
tauriLinuxDeps = with pkgs; [
pkg-config
gobject-introspection
gtk3
glib
gdk-pixbuf
pango
cairo
atk
webkitgtk_4_1 # WebKit2GTK 4.1 — required by Tauri v2
libsoup_3
openssl
libayatana-appindicator
librsvg
xdotool # optional but handy for window automation in tests
libx11
libxcursor
libxrandr
libxi
];
in
{
# ---------------------------------------------------------------------------
# devShell
#
# Enter with: nix develop
# Or, with direnv: echo "use flake" > .envrc && direnv allow
#
# Everything needed to build, run, test, and lint the project is
# available in this shell. No global installs required.
# ---------------------------------------------------------------------------
devShells.default = pkgs.mkShell {
name = "clojkstra-dev";
buildInputs = [
# --- Language runtimes ---
jdk
bun
# --- Rust toolchain (needed by cargo-tauri / src-tauri) ---
pkgs.rustc
pkgs.cargo
pkgs.rustfmt
pkgs.clippy
# --- Tauri CLI ---
pkgs.cargo-tauri
# --- Tauri system dependencies (Linux only) ---
] ++ (pkgs.lib.optionals pkgs.stdenv.isLinux tauriLinuxDeps) ++ [
# --- Utilities ---
pkgs.git
pkgs.curl # handy for quick API checks during development
pkgs.jq # JSON pretty-printing / querying
pkgs.clj-kondo # ClojureScript linter
pkgs.cljfmt # ClojureScript formatter
pkgs.just # task runner used by justfile
];
# Ensure the JVM used by shadow-cljs is the pinned one.
JAVA_HOME = jdk;
# pkg-config needs to find the Tauri system libs.
PKG_CONFIG_PATH = pkgs.lib.optionalString pkgs.stdenv.isLinux (
pkgs.lib.makeSearchPathOutput "dev" "lib/pkgconfig" tauriLinuxDeps
);
# GIO_MODULE_DIR is required by WebKit on some NixOS setups.
GIO_MODULE_DIR = pkgs.lib.optionalString pkgs.stdenv.isLinux
"${pkgs.glib-networking}/lib/gio/modules";
# Point Rust to OpenSSL headers so the openssl-sys crate compiles.
OPENSSL_DIR = pkgs.lib.optionalString pkgs.stdenv.isLinux
"${pkgs.openssl.dev}";
OPENSSL_LIB_DIR = pkgs.lib.optionalString pkgs.stdenv.isLinux
"${pkgs.openssl.out}/lib";
# Set a clear prompt so developers know they are in the Nix shell.
shellHook = ''
echo ""
echo " ⚡ Clojkstra dev shell ready"
echo ""
echo " Runtime versions:"
echo " java $(java -version 2>&1 | head -1)"
echo " bun $(bun --version)"
echo " rustc $(rustc --version)"
echo " cargo $(cargo --version)"
echo ""
echo " Available commands:"
echo " just dev — start shadow-cljs watch + dev server on :8080"
echo " just build — production ClojureScript build → docs/cljs-out/"
echo " just tauri-dev — start Tauri desktop app with hot reload"
echo " just tauri-build — build Tauri desktop app + installers"
echo " just tauri-info — show Tauri environment info"
echo " just lint — clj-kondo lint"
echo " just fmt — auto-fix ClojureScript formatting"
echo " just ci — lint + fmt-check + release build"
echo ""
# Install JS dependencies via bun if node_modules is absent.
# This is a no-op if bun.lock + node_modules are already up to date.
if [ ! -d node_modules ]; then
echo " → Running 'bun install' to hydrate node_modules…"
bun install
echo ""
fi
'';
};
# ---------------------------------------------------------------------------
# formatter — run with: nix fmt
# Uses nixpkgs-fmt to keep flake.nix itself consistently formatted.
# ---------------------------------------------------------------------------
formatter = pkgs.nixpkgs-fmt;
});
}