Oligarchy NixOS is a custom NixOS distribution optimized for the Framework Laptop 16 (AMD Ryzen 7040 series), with robust support for other x86_64 hardware. It is designed for developers, researchers, creators, gamers, and Framework enthusiasts, offering a lightweight, Wayland-based Hyprland desktop (with optional X11 Cinnamon and DWM support), a graphical Calamares installer, and extensive customization options. The distribution integrates the HydraMesh service, powered by the DeMoD-LISP (D-LISP) SDK, for low-latency peer-to-peer (P2P) communication, suitable for Internet of Things (IoT), edge computing, and gaming applications. With a focus on utilitarian efficiency, educational value, stability, and accessibility, Oligarchy NixOS supports Snap packages, a comprehensive gaming suite, and hardware-specific optimizations to achieve low power consumption (5-7W idle on Framework 16) and high performance.
Oligarchy NixOS stands out due to its carefully crafted features, ensuring a robust, secure, and user-friendly experience tailored to modern hardware and advanced use cases:
- Low Idle Power Consumption: Optimized for the Framework Laptop 16 with power-efficient settings:
- Power Profiles Daemon: Dynamically adjusts CPU performance to minimize idle power usage (
power-profiles-daemonenables balanced and low-power modes). - AMDGPU Configuration: Kernel parameters (
amdgpu.abmlevel=0,amdgpu.sg_display=0,amdgpu.exp_hw_support=1) optimize GPU power draw, achieving 5-7W idle consumption on Framework 16 (when using integrated AMD graphics). - Fan Control: The
fw-fanctrlmodule ensures efficient cooling, reducing fan activity during low loads to further lower power usage. - Lid Switch Handling: Configurable scripts (
lid.sh,toggle_clamshell.sh) disable the laptop screen in clamshell mode, saving power for external monitor setups.
- Power Profiles Daemon: Dynamically adjusts CPU performance to minimize idle power usage (
- Framework 16 Compatibility: Leverages
nixos-hardwareandfw-fanctrlfor AMD Ryzen 7040 support, including GPU drivers (amdgpu), firmware updates (fwupd), and fingerprint authentication (fprintd). A fallback option ensures compatibility with other hardware. - Modular Package Management: Nix’s declarative configuration allows precise control over installed components. Features like gaming (
steam,lutris,dhewm3), Snap support, and the HydraMesh service are optional, keeping the system lean and customizable. - Lightweight Desktop: Hyprland, paired with Waybar (system status bar) and Wofi (application launcher), provides a fast, modern Wayland-based desktop environment, minimizing resource usage while supporting multi-monitor and clamshell configurations. Optional X11 support via Cinnamon and DWM.
- Streamlined Installation: The graphical Calamares installer simplifies disk setup (LUKS-encrypted ext4), user configuration, hardware options, and HydraMesh security settings (firewall and AppArmor), ensuring a quick, secure, and user-friendly deployment process.
- Customization Scripts: Tools for resolution cycling, Hyprland configuration, theme switching, web app integration, HydraMesh management, and a keybindings cheat sheet enhance user control, accessible via Wofi or keyboard shortcuts.
- Snap Support: Snap is optional, expanding software availability without compromising Nix’s reproducibility.
- HydraMesh Service: Integrates the DeMoD-LISP SDK for low-latency P2P communication, supporting transports like gRPC, WebSocket, and LoRaWAN. It includes a TUI configuration editor, Waybar status indicator, and robust security (systemd hardening, optional firewall, and AppArmor), making it ideal for IoT, gaming, and edge computing.
- Virtual Camera Support: Kernel module
v4l2loopbackenables virtual webcams for streaming and video conferencing.
Oligarchy NixOS prioritizes security, particularly for the HydraMesh service, which handles networked P2P communication for IoT, gaming, and edge computing. The HydraMesh service is secured through a multi-layered approach, adhering to industry best practices (e.g., NIST SP 800-53, CIS Controls) to mitigate risks from untrusted network inputs and potential exploits. Below is a detailed explanation of how HydraMesh is secured:
-
Systemd Hardening:
- Dedicated User and Group: HydraMesh runs as a dedicated
hydrameshuser and group, created dynamically withDynamicUser = true. This isolates the service from other system processes, preventing privilege escalation if compromised. - Restricted Environment: The systemd service (
systemd.services.hydramesh) applies strict confinement:PrivateDevices = true: Blocks access to hardware devices (e.g.,/dev/sda,/dev/input).ProtectSystem = "strict": Mounts/usr,/boot, and/etcas read-only, preventing unauthorized modifications.ProtectHome = true: Denies access to user home directories.PrivateTmp = true: Provides a private/tmpdirectory, isolating temporary files.NoNewPrivileges = true: Prevents the service from gaining new privileges (e.g., via setuid binaries).CapabilityBoundingSet = "": Removes all Linux capabilities, limiting kernel-level operations.RestrictNamespaces = true: Restricts access to kernel namespaces (e.g., network, mount), reducing attack surface.SystemCallFilter = "@system-service ~@privileged": Whitelists only necessary system calls, blocking privileged operations (e.g., kernel module loading).
- Low-Level Mechanics: These directives are enforced by systemd during service startup, creating a sandboxed environment. The service runs
/etc/hydramesh/as its working directory, withhydrameshuser permissions (UID/GID dynamically assigned at runtime). - Value: This aligns with containerization security principles (e.g., Docker’s default settings), ensuring robust isolation for networked applications.
- Dedicated User and Group: HydraMesh runs as a dedicated
-
Optional Firewall:
- Dynamic Port Configuration: If
services.hydramesh.firewallEnableis set totrue(configured post-installation), the firewall opens the TCP port specified in/etc/hydramesh/config.json(default 50051 for gRPC) and UDP 5683 for LoRaWAN if thelorawanplugin is enabled ("plugins": {"lorawan": true}). - Implementation: The
networking.firewallsection inhydramesh.nixusesbuiltins.fromJSONto parseconfig.jsonand dynamically setallowedTCPPortsandallowedUDPPorts. This ensures only necessary ports are exposed, reducing the attack surface. - Low-Level Mechanics: NixOS’s firewall, based on
iptablesornftables, applies rules during system activation (nixos-rebuild switch). For example, ifport = 50051and LoRaWAN is enabled, rules likeiptables -A INPUT -p tcp --dport 50051 -j ACCEPTandiptables -A INPUT -p udp --dport 5683 -j ACCEPTare added. - Value: Follows network segmentation best practices (e.g., CIS Control 12), ensuring only required ports are open, critical for public-facing IoT or gaming nodes.
- Dynamic Port Configuration: If
-
Optional AppArmor Profile:
- Confinement: If
services.hydramesh.apparmorEnableis set totrue(configured post-installation), an AppArmor profile confines the HydraMesh service (/usr/bin/sbcl) to:- Read access to
/etc/hydramesh/**(configuration files). - Read/write access to
/var/lib/hydramesh/**(StreamDB data). - TCP and UDP network access for communication (e.g., gRPC, LoRaWAN).
capability dac_overridefor file operations within allowed paths.
- Read access to
- Complain Mode: The profile uses
flags=(complain)to log violations without blocking, aiding debugging while maintaining security during production testing. - Low-Level Mechanics: The profile is generated in
hydramesh.nixusingpkgs.writeTextand loaded into/etc/apparmor.d/during system activation. AppArmor’s kernel module enforces restrictions, logging violations to/var/log/audit/audit.log(ifauditdis enabled). - Value: Provides mandatory access control, aligning with OWASP Top 10 mitigation strategies, protecting against file system exploits and unauthorized network access.
- Confinement: If
-
File System Permissions:
- Dedicated Directories: HydraMesh uses
/etc/hydramesh/for configuration (read-only forhydrameshuser) and/var/lib/hydramesh/for data (read/write). Permissions are set with:sudo chown hydramesh:hydramesh /var/lib/hydramesh /etc/hydramesh sudo chmod 755 /var/lib/hydramesh /etc/hydramesh sudo chmod 640 /etc/hydramesh/* - Low-Level Mechanics: The
hydrameshuser, created byDynamicUser, owns these directories, ensuring only the service can access them. The640mode restricts configuration files to read-only for non-owners, preventing unauthorized modifications. - Value: Enforces least privilege, a core security principle (e.g., NIST SP 800-53 AC-6), preventing tampering with sensitive files.
- Dedicated Directories: HydraMesh uses
-
Secure Configuration Management:
- TUI Editor: The
hydramesh_config_editor.pyscript validatesconfig.jsoninputs against the D-LISP SDK schema, ensuring safe edits with JSON parsing and user confirmation prompts. - Low-Level Mechanics: The script uses Python’s
cursesfor a TUI,jsonfor parsing, andrefor input validation (e.g., numbers, booleans, arrays). Changes are written to/etc/hydramesh/config.jsononly after user confirmation, reducing misconfiguration risks. - Value: Mitigates configuration errors, a common attack vector in networked services.
- TUI Editor: The
-
System-Wide Security Features:
- AppArmor: Enabled system-wide (
security.apparmor.enable = true) for mandatory access control on all processes. - Polkit and RTKit:
security.polkit.enable = truefor authorization, andsecurity.rtkit.enable = truefor real-time kernel privileges in audio/pipewire. - PAM for Fingerprint:
security.pam.services.login.fprintAuth = trueandsudo.fprintAuth = truefor secure authentication. - Firewall: Always enabled (
networking.firewall.enable = true), with dynamic rules for HydraMesh. - Value: Provides layered defense, aligning with best practices for system integrity and access control.
- AppArmor: Enabled system-wide (
-
Clone the Repository:
git clone https://github.com/ALH477/DeMoD-Framework16-NIXOS.git cd DeMoD-Framework16-NIXOS -
Prepare Assets:
- Place
wallpaper.jpgandhydramesh.svgin the repository root. - Ensure
./HydraMesh/containssrc/hydramesh.lisp,plugins/*.lisp, andstreamdb/src/.
- Place
-
Update StreamDB Hash:
nix-prefetch-url --unpack file://$(pwd)/HydraMesh/streamdbReplace
cargoSha256inhydramesh/flake.nixwith the output. Note: The separate StreamDB flake uses Crane for building, with WASM and encryption features; integrate if needed via inputs. -
Customize Configuration (Optional):
- Edit
./configuration.nixto toggle options likecustom.steam.enable,custom.snap.enable,custom.nvidia.enablebefore building the ISO. By default, Steam, Snap, and NVIDIA support are enabled; Framework-specific optimizations and fan control are included via modules.
- Edit
-
Build the ISO:
nix build .#nixosConfigurations.iso.config.system.build.isoImage -
Flash the ISO: Use
ddor a tool like Popsicle to flashresult/iso/nixos-*.isoto a USB drive. -
Installation:
- Boot from the USB. The live environment uses LightDM and i3 for a minimal graphical session.
- Calamares will autostart on login. Follow the graphical steps:
- Partitioning: Select and partition the target disk (e.g.,
/dev/sda), enabling LUKS encryption on ext4 as needed. - User and System: Configure hostname, username, passwords, locale, and timezone.
- The installer will generate
hardware-configuration.nix, copy the preconfigured./configuration.nix(with enabled features like Steam, Snap, NVIDIA drivers, and Hyprland), and complete the installation.
- Partitioning: Select and partition the target disk (e.g.,
- Reboot into the new system, entering the LUKS password at boot if encrypted.
-
Test in QEMU (Optional):
qemu-system-x86_64 -cdrom result/iso/nixos-*.iso -m 4G -enable-kvm -cpu host
Once installed, Oligarchy NixOS provides a powerful and customizable environment:
-
Desktop:
- Hyprland starts automatically via SDDM, with Waybar displaying CPU, memory, battery, network, and HydraMesh status (🕸️ ON/OFF).
- Launch applications via Wofi (
SUPER+D) or the terminal (SUPER+Qfor Kitty). - Use
SUPER+1-0to switch workspaces,SUPER+SHIFT+1-0to move windows to workspaces, andSUPER+Sfor a specialdemodworkspace. - Optional: Switch to Cinnamon or DWM via SDDM.
-
Customization:
- Resolution: Cycle resolutions with
SUPER+SHIFT+WorSUPER+SHIFT+F1-F5, or runtoggle_resolutionvia Wofi/terminal. - Hyprland Config: Modify wallpaper/keybindings with
SUPER+SHIFT+Porhyprland_config_modifiervia Wofi. - Themes: Switch color schemes with
SUPER+SHIFT+Tortheme_changervia Wofi (options: green, blue, red, purple, Nord, Dracula, Gruvbox, Solarized, Catppuccin, Tokyo Night, custom). - Web Apps: Add web apps to Wofi with
SUPER+SHIFT+Aorwebapp_to_wofivia Wofi (supports Firefox, Brave, or default browser). - HydraMesh: Toggle the service with
SUPER+SHIFT+Horhydramesh_togglevia Wofi. Editconfig.jsonwithSUPER+SHIFT+Eorhydramesh_config_editorvia Wofi. Monitor status in Waybar. - Keybindings Cheat Sheet: View keybindings with
SUPER+SHIFT+Korkeybindings_cheatsheetvia Wofi.
- Resolution: Cycle resolutions with
-
Gaming:
- Steam, Lutris, and related tools are enabled by default. Run
steam,lutris,dhewm3(requires Doom 3 data files),r2modmanfor modded games, ordarkradiantfor level editing via Wofi or terminal. - Use
proton-ge-binfor enhanced game compatibility.
- Steam, Lutris, and related tools are enabled by default. Run
-
HydraMesh:
- Enable the service post-installation by adding to
configuration.nix(then runnixos-rebuild switch):imports = [ ./hydramesh.nix ]; services.hydramesh.enable = true; services.hydramesh.firewallEnable = true; # Enables firewall for TCP/UDP ports services.hydramesh.apparmorEnable = true; # Enables AppArmor confinement
- Configure via
/etc/hydramesh/config.jsonusing the TUI editor (SUPER+SHIFT+Eor Wofi). Supported fields:transport:gRPC,WebSocket, ornative-lisp.hostandport: e.g.,localhost:50051for gRPC.mode:p2p,client,server,auto, ormaster.node-id: Unique identifier (e.g.,hydramesh-node-1).peers: Array of peer addresses (e.g.,["peer1:50051"]).group-rtt-threshold: RTT threshold in ms (default 50).plugins: Object to enable transports (e.g.,{"lorawan": true}).storage:streamdborin-memory.streamdb-path: Path for StreamDB (e.g.,/var/lib/hydramesh/streamdb).optimization-level: 0-3 for performance tuning.retry-max: 1-10 for transient error retries.
- Test the service:
/etc/hydramesh/test-hydramesh.sh
- Update the codebase by replacing
./HydraMesh/contents and running:sudo nixos-rebuild switch
- Set permissions:
sudo mkdir -p /var/lib/hydramesh/streamdb sudo chown hydramesh:hydramesh /var/lib/hydramesh /etc/hydramesh sudo chmod 755 /var/lib/hydramesh /etc/hydramesh sudo chmod 640 /etc/hydramesh/*
- Enable the service post-installation by adding to
-
Snap:
- If enabled during customization, install:
Example:
snap install <package>
snap install core; snap install hello-world - Run:
snap run hello-world
- If enabled during customization, install:
-
Wallpaper:
- Place a custom wallpaper at
~/Pictures/wall.jpgor use the default/etc/nixos/hypr/wallpaper.jpg.
- Place a custom wallpaper at
-
Build Failures:
- Ensure
cargoSha256inhydramesh/flake.nixis updated with:nix-prefetch-url --unpack file://$(pwd)/HydraMesh/streamdb - Verify
./HydraMesh/containssrc/hydramesh.lisp,plugins/*.lisp, andstreamdb/src/. - Check internet connectivity for fetching dependencies, or use a cached
/nix/store.
- Ensure
-
HydraMesh Issues:
- If the service fails to start, check logs:
journalctl -u hydramesh
- Ensure
libstreamdb.sois built and accessible in/etc/hydramesh/streamdb/lib/. - Validate
config.jsonwith the TUI editor (SUPER+SHIFT+E). - Check AppArmor logs if enabled:
journalctl -t apparmor
- If the service fails to start, check logs:
-
Installer Errors:
- Ensure the USB device is correctly identified (
lsblk) and not mounted. - If LUKS decryption fails, verify the password matches the one set during installation.
- For Framework 16 issues, confirm
nixos-hardwareandfw-fanctrlinputs are accessible.
- Ensure the USB device is correctly identified (
-
Hyprland Issues:
- If Waybar or Wofi fails, check configs in
~/.config/waybar/or~/.config/wofi/. - For display issues, manually set resolutions:
hyprctl keyword monitor eDP-2,2560x1600@165,auto,1
- If Waybar or Wofi fails, check configs in
-
General Support:
- Consult the NixOS Wiki for configuration help.
- Open issues at GitHub.
- Check Nix logs:
journalctl -u nix-daemon.
Contributions are welcome! To contribute:
- Fork the repository:
https://github.com/ALH477/DeMoD-Framework16-NIXOS. - Make changes, ensuring compatibility with NixOS 25.05 (or upcoming 25.11) and Framework 16.
- Submit pull requests or issues via GitHub.
- Test changes with
nixos-rebuild dry-runor QEMU before submitting.
This project is licensed under the BSD 3-Clause License:
Copyright (c) 2025, DeMoD LLC
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Note: The HydraMesh codebase in ./HydraMesh/ is licensed under LGPL-3.0. See ./HydraMesh/LICENSE for details.
- Doom 3:
dhewm3requires separately owned Doom 3 data files (e.g., from Steam). - Assets: Ensure
wallpaper.jpg,hydramesh.svg, and./HydraMesh/(withsrc/hydramesh.lisp,plugins/*.lisp,streamdb/src/) are in the repository root before building. - StreamDB Build: Replace
cargoSha256inhydramesh/flake.nixwith the output ofnix-prefetch-url --unpack file://$(pwd)/HydraMesh/streamdb. For advanced builds, use the separate StreamDB flake with Crane for WASM/encryption support. - Validation: Locale/timezone inputs are handled via Calamares; use standard formats (e.g.,
en_US.UTF-8,America/Los_Angeles). - Snap: Enable via
custom.snap.enableinconfiguration.nixbefore building. Usesnapcommands post-install. - HydraMesh Security: The firewall (if enabled) opens the TCP port specified in
config.json(default 50051) and UDP 5683 for LoRaWAN if enabled. AppArmor (if enabled) confines the service to/etc/hydramesh/**(read) and/var/lib/hydramesh/**(read/write) with TCP/UDP access. - Password Security: User and root passwords are set during Calamares installation and hashed for security.
- Memory Management: To exclude prior conversation references, go to "Data Controls" in settings or click the book icon beneath relevant messages to forget specific chats.
- NVIDIA Support: Enabled by default for hybrid graphics setups; disable via
custom.nvidia.enable = false;inconfiguration.nixfor pure AMD power optimization.