forked from Jesssullivan/XoxdWM
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
453 lines (388 loc) · 15.4 KB
/
flake.nix
File metadata and controls
453 lines (388 loc) · 15.4 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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
{
description = "EXWM-VR: VR-first transhuman Emacs window manager";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
emacs-overlay = {
url = "github:nix-community/emacs-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils.url = "github:numtide/flake-utils";
nix2container = {
url = "github:nlewo/nix2container";
inputs.nixpkgs.follows = "nixpkgs";
};
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
# VR hardware support (Monado, WiVRn, OpenComposite)
nixpkgs-xr = {
url = "github:nix-community/nixpkgs-xr";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, emacs-overlay, rust-overlay, flake-utils, nix2container, home-manager, nixpkgs-xr }:
let
version = "0.5.0";
# XR kernel module — patches + structured config for Bigscreen Beyond 2e
xrKernelLib = import ./nix/kernel/xr-kernel.nix;
# Shared helper: build the Wayland/DRM library list for any pkgs set
# (used by both the per-system block and the cross-compilation blocks)
mkWaylandLibs = pkgs: with pkgs; [
wayland
wayland-protocols
wayland-scanner
libdrm
libgbm
mesa
libinput
libxkbcommon
seatd
libffi
pixman
udev
];
# NixOS modules (not per-system)
nixosModuleOutputs = {
nixosModules = {
exwm-vr = import ./nix/modules/exwm-vr.nix;
monado = import ./nix/modules/monado.nix;
default = self.nixosModules.exwm-vr;
};
homeManagerModules = {
exwm-vr = import ./nix/home-manager/exwm-vr.nix;
default = self.homeManagerModules.exwm-vr;
};
# Kernel overlay: XR kernel patches for Bigscreen Beyond 2e + AMD DSC
#
# Uses nix/kernel/xr-kernel.nix for patches + structured config.
#
# Usage in NixOS config:
# nixpkgs.overlays = [ ewwm.overlays.kernel-beyond ];
# boot.kernelPackages = pkgs.linuxPackages_beyond;
overlays.kernel-beyond = final: prev:
let
kLib = xrKernelLib {
inherit (prev) lib linuxKernel fetchpatch fetchurl;
pkgs = prev;
};
in {
linuxPackages_beyond = prev.linuxPackages_latest.extend (lpSelf: lpPrev: {
kernel = kLib.mkXrKernel {
baseKernel = lpPrev.kernel;
};
});
};
};
# Per-system outputs
perSystemOutputs = flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [
emacs-overlay.overlays.default
rust-overlay.overlays.default
];
};
n2c = nix2container.packages.${system}.nix2container;
rustToolchain = pkgs.rust-bin.nightly.latest.default.override {
extensions = [
"rustc"
"cargo"
"clippy"
"rustfmt"
"rust-analyzer"
"rust-src"
];
};
emacsPkg = pkgs.emacs-pgtk.overrideAttrs (old: {
configureFlags = (old.configureFlags or [ ]) ++ [
"--with-native-compilation=aot"
];
});
waylandLibs = mkWaylandLibs pkgs;
buildInputs = with pkgs; [
# Rust
rustToolchain
pkg-config
clang
llvmPackages.libclang
# Emacs
emacsPkg
# Dev tools (cross-platform)
just
git-cliff
nixpkgs-fmt
direnv
cachix
dhall
]
# Wayland / VR deps (Linux only — not available on macOS)
++ lib.optionals stdenv.isLinux (waylandLibs ++ [
monado
openxr-loader
libuvc
cage # single-window Wayland compositor for testing
weston # headless Wayland compositor
]);
# Common function to build the compositor with given features
mkCompositor = { pname, features ? [ ], extraBuildInputs ? [ ] }:
pkgs.rustPlatform.buildRustPackage {
inherit pname version;
src = ./compositor;
cargoLock.lockFile = ./compositor/Cargo.lock;
nativeBuildInputs = with pkgs; [
pkg-config
clang
llvmPackages.libclang
];
buildInputs = waylandLibs ++ [ pkgs.libuvc ] ++ extraBuildInputs;
buildNoDefaultFeatures = (features == [ ]);
buildFeatures = features;
LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";
# Ensure linker can find all native libraries (mesa/gbm, etc.)
LIBRARY_PATH = pkgs.lib.makeLibraryPath (waylandLibs ++ [ pkgs.libuvc ] ++ extraBuildInputs);
meta = with pkgs.lib; {
description = "EXWM-VR Wayland compositor built on Smithay";
license = licenses.gpl3Plus;
platforms = platforms.linux;
};
};
in builtins.foldl' pkgs.lib.recursiveUpdate {} [
{
devShells.default = pkgs.mkShell {
inherit buildInputs;
shellHook = ''
export LIBCLANG_PATH="${pkgs.llvmPackages.libclang.lib}/lib"
export PKG_CONFIG_PATH="${pkgs.lib.makeSearchPathOutput "dev" "lib/pkgconfig" waylandLibs}"
export LD_LIBRARY_PATH="${pkgs.lib.makeLibraryPath waylandLibs}"
export XDG_DATA_DIRS="$XDG_DATA_DIRS:${pkgs.monado}/share"
export OPENXR_RUNTIME_JSON="${pkgs.monado}/share/openxr/1/openxr_monado.json"
echo "exwm-vr dev shell ready"
echo " rustc: $(rustc --version)"
echo " emacs: $(emacs --version | head -1)"
echo ""
echo " cachix: use 'cachix use exwm-vr' to enable binary cache"
'';
};
# BIOS analysis shell — Ghidra, UEFITool, binwalk for Dell firmware RE
devShells.bios-tools = pkgs.mkShell {
buildInputs = with pkgs; [
uefitool
binwalk
p7zip
] ++ lib.optionals stdenv.isLinux [
ghidra
];
shellHook = ''
echo "BIOS analysis shell ready"
echo " uefitool: available"
echo " binwalk: $(binwalk --version 2>/dev/null | head -1)"
echo " 7z: $(7z 2>&1 | head -2 | tail -1)"
echo ""
echo "Workflow:"
echo " 1. just bios-download"
echo " 2. just bios-extract"
echo " 3. uefitool packaging/bios/extracted/*.bin"
echo " 4. ghidra # import extracted UEFI modules"
'';
};
# Full compositor with VR support
packages.compositor = mkCompositor {
pname = "ewwm-compositor";
features = [ "full-backend" "vr" ];
extraBuildInputs = [ pkgs.openxr-loader ];
};
# Headless compositor (no full-backend, no VR) for s390x / minimal
packages.compositor-headless = mkCompositor {
pname = "ewwm-compositor-headless";
features = [ ];
};
# --- OCI container images via nix2container ---
packages.oci-headless = n2c.buildImage {
name = "ewwm-compositor-headless";
tag = "latest";
config = {
entrypoint = [ "${self.packages.${system}.compositor-headless}/bin/ewwm-compositor" ];
cmd = [ "--headless" ];
};
};
packages.oci-compositor = n2c.buildImage {
name = "ewwm-compositor";
tag = "latest";
config = {
entrypoint = [ "${self.packages.${system}.compositor}/bin/ewwm-compositor" ];
};
};
packages.oci-full = n2c.buildImage {
name = "ewwm-compositor-full";
tag = "latest";
copyToRoot = [ emacsPkg ];
config = {
entrypoint = [ "${self.packages.${system}.compositor}/bin/ewwm-compositor" ];
};
};
packages.default = self.packages.${system}.compositor;
# Elisp package: all .el files for load-path
packages.ewwm-elisp = pkgs.runCommand "ewwm-elisp-${version}" { } ''
mkdir -p $out/share/emacs/site-lisp/ewwm/{core,vr,ext}
cp ${./lisp/core}/*.el $out/share/emacs/site-lisp/ewwm/core/ 2>/dev/null || true
cp ${./lisp/vr}/*.el $out/share/emacs/site-lisp/ewwm/vr/ 2>/dev/null || true
cp ${./lisp/ext}/*.el $out/share/emacs/site-lisp/ewwm/ext/ 2>/dev/null || true
'';
}
(pkgs.lib.optionalAttrs (pkgs.stdenv.isLinux) (
let
kLib = xrKernelLib {
inherit (pkgs) lib linuxKernel fetchpatch fetchurl;
inherit pkgs;
};
# Chapel 2.8 — parallel programming language for BCI analysis
chapel = import ./nix/packages/chapel.nix { inherit pkgs; inherit (pkgs) lib stdenv fetchurl python3 llvmPackages_18 gmp which perl bash cmake; };
# Patched wlroots 0.18 — Bigscreen Beyond non_desktop detection
wlroots-beyond = import ./nix/packages/wlroots-beyond.nix { inherit pkgs; };
# Sway 1.10 linked against patched wlroots
sway-beyond = import ./nix/packages/sway-beyond.nix { inherit pkgs wlroots-beyond; };
# Monado OpenXR runtime with Beyond build flags
monado-beyond = import ./nix/packages/monado-beyond.nix {
inherit pkgs nixpkgs-xr system;
};
in {
# XR-patched kernel for NixOS — build and cache via Attic:
# nix build .#kernel-xr
# attic push xr-cache result/
# Subsequent builds with the xr-cache substituter get binary substitution.
packages.kernel-xr = kLib.mkXrKernel {
baseKernel = pkgs.linuxPackages_latest.kernel;
};
# Patched wlroots + sway for Bigscreen Beyond VR — build and cache:
# nix build .#wlroots-beyond
# nix build .#sway-beyond
# attic push xr-cache result/
# nix copy --to ssh://honey result/
packages.wlroots-beyond = wlroots-beyond;
packages.sway-beyond = sway-beyond;
packages.monado-beyond = monado-beyond;
# Chapel 2.8 compiler + runtime for BCI batch analysis
packages.chapel = chapel;
# Chapel development shell with Mason package manager
devShells.chapel-dev = pkgs.mkShell {
buildInputs = [ chapel ];
shellHook = ''
echo "Chapel dev shell ready"
echo " chpl: $(chpl --version 2>/dev/null || echo 'in PATH')"
echo " mason: $(mason --version 2>/dev/null || echo 'available')"
echo ""
echo "Build: cd analysis && mason build"
echo "Test: cd analysis && mason test"
'';
};
}
))
(pkgs.lib.optionalAttrs (system == "x86_64-linux") {
# NixOS VM integration tests (require KVM)
checks.boot-test = import ./nix/tests/boot-test.nix {
inherit pkgs self;
};
checks.full-stack-test = import ./nix/tests/full-stack-test.nix {
inherit pkgs self home-manager;
};
})
]
);
# Cross-compilation outputs (not produced by eachDefaultSystem)
crossOutputs = {
# Cross-compile for aarch64-linux from x86_64-linux
packages.aarch64-linux = let
pkgs = import nixpkgs {
system = "x86_64-linux";
crossSystem.config = "aarch64-unknown-linux-gnu";
overlays = [
rust-overlay.overlays.default
];
};
waylandLibs = mkWaylandLibs pkgs;
in {
compositor = pkgs.rustPlatform.buildRustPackage {
pname = "ewwm-compositor";
inherit version;
src = ./compositor;
cargoLock.lockFile = ./compositor/Cargo.lock;
nativeBuildInputs = with pkgs.buildPackages; [
pkg-config
clang
llvmPackages.libclang
];
buildInputs = waylandLibs ++ [ pkgs.libuvc pkgs.openxr-loader ];
buildFeatures = [ "full-backend" "vr" ];
LIBCLANG_PATH = "${pkgs.buildPackages.llvmPackages.libclang.lib}/lib";
LIBRARY_PATH = pkgs.lib.makeLibraryPath (waylandLibs ++ [ pkgs.libuvc pkgs.openxr-loader ]);
meta = with pkgs.lib; {
description = "EXWM-VR Wayland compositor built on Smithay (aarch64)";
license = licenses.gpl3Plus;
platforms = [ "aarch64-linux" ];
};
};
compositor-headless = pkgs.rustPlatform.buildRustPackage {
pname = "ewwm-compositor-headless";
inherit version;
src = ./compositor;
cargoLock.lockFile = ./compositor/Cargo.lock;
nativeBuildInputs = with pkgs.buildPackages; [
pkg-config
clang
llvmPackages.libclang
];
buildInputs = waylandLibs ++ [ pkgs.libuvc ];
buildNoDefaultFeatures = true;
LIBCLANG_PATH = "${pkgs.buildPackages.llvmPackages.libclang.lib}/lib";
LIBRARY_PATH = pkgs.lib.makeLibraryPath (waylandLibs ++ [ pkgs.libuvc ]);
meta = with pkgs.lib; {
description = "EXWM-VR Wayland compositor headless (aarch64)";
license = licenses.gpl3Plus;
platforms = [ "aarch64-linux" ];
};
};
};
# Cross-compile for s390x-linux from x86_64-linux
packages.s390x-linux = let
pkgs = import nixpkgs {
system = "x86_64-linux";
crossSystem.config = "s390x-unknown-linux-gnu";
overlays = [
rust-overlay.overlays.default
];
};
waylandLibs = mkWaylandLibs pkgs;
in {
compositor-headless = pkgs.rustPlatform.buildRustPackage {
pname = "ewwm-compositor-headless";
inherit version;
src = ./compositor;
cargoLock.lockFile = ./compositor/Cargo.lock;
nativeBuildInputs = with pkgs.buildPackages; [
pkg-config
clang
llvmPackages.libclang
];
buildInputs = waylandLibs ++ [ pkgs.libuvc ];
buildNoDefaultFeatures = true;
LIBCLANG_PATH = "${pkgs.buildPackages.llvmPackages.libclang.lib}/lib";
LIBRARY_PATH = pkgs.lib.makeLibraryPath (waylandLibs ++ [ pkgs.libuvc ]);
meta = with pkgs.lib; {
description = "EXWM-VR Wayland compositor headless (s390x)";
license = licenses.gpl3Plus;
platforms = [ "s390x-linux" ];
};
};
};
};
in
nixpkgs.lib.recursiveUpdate
(nixosModuleOutputs // perSystemOutputs)
crossOutputs;
}