feat: implement modular foundation and core system services

- Update flake.nix with 25.11 release and core inputs
- Add dedicated modules for audio (Pipewire), bluetooth, and networking
- Update GEMINI.md with the new Modular Merging Architecture blueprint
- Configure graphical installer ISO and test VM outputs
This commit is contained in:
Bernardo Magri
2026-04-03 21:06:42 +01:00
parent 33deeb494b
commit 29cc0d2547
49 changed files with 1628 additions and 855 deletions

View File

@@ -1,64 +1,40 @@
# Nomarchy - A NixOS-based distribution with Omarchy flavour - Agent Build Blueprint
## System Architecture Overview
You are tasked with generating a NixOS-based Linux distribution monorepo that perfectly replicates the Omarchy Wayland workflow. The architecture relies on a strictly declarative Nix Flake setup, separated into System-level configurations (NixOS) and User-level configurations (Standalone Home Manager).
Nomarchy uses a **Modular Merging Architecture**. The distro is distributed as a Nix Flake that exports two primary modules: `nixosModules.system` and `nixosModules.home`. This approach ensures strict separation between the "Upstream" core and the "Downstream" user configuration.
The goal is to provide an upstream repository that users can import into their own downstream `flake.nix` files, allowing them to keep the core Omarchy aesthetic while maintaining their own custom packages and development environments.
Users interact with the system by importing the distro's modules into their own `flake.nix` and then layering their own personal modules (`system.nix` and `home.nix`) on top. This follows the native NixOS design pattern for declarative, multi-module systems.
## Directory Structure
Generate the repository using the following exact structure:
* `flake.nix` (Master entry point)
* `installer/install-nomarchy.sh` (Bash/Gum interactive installer)
* `installer/disko-ext4.nix` (Standard drive layout)
* `installer/disko-btrfs-luks.nix` (Encrypted snapshot layout)
* `modules/system/default.nix` (Core OS module)
* `modules/system/plymouth.nix` (Boot splash)
* `modules/system/sddm.nix` (Display manager logic)
* `modules/home/default.nix` (Core Nomarchy user environment)
* `modules/home/hyprland.nix` (Window manager)
* `modules/home/waybar.nix` (Status bar)
* `modules/home/walker.nix` (App launcher and menus)
* `modules/home/theme-switcher.nix` (State file and scripts)
* `themes/nomarchy-palettes.nix` (Base16 Nix-colors dictionaries)
* `hosts/live-iso.nix` (Bootable USB configuration)
* `flake.nix` (Master entry point with core modules and test configurations)
* `installer/install-nomarchy.sh` (Interactive installer generating a clean downstream flake)
* `modules/system/default.nix` (Distro-wide OS defaults: SDDM, Plymouth, Audio, Network)
* `modules/home/default.nix` (Distro-wide user environment: Hyprland, Waybar, Styling)
* `bin/` (The collection of Omarchy productivity and config scripts)
* `themes/` (Distro-wide color palettes and backgrounds)
## Core Components & Logic
### 1. The Master Flake (`flake.nix`)
* **Inputs required:** `nixpkgs` (unstable), `nixos-hardware`, `disko`, `home-manager`, `nix-colors`.
* **Outputs required:** * `nixosModules.system`: Points to `modules/system`.
* `nixosModules.home`: Points to `modules/home`.
* `nixosConfigurations.installerIso`: Generates a bootable ISO importing standard minimal CD modules, adding `git`, `gum`, and `disko` to system packages, and copying `install-nomarchy.sh` to `/etc/`.
### 1. Separation of Concerns (Upstream vs. Downstream)
* **Upstream:** The `nomarchy/` directory contains the core logic. It is treated as an immutable input by the target system.
* **Downstream:** The user's `/etc/nixos/flake.nix` imports the upstream modules. The user's personal customizations are kept in `/etc/nixos/system.nix` and `/etc/nixos/home.nix`.
* **Merging:** NixOS automatically merges definitions. For example, if both the distro and the user add packages to `home.packages`, the final system includes the union of both lists.
### 2. The Interactive Installer (`installer/install-nomarchy.sh`)
Write a Bash script utilizing `gum` for UI prompts. The flow must execute as follows:
1. **Hardware Detection:** Read `/sys/class/dmi/id/product_name` and map it to a generic or specific `nixos-hardware` flake module.
2. **Storage Setup:** Prompt user for target drive. Prompt to choose between "Standard Ext4" or "Encrypted BTRFS (LUKS2)". Execute the corresponding Disko `.nix` file.
3. **User Details:** Prompt for target username.
4. **Login Preferences:** Prompt to choose between "SDDM Auto-login" (default) or "Require Password". Generate `/mnt/etc/nixos/login-preference.nix` based on the choice.
5. **Hardware Config:** Run `nixos-generate-config` into `/mnt/etc/nixos/`.
6. **Handoff Flake Generation:** Write a new `/mnt/etc/nixos/flake.nix` that imports the upstream Nomarchy distribution, the hardware config, the login preference, and sets up the user account.
7. **Version Control:** Initialize a git repository in `/mnt/etc/nixos/`, add files, and make an initial commit.
8. **Execution:** Run `nixos-install --flake /mnt/etc/nixos#default --no-root-passwd`.
The installer is designed to bootstrap a fresh system with this modular structure:
1. **Repo Detection:** Identifies the location of the Nomarchy source.
2. **Scaffolding:** Creates a new downstream `flake.nix` that imports Nomarchy core modules.
3. **User Files:** Generates skeleton `system.nix` and `home.nix` files for the user to customize.
4. **Bundling:** Copies the entire Nomarchy source to `/etc/nixos/nomarchy` so the system can be rebuilt offline.
### 3. Disko Configurations
* **Ext4:** Single EFI partition, single Ext4 root partition.
* **BTRFS+LUKS:** EFI partition, LUKS2 encrypted container holding a BTRFS filesystem. Subvolumes must include `@` (root), `@home` (user data), `@nix` (Nix store), and `@log` (logs).
### 3. Home Manager Integration
* **Hybrid Declarative State:** While the distro is declarative, it uses state files in `~/.config/home-manager/` (managed by the distro's scripts) to allow for instant UI feedback (theming, fonts, wallpapers) without needing a full system rebuild for every small tweak.
* **Script Wrapping:** All scripts in `bin/` are wrapped with their specific dependencies (`swayosd`, `pulseaudio`, `jq`, etc.) to ensure they work reliably across different hardware.
### 4. System Modules (`modules/system/`)
* **Boot:** Enable `systemd` initrd. Enable Plymouth with a custom Nomarchy theme derivation. Silence kernel logs completely (`quiet splash loglevel=3`).
* **Login:** Enable SDDM with Wayland support. Read the generated `login-preference.nix` to conditionally enable `autoLogin`. Enable Hyprland system-level dependencies.
### 4. Dynamic Theming
* **Palettes:** Themes are defined in simple `colors.toml` files. The distro dynamically generates Base16 palettes from these, allowing for infinite theme expansion without modifying Nix code.
### 5. Home Manager & Theming (`modules/home/`)
* **Architecture:** Must remain standalone (not built into the system NixOS config).
* **Aliases:** Define `sys-update` (`sudo nixos-rebuild switch`) and `env-update` (`home-manager switch`) in `home.shellAliases`.
* **Theme Engine:** Import `nix-colors`. Read a local untracked/state variable file (`~/.config/home-manager/theme-state.nix`) to determine the active theme from `nomarchy-palettes.nix`.
* **Styling:** Inject `nix-colors` variables (e.g., `${config.colorScheme.palette.base00}`) into Hyprland borders, Waybar CSS, Alacritty colors, and Walker CSS.
* **Walker & Scripting:** Configure Walker to run as a service. Write a `pkgs.writeShellScriptBin` script called `nomarchy-theme-selector` that uses Walker in `dmenu` mode to select a theme, overwrites `theme-state.nix`, stages it in git, and runs `env-update` to hot-reload the UI. Map this script to `Super + Alt + Space` in Hyprland.
## Execution Directives for Agent
1. Initialize the git repository.
2. Create the directory skeleton.
3. Generate the code for each file strictly adhering to declarative Nix principles, except for the installer script.
4. Ensure all Base16 variables used in Waybar and Walker CSS strings are properly escaped.
## Verification & Build
* **Test Installer:** `./bin/nomarchy-test-installer` (Builds a VM of the installer environment).
* **Check Integrity:** `nix flake check --impure` (Verifies all configurations evaluate).
* **Build ISO:** `nix build .#nixosConfigurations.installerIso.config.system.build.isoImage` (Generates the flashable USB image).