-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathflake.nix
More file actions
593 lines (508 loc) · 19.7 KB
/
flake.nix
File metadata and controls
593 lines (508 loc) · 19.7 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
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
# flake.nix
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2025 DeMoD LLC. All rights reserved.
# ============================================================================
# ArchibaldOS Community Edition
# Real-time audio workstation + HydraMesh P2P networking for NixOS
#
# For commercial features (Thunderbolt/USB4, ARM support, auto-updates,
# enterprise configurations), see: https://demod.ltd
# ============================================================================
{
description = "ArchibaldOS Community Edition - Real-time audio workstation + HydraMesh";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
musnix.url = "github:musnix/musnix";
chaotic.url = "github:chaotic-cx/nyx/nyxpkgs-unstable";
};
outputs = { self, nixpkgs, musnix, chaotic }:
let
system = "x86_64-linux";
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
};
# Shared flake URI for updates
flakeUri = "github:ALH477/ArchibaldOS";
# CachyOS RT BORE kernel configuration (primary)
cachyosRtConfig = { config, pkgs, lib, ... }: {
# Use CachyOS RT kernel with BORE scheduler
boot.kernelPackages = pkgs.linuxPackages_cachyos-rt;
# RT kernel params
boot.kernelParams = [
"threadirqs"
"isolcpus=1-3"
"nohz_full=1-3"
"intel_idle.max_cstate=1"
"processor.max_cstate=1"
"tsc=reliable"
"clocksource=tsc"
"preempt=full"
];
powerManagement.cpuFreqGovernor = "performance";
# scx scheduler support (if available)
# boot.kernelModules = [ "scx" ];
};
# Fallback musnix RT kernel configuration
musnixRtConfig = { config, pkgs, lib, ... }: {
musnix = {
enable = true;
kernel.realtime = true;
alsaSeq.enable = true;
rtirq.enable = true;
das_watchdog.enable = true;
};
boot.kernelParams = [
"threadirqs"
"isolcpus=1-3"
"nohz_full=1-3"
"intel_idle.max_cstate=1"
"processor.max_cstate=1"
];
powerManagement.cpuFreqGovernor = "performance";
};
# Common base configuration
baseConfig = { config, pkgs, lib, ... }: {
system.stateVersion = "24.11";
isoImage.squashfsCompression = "gzip -Xcompression-level 1";
nix.settings.experimental-features = [ "nix-command" "flakes" ];
networking.networkmanager.enable = true;
networking.firewall.enable = true;
};
in {
# ========================================================================
# NIXOS CONFIGURATIONS
# ========================================================================
nixosConfigurations = {
# ======================================================================
# ARCHIBALDOS - Desktop RT Audio Workstation (x86_64 ISO)
# Profile: Audio Production
# Kernel: CachyOS RT with BORE scheduler
# ======================================================================
archibaldOS-iso = nixpkgs.lib.nixosSystem {
inherit system;
specialArgs = { inherit musnix chaotic flakeUri; };
modules = [
"${nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-graphical-calamares-plasma6.nix"
chaotic.nixosModules.default
musnix.nixosModules.musnix
./modules/audio.nix
./modules/desktop.nix
./modules/branding.nix
./modules/hydramesh.nix
./modules/profiles.nix
cachyosRtConfig
baseConfig
({ config, pkgs, lib, ... }: {
nixpkgs.config.permittedInsecurePackages = [ "qtwebengine-5.15.19" ];
# Select audio profile
profiles.audio.enable = true;
# musnix for audio tooling (not kernel)
musnix = {
enable = true;
kernel.realtime = false; # Using CachyOS RT instead
alsaSeq.enable = true;
rtirq.enable = true;
das_watchdog.enable = true;
};
# Audio production packages
environment.systemPackages = with pkgs; [
# Core
usbutils libusb1 alsa-firmware alsa-tools
dialog mkpasswd
# DAWs & Audio Tools
audacity ardour reaper
fluidsynth guitarix
# Synths & Effects
surge helm vmpk calf
zrythm carla
# DSP & Programming
csound csound-qt
faust faust2alsa faust2jack
puredata supercollider
# Utilities
qjackctl pavucontrol
];
# Graphics
hardware.graphics.enable = true;
hardware.graphics.extraPackages = with pkgs; [
mesa vaapiIntel vaapiVdpau libvdpau-va-gl
];
# Branding
branding.enable = true;
branding.variant = "audio";
# Live user
users.users.nixos = {
isNormalUser = true;
initialHashedPassword = lib.mkForce null;
initialPassword = "nixos";
home = "/home/nixos";
createHome = true;
extraGroups = [ "wheel" "audio" "jackaudio" "video" "networkmanager" "docker" ];
shell = lib.mkForce pkgs.bashInteractive;
};
services.displayManager.autoLogin = {
enable = true;
user = "nixos";
};
})
];
};
# ======================================================================
# ARCHIBALDOS ROBOTICS - RT Robotics Workstation (x86_64 ISO)
# Profile: Robotics & Control Systems
# Kernel: CachyOS RT with BORE scheduler
# ======================================================================
archibaldOS-robotics = nixpkgs.lib.nixosSystem {
inherit system;
specialArgs = { inherit musnix chaotic flakeUri; };
modules = [
"${nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-graphical-calamares-plasma6.nix"
chaotic.nixosModules.default
musnix.nixosModules.musnix
./modules/desktop.nix
./modules/branding.nix
./modules/hydramesh.nix
./modules/profiles.nix
cachyosRtConfig
baseConfig
({ config, pkgs, lib, ... }: {
nixpkgs.config.permittedInsecurePackages = [ "qtwebengine-5.15.19" ];
# Select robotics profile
profiles.robotics.enable = true;
# musnix for RT tooling (not kernel)
musnix = {
enable = true;
kernel.realtime = false; # Using CachyOS RT instead
rtirq.enable = true;
das_watchdog.enable = true;
};
# Robotics packages
environment.systemPackages = with pkgs; [
# Core
usbutils libusb1
dialog mkpasswd
# ROS 2 (if available in nixpkgs)
# ros2-humble
# Robotics frameworks
gazebo
# openrave
# Control & Simulation
octave
python3Packages.numpy
python3Packages.scipy
python3Packages.matplotlib
python3Packages.sympy
python3Packages.control
python3Packages.roboticstoolbox-python or null
# Serial & Hardware
minicom
screen
picocom
python3Packages.pyserial
# CAN bus
can-utils
# Vision
opencv
python3Packages.opencv4
# 3D & CAD
freecad
openscad
blender
# Electronics
kicad
fritzing
# Development
cmake
gnumake
gcc
gdb
clang
python3
python3Packages.pip
# IDEs
vscode
arduino-ide
# Networking for robot comms
wireshark
tcpdump
nmap
# Documentation
doxygen
graphviz
];
# Graphics for simulation
hardware.graphics.enable = true;
hardware.graphics.extraPackages = with pkgs; [
mesa vaapiIntel vaapiVdpau libvdpau-va-gl
];
# Branding
branding.enable = true;
branding.variant = "robotics";
# Enable HydraMesh for robot-to-robot comms
services.hydramesh = {
enable = lib.mkDefault false; # User can enable
mode = "p2p";
hardened = true;
};
# Serial port access
users.groups.dialout = {};
users.groups.plugdev = {};
# udev rules for robotics hardware
services.udev.extraRules = ''
# Arduino
SUBSYSTEM=="tty", ATTRS{idVendor}=="2341", MODE="0666", GROUP="dialout"
SUBSYSTEM=="tty", ATTRS{idVendor}=="1a86", MODE="0666", GROUP="dialout"
# FTDI
SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", MODE="0666", GROUP="dialout"
# Silicon Labs CP210x
SUBSYSTEM=="tty", ATTRS{idVendor}=="10c4", MODE="0666", GROUP="dialout"
# STM32
SUBSYSTEM=="usb", ATTRS{idVendor}=="0483", MODE="0666", GROUP="plugdev"
# Teensy
SUBSYSTEM=="usb", ATTRS{idVendor}=="16c0", MODE="0666", GROUP="plugdev"
# Generic USB serial
KERNEL=="ttyUSB*", MODE="0666", GROUP="dialout"
KERNEL=="ttyACM*", MODE="0666", GROUP="dialout"
'';
# CAN bus kernel modules
boot.kernelModules = [ "can" "can_raw" "can_bcm" "vcan" "slcan" ];
# Live user with robotics groups
users.users.nixos = {
isNormalUser = true;
initialHashedPassword = lib.mkForce null;
initialPassword = "nixos";
home = "/home/nixos";
createHome = true;
extraGroups = [
"wheel" "video" "networkmanager" "docker"
"dialout" "plugdev" "input" "gpio" "i2c" "spi"
];
shell = lib.mkForce pkgs.bashInteractive;
};
# GPIO/I2C/SPI groups
users.groups.gpio = {};
users.groups.i2c = {};
users.groups.spi = {};
services.displayManager.autoLogin = {
enable = true;
user = "nixos";
};
# Kernel params for robotics (deterministic timing)
boot.kernelParams = lib.mkAfter [
"usbhid.mousepoll=1" # Faster USB polling
];
})
];
};
# ======================================================================
# HYDRAMESH - Headless P2P Networking Node (x86_64 ISO)
# Kernel: CachyOS RT with BORE scheduler
# ======================================================================
hydramesh = nixpkgs.lib.nixosSystem {
inherit system;
specialArgs = { inherit musnix chaotic flakeUri; };
modules = [
"${nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix"
chaotic.nixosModules.default
musnix.nixosModules.musnix
./modules/hydramesh.nix
./modules/profiles.nix
cachyosRtConfig
baseConfig
({ config, pkgs, lib, ... }: {
# musnix for RT tooling (not kernel)
musnix = {
enable = true;
kernel.realtime = false; # Using CachyOS RT instead
alsaSeq.enable = false;
rtirq.enable = false;
das_watchdog.enable = true;
};
environment.systemPackages = with pkgs; [
usbutils
dialog mkpasswd
htop iotop
tcpdump iperf3
vim git tmux
];
# Enable HydraMesh
services.hydramesh = {
enable = true;
image = "alh477/hydramesh:latest";
mode = "p2p";
hardened = true;
};
powerManagement.cpuFreqGovernor = "performance";
# Headless
services.xserver.enable = false;
services.displayManager.enable = false;
# Console user
users.users.hydramesh = {
isNormalUser = true;
extraGroups = [ "wheel" "networkmanager" "docker" ];
initialPassword = "hydramesh";
};
services.getty.autologinUser = lib.mkForce "hydramesh";
})
];
};
# ======================================================================
# FALLBACK CONFIGURATIONS (musnix PREEMPT_RT kernel)
# For systems that can't use CachyOS or need mainline RT
# ======================================================================
# Audio with musnix RT kernel
archibaldOS-musnix = nixpkgs.lib.nixosSystem {
inherit system;
specialArgs = { inherit musnix flakeUri; };
modules = [
"${nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-graphical-calamares-plasma6.nix"
musnix.nixosModules.musnix
./modules/audio.nix
./modules/desktop.nix
./modules/branding.nix
./modules/hydramesh.nix
./modules/profiles.nix
musnixRtConfig
baseConfig
({ config, pkgs, lib, ... }: {
nixpkgs.config.permittedInsecurePackages = [ "qtwebengine-5.15.19" ];
profiles.audio.enable = true;
environment.systemPackages = with pkgs; [
usbutils libusb1 alsa-firmware alsa-tools
dialog mkpasswd
audacity ardour reaper fluidsynth guitarix
surge helm vmpk calf zrythm carla
csound csound-qt faust faust2alsa faust2jack
puredata supercollider qjackctl pavucontrol
];
hardware.graphics.enable = true;
hardware.graphics.extraPackages = with pkgs; [
mesa vaapiIntel vaapiVdpau libvdpau-va-gl
];
branding.enable = true;
branding.variant = "audio";
users.users.nixos = {
isNormalUser = true;
initialHashedPassword = lib.mkForce null;
initialPassword = "nixos";
home = "/home/nixos";
createHome = true;
extraGroups = [ "wheel" "audio" "jackaudio" "video" "networkmanager" "docker" ];
shell = lib.mkForce pkgs.bashInteractive;
};
services.displayManager.autoLogin = {
enable = true;
user = "nixos";
};
})
];
};
# Robotics with musnix RT kernel
archibaldOS-robotics-musnix = nixpkgs.lib.nixosSystem {
inherit system;
specialArgs = { inherit musnix flakeUri; };
modules = [
"${nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-graphical-calamares-plasma6.nix"
musnix.nixosModules.musnix
./modules/desktop.nix
./modules/branding.nix
./modules/hydramesh.nix
./modules/profiles.nix
musnixRtConfig
baseConfig
({ config, pkgs, lib, ... }: {
nixpkgs.config.permittedInsecurePackages = [ "qtwebengine-5.15.19" ];
profiles.robotics.enable = true;
environment.systemPackages = with pkgs; [
usbutils libusb1 dialog mkpasswd
gazebo octave
python3Packages.numpy python3Packages.scipy
python3Packages.matplotlib python3Packages.sympy
python3Packages.pyserial
minicom screen picocom can-utils
opencv freecad openscad blender
kicad cmake gnumake gcc gdb clang
python3 vscode arduino-ide
wireshark tcpdump nmap
doxygen graphviz
];
hardware.graphics.enable = true;
hardware.graphics.extraPackages = with pkgs; [
mesa vaapiIntel vaapiVdpau libvdpau-va-gl
];
branding.enable = true;
branding.variant = "robotics";
services.udev.extraRules = ''
SUBSYSTEM=="tty", ATTRS{idVendor}=="2341", MODE="0666", GROUP="dialout"
SUBSYSTEM=="tty", ATTRS{idVendor}=="1a86", MODE="0666", GROUP="dialout"
SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", MODE="0666", GROUP="dialout"
SUBSYSTEM=="tty", ATTRS{idVendor}=="10c4", MODE="0666", GROUP="dialout"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0483", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTRS{idVendor}=="16c0", MODE="0666", GROUP="plugdev"
KERNEL=="ttyUSB*", MODE="0666", GROUP="dialout"
KERNEL=="ttyACM*", MODE="0666", GROUP="dialout"
'';
boot.kernelModules = [ "can" "can_raw" "can_bcm" "vcan" "slcan" ];
users.groups.dialout = {};
users.groups.plugdev = {};
users.groups.gpio = {};
users.groups.i2c = {};
users.groups.spi = {};
users.users.nixos = {
isNormalUser = true;
initialHashedPassword = lib.mkForce null;
initialPassword = "nixos";
home = "/home/nixos";
createHome = true;
extraGroups = [
"wheel" "video" "networkmanager" "docker"
"dialout" "plugdev" "input" "gpio" "i2c" "spi"
];
shell = lib.mkForce pkgs.bashInteractive;
};
services.displayManager.autoLogin = {
enable = true;
user = "nixos";
};
})
];
};
};
# ========================================================================
# BUILD OUTPUTS
# ========================================================================
packages.${system} = {
# CachyOS RT BORE (primary)
default = self.nixosConfigurations.archibaldOS-iso.config.system.build.isoImage;
iso = self.nixosConfigurations.archibaldOS-iso.config.system.build.isoImage;
robotics-iso = self.nixosConfigurations.archibaldOS-robotics.config.system.build.isoImage;
hydramesh-iso = self.nixosConfigurations.hydramesh.config.system.build.isoImage;
# musnix PREEMPT_RT (fallback)
iso-musnix = self.nixosConfigurations.archibaldOS-musnix.config.system.build.isoImage;
robotics-iso-musnix = self.nixosConfigurations.archibaldOS-robotics-musnix.config.system.build.isoImage;
};
# ========================================================================
# DEV SHELLS
# ========================================================================
devShells.${system} = {
default = pkgs.mkShell {
packages = with pkgs; [
audacity ardour fluidsynth guitarix
csound faust supercollider qjackctl
surge puredata vim docker
];
};
robotics = pkgs.mkShell {
packages = with pkgs; [
cmake gnumake gcc gdb
python3 python3Packages.numpy python3Packages.scipy
python3Packages.matplotlib python3Packages.pyserial
opencv arduino-ide
can-utils minicom
vim docker
];
};
};
};
}