How sandptel/regolith-nix works
Project Type & Purpose
• This is an “infrastructure‐as‐code”/configuration‐management project using Nix flakes.
• Its goal is to package, patch, and expose Regolith (i3/Sway desktop + ecosystem) as a reusable NixOS module and development shell.
File Structure
• Top-level:
• flake.nix, flake.lock – the root flake defining inputs, outputs, modules, and dev shells.
• README.md – usage instructions (installing Nix, using the flake).
• modules/ – NixOS module definitions, e.g., modules/regolith.nix.
• packages/ – individual Nix derivations for Regolith components (i3‐swap‐focus, i3status‐rs, regolith‐powerd, etc.).
• sway-regolith/ – an overlay with patches and a series file to modify the upstream sway‐regolith package.
• testing/ – a separate flake for CI/test configurations (home-manager and NixOS configs).
• regolith-look-* & regolith-powerd directories – local build artifacts or additional overlays.
README for Insights
• Inputs: nixpkgs, home-manager, regolith (this repo).
• Outputs:
• nixosConfigurations.<name> – a NixOS module that, when enabled, brings in all Regolith packages and sets up the desktop session.
• devShell (“nix develop”) containing all tooling.
• External services: Cachix for binary cache, Nix’s flakes feature.
Main Components & Their Relationships
a. Flake Root (flake.nix)
• Declares inputs: nixpkgs, home-manager, regolith.
• Exposes outputs: NixOS module, devShell, package set.
b. NixOS Module (modules/regolith.nix)
• Configures system.packages, services, sway session, input, status bar, etc.
• Pulls in packages from packages/ and the overlay sway-regolith.
c. Packages/Overlays
• packages/*: Nix derivations for each Regolith component.
• sway-regolith overlay: patches to upstream sway‐regolith, series for nixpkgs overlay.
d. Testing Flake (testing/flake.nix)
• Uses this repo as input; defines two test configurations:
• home-manager test shell
• NixOS VM config + hardware config for CI.
e. External Dependencies
• Cachix: binary cache endpoint.
• nixpkgs & home-manager: upstream flakes.
• nix daemon/CLI with flakes enabled.
Architectural Patterns & Principles
• Declarative configuration: represent flake.nix as the single source of truth.
• Overlays: show how sway-regolith feeds into nixpkgs to alter package derivations.
• Modularity: modules/ holds the NixOS module, packages/ holds individual derivations.
• Testing as code: separate flake under testing/ that depends on the main flake.