Most configurations in this repository have not been thoroughly tested (OR AT ALL!) and should NOT be used in any environments!
These are primarily untested AI generated configurations for learning purposes. Use at your own risk.
A unified NixOS configuration system for desktops, servers, macOS, and ChromeOS.
This repository contains unified configurations for multiple systems:
- NixOS Desktop/Laptop: Full system configuration for Linux desktops
- NixOS Server: Minimal configuration for home servers
- WSL2: NixOS configuration for Windows Subsystem for Linux
- macOS: Using nix-darwin for system configuration
- ChromeOS: Using standalone home-manager
cosmo/
├── flake.nix # Main entry point for all configurations
├── modules/ # NixOS modules
│ ├── common/ # Shared NixOS configuration
│ └── hosts/ # Host-specific configurations
│ ├── desktop/ # Desktop configuration
│ ├── desktop-zfs/# ZFS-based desktop configuration
│ ├── server/ # Server configuration
│ └── wsl2/ # WSL2 configuration
├── home/ # Home-manager configurations
│ ├── common/ # Shared home-manager config
│ ├── linux/ # Linux-specific home config
│ └── darwin/ # macOS-specific home config
├── pkgs/ # Custom package definitions
└── docs/ # Documentation
└── legacy.md # Legacy configuration history
-
Install Nix:
# For multi-user installation (recommended): sh <(curl -L https://nixos.org/nix/install) --daemon # For single-user installation: sh <(curl -L https://nixos.org/nix/install) --no-daemon
-
Enable Flakes:
mkdir -p ~/.config/nix echo "experimental-features = nix-command flakes" >> ~/.config/nix/nix.conf
-
Clone Repository:
git clone https://github.com/patflynn/cosmo.git cd cosmo
-
Install NixOS: If you're starting from scratch, install NixOS by following the official installation guide.
-
Add Hardware Configuration:
# Copy your existing hardware configuration sudo cp /etc/nixos/hardware-configuration.nix modules/hosts/desktop/ # Or use the ZFS configuration if applicable # sudo cp /etc/nixos/hardware-configuration.nix modules/hosts/desktop-zfs/
-
Adjust Host Settings: Edit
modules/hosts/desktop/default.nix
ormodules/hosts/server/default.nix
to update hostname, network settings, etc.
-
Install nix-darwin:
nix-build https://github.com/LnL7/nix-darwin/archive/master.tar.gz -A installer ./result/bin/darwin-installer
-
Install Home Manager:
nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager nix-channel --update
-
Configure System: If using an Intel Mac, edit
flake.nix
to changeaarch64-darwin
tox86_64-darwin
in the macbook configuration.
-
Install WSL2:
# Open PowerShell as Administrator and run: wsl --install
-
Install NixOS on WSL2:
- Download the latest NixOS-WSL tarball from NixOS-WSL releases
- Create a directory for NixOS:
mkdir C:\NixOS
- Import the tarball:
wsl --import NixOS C:\NixOS path\to\nixos-wsl.tar.gz --version 2
- Start NixOS:
wsl -d NixOS
-
Set Up User Account:
# Create a new user (as root) useradd -m -G wheel -s /bin/sh username passwd username # Edit sudoers to allow wheel group visudo # Uncomment: %wheel ALL=(ALL) ALL
-
Clone and Apply Configuration:
# Switch to your user su - username # Clone repository and apply configuration mkdir -p ~/hack cd ~/hack git clone https://github.com/patflynn/cosmo.git cd cosmo # Apply configuration sudo nixos-rebuild switch --flake .#wsl2
For detailed WSL2 setup instructions, see docs/wsl2-setup.md.
-
Enable Linux (Crostini):
- Open Chrome OS Settings
- Go to "Linux development environment" section
- Click "Turn On" and follow the setup instructions
-
Install Nix: Inside the Linux container:
sh <(curl -L https://nixos.org/nix/install) --no-daemon
-
Install Home Manager:
nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager nix-channel --update
# Test without making changes
sudo nixos-rebuild test --flake .#desktop
# Apply changes
sudo nixos-rebuild switch --flake .#desktop
# Test without making changes
sudo nixos-rebuild test --flake .#server
# Apply changes
sudo nixos-rebuild switch --flake .#server
# Test without making changes
sudo nixos-rebuild test --flake .#wsl2
# Apply changes
sudo nixos-rebuild switch --flake .#wsl2
# Test without making changes
darwin-rebuild check --flake .#macbook
# Apply changes
darwin-rebuild switch --flake .#macbook
# Test without making changes
home-manager build --flake .#chromeos
# Apply changes
home-manager switch --flake .#chromeos
-
System-wide Packages (NixOS): Edit
modules/common/default.nix
or the host-specific configuration inmodules/hosts/<host>/default.nix
. -
User Packages:
- For all platforms: Edit
home/common/default.nix
- For platform-specific packages: Edit
home/linux/default.nix
orhome/darwin/default.nix
- For all platforms: Edit
-
Create a new module: Create a file in the appropriate directory:
# For a new service in NixOS touch modules/common/myservice.nix # For a new application configuration touch home/common/myapp.nix
-
Import the new module: Add an import statement in the appropriate default.nix file.
This repository has undergone a significant restructuring to unify configurations across platforms. The legacy configuration files are preserved locally but removed from git tracking. See docs/legacy.md for details on the migration and preservation of hardware-specific configurations.
Testing documentation and procedures are available in the GitHub issues:
- Test and finalize desktop configuration
- Test and finalize server configuration
- Test and finalize macOS configuration
- Test and finalize ChromeOS configuration
-
Configuration doesn't apply: Make sure you're using the correct flake target and have the right permissions.
-
Hardware detection issues: Ensure your hardware configuration is correctly set up in the host-specific directory.
-
Package conflicts: Check for conflicting packages and use overlays to resolve them.
If you encounter issues, check:
- The NixOS Wiki
- The NixOS Discourse
- Or file an issue in this repository