Skip to content

patflynn/cosmo

Folders and files

NameName
Last commit message
Last commit date
Mar 17, 2025
Mar 14, 2025
Mar 15, 2025
Mar 14, 2025
Mar 14, 2025
Mar 14, 2025
Mar 14, 2025
Mar 15, 2025
Jan 28, 2024
Mar 15, 2025

Repository files navigation

Cosmo: Cross-Platform NixOS Configuration

⚠️ WARNING: EXPERIMENTAL CONFIGURATIONS ⚠️

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.

NixOS Configuration Test Nix Format Check Daily Package Updates

Overview

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

Repository Structure

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

Setup Prerequisites

For All Platforms

  1. 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
  2. Enable Flakes:

    mkdir -p ~/.config/nix
    echo "experimental-features = nix-command flakes" >> ~/.config/nix/nix.conf
  3. Clone Repository:

    git clone https://github.com/patflynn/cosmo.git
    cd cosmo

NixOS-Specific Setup

  1. Install NixOS: If you're starting from scratch, install NixOS by following the official installation guide.

  2. 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/
  3. Adjust Host Settings: Edit modules/hosts/desktop/default.nix or modules/hosts/server/default.nix to update hostname, network settings, etc.

macOS-Specific Setup

  1. Install nix-darwin:

    nix-build https://github.com/LnL7/nix-darwin/archive/master.tar.gz -A installer
    ./result/bin/darwin-installer
  2. Install Home Manager:

    nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager
    nix-channel --update
  3. Configure System: If using an Intel Mac, edit flake.nix to change aarch64-darwin to x86_64-darwin in the macbook configuration.

WSL2-Specific Setup

  1. Install WSL2:

    # Open PowerShell as Administrator and run:
    wsl --install
  2. 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
  3. 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
  4. 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.

ChromeOS-Specific Setup

  1. Enable Linux (Crostini):

    • Open Chrome OS Settings
    • Go to "Linux development environment" section
    • Click "Turn On" and follow the setup instructions
  2. Install Nix: Inside the Linux container:

    sh <(curl -L https://nixos.org/nix/install) --no-daemon
  3. Install Home Manager:

    nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager
    nix-channel --update

Usage Instructions

NixOS Desktop

# Test without making changes
sudo nixos-rebuild test --flake .#desktop

# Apply changes
sudo nixos-rebuild switch --flake .#desktop

NixOS Server

# Test without making changes
sudo nixos-rebuild test --flake .#server

# Apply changes
sudo nixos-rebuild switch --flake .#server

WSL2

# Test without making changes
sudo nixos-rebuild test --flake .#wsl2

# Apply changes
sudo nixos-rebuild switch --flake .#wsl2

macOS

# Test without making changes
darwin-rebuild check --flake .#macbook

# Apply changes
darwin-rebuild switch --flake .#macbook

ChromeOS

# Test without making changes
home-manager build --flake .#chromeos

# Apply changes
home-manager switch --flake .#chromeos

Customization

Adding Packages

  1. System-wide Packages (NixOS): Edit modules/common/default.nix or the host-specific configuration in modules/hosts/<host>/default.nix.

  2. User Packages:

    • For all platforms: Edit home/common/default.nix
    • For platform-specific packages: Edit home/linux/default.nix or home/darwin/default.nix

Adding Custom Configuration

  1. 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
  2. Import the new module: Add an import statement in the appropriate default.nix file.

Migration Notes

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 Status

Testing documentation and procedures are available in the GitHub issues:

Troubleshooting

Common Issues

  1. Configuration doesn't apply: Make sure you're using the correct flake target and have the right permissions.

  2. Hardware detection issues: Ensure your hardware configuration is correctly set up in the host-specific directory.

  3. Package conflicts: Check for conflicting packages and use overlays to resolve them.

Getting Help

If you encounter issues, check:

  1. The NixOS Wiki
  2. The NixOS Discourse
  3. Or file an issue in this repository

About

Scripts to setup my development environment

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published