Vic's *Nix config.
at noden 182 lines 7.6 kB view raw view rendered
1# Vic's Nix Environment 2 3[![CI](https://github.com/vic/vix/actions/workflows/build-systems.yaml/badge.svg)](https://github.com/vic/vix/actions/workflows/build-systems.yaml) 4[![Cachix](https://img.shields.io/badge/cachix-vix-blue.svg)](https://app.cachix.org/cache/vix) 5[![Dendritic Pattern](https://img.shields.io/badge/pattern-dendritic-6c3.svg)](https://vic.github.io/dendrix/Dendritic.html) 6 7Welcome! This repository is vic's, modular, and shareable NixOS/MacOS/WSL configuration, designed both for my own use and as a template for anyone interested in the [Dendritic](https://vic.github.io/dendrix/Dendritic.html) pattern. Whether you're new to Nix or a seasoned user, you'll find reusable modules, clear structure, and plenty of pointers to help you get started or extend your own setup. 8 9--- 10 11## Table of Contents 12 131. [Overview](#overview) 142. [Getting Started](#getting-started) 153. [Host Configurations](#host-configurations) 164. [Everyday Usage](#everyday-usage) 175. [Shareable Modules & Features](#shareable-modules--features) 18 - [Community Modules Overview](#community-modules-overview) 196. [For Contributors](#for-contributors) 207. [Quaerendo Invenietis](#quaerendo-invenietis) 218. [CI & Caching](#ci--caching) 229. [References](#references) 23 24--- 25 26## Overview 27 28- **Dendritic Pattern:** 29 This repo uses [`vic/flake-file`](https://github.com/vic/flake-file) to automatically generate `flake.nix` from [inputs defined on modules](https://github.com/search?q=repo%3Avic%2Fvix%20%22flake-file.inputs%22%20language%3ANix&type=code), flattening dependencies for you. The entrypoint is [`modules/flake/dendritic.nix`](modules/flake/dendritic.nix). 30 [`vic/import-tree`](https://github.com/vic/import-tree) then auto-discovers and loads all `./modules/**/*.nix` files, so you can focus on writing modular, reusable code. 31 32- **Modular Structure:** 33 - `modules/community/`: Shareable, generic modules and features for any NixOS/Darwin system. 34 - `modules/vic/`: Personal, but some modules are reusable (see below). 35 - `modules/hosts/`: Per-host configuration (see [osConfigurations.nix](modules/flake/osConfigurations.nix)). 36 37--- 38 39## Getting Started 40 41It's easy to get going! Clone the repo, link it, and (optionally) set up secrets: 42 43```fish 44git clone https://github.com/vic/vix ~/vix 45ln -sfn ~/vix ~/.flake 46# (Optional) Setup SOPS keys if using secrets 47nix run path:~/vix#vic-sops-get -- --keyservice tcp://SOPS_SERVER:5000 -f SSH_KEY --setup - >> ~/.config/sops/age/keys.txt 48``` 49 50- **NixOS:** 51 `nixos-install --root /mnt --flake ~/vix#HOST` 52- **Darwin/WSL/Ubuntu:** 53 `nix run path:~/vix#os-rebuild -- HOST switch` 54 55--- 56 57## Host Configurations 58 59All hosts are defined in [`modules/hosts/`](modules/hosts/), and exposed via [`osConfigurations.nix`](modules/flake/osConfigurations.nix). 60 61| Host | Platform | Users | Notes | 62| -------- | ------------ | ---------- | ----------------------- | 63| bombadil | NixOS ISO | vic | USB installer, CI build | 64| varda | MacOS (M4) | vic | Mac Mini | 65| yavanna | MacOS (x86) | vic | MacBook Pro | 66| nienna | NixOS | vic | MacBook Pro | 67| mordor | NixOS | vic | ASUS ROG Tower | 68| annatar | WSL2 | vic | ASUS ROG Tower | 69| nargun | NixOS | vic | Lenovo Laptop | 70| smaug | NixOS | vic | HP Laptop | 71| bill | Ubuntu (ARM) | runner/vic | GH Action Runner | 72| bert | MacOS (ARM) | runner/vic | GH Action Runner | 73| tom | Ubuntu | runner/vic | GH Action Runner | 74 75--- 76 77## Everyday Usage 78 79- **Rebuild any host:** 80 `nix run path:~/vix#os-rebuild -- HOST switch` 81- **Rotate secrets:** 82 `nix develop .#nixos -c vic-sops-rotate` 83 84--- 85 86## Shareable Modules & Features 87 88This repository is not just for me! Many modules are designed to be reused in your own Nix setups, especially if you want to try the Dendritic pattern. You can browse the [`modules/community/`](https://github.com/vic/vix/tree/main/modules/community) directory, or use the `dendrix.vic-vix` tree in your own flake. 89 90```nix 91# Example usage in your own flake 92{ inputs, lib, ...}: { 93 imports = [ 94 # Use import-tree's API to select only the files you need 95 inputs.dendrix.vic-vix.filter(lib.hasSuffix "xfce-desktop.nix") 96 ]; 97} 98``` 99 100### Community Modules Overview 101 102#### features/ 103 104- **\_macos-keys.nix**: MacOS-specific key management helpers. 105- **all-firmware.nix**: Installs all available firmware blobs for broad hardware support. 106- **bootable-private.nix**: Example for hiding private files in bootable images. 107- **bootable.nix**: Makes a NixOS system image bootable (for ISOs/USB). 108- **darwin.nix**: MacOS-specific system settings and tweaks. 109- **gnome-desktop.nix**: GNOME desktop environment configuration. 110- **kde-desktop.nix**: KDE desktop environment configuration. 111- **kvm+amd.nix**: KVM/QEMU virtualization support for AMD CPUs. 112- **kvm+intel.nix**: KVM/QEMU virtualization support for Intel CPUs. 113- **macos-keys.nix**: (Alias/duplicate) MacOS key management. 114- **nix-setttings.nix**: Common Nix settings. 115- **nixos.nix**: NixOS-specific system settings. 116- **nvidia.nix**: NVIDIA GPU support and configuration. 117- **platform.nix**: Platform detection and helpers (Linux, Darwin, WSL, etc). 118- **rdesk+inputleap+anydesk.nix**: Remote desktop and input sharing tools. 119- **unfree.nix**: Enables unfree packages and related options. 120- **wl-broadcom.nix**: Broadcom wireless support for Linux. 121- **wsl.nix**: WSL2-specific tweaks and integration. 122- **xfce-desktop.nix**: XFCE desktop environment configuration. 123 124#### flake/ 125 126- **formatter.nix**: Nix formatter configuration for consistent code style. 127- **systems.nix**: Supported system types/architectures for the flake. 128 129#### home/ 130 131- **nix-index.nix**: Home-manager integration for `nix-index` (fast file search). 132- **nix-registry.nix**: Home-manager integration for Nix registry pinning. 133- **vscode-server.nix**: Home-manager config for VSCode server (remote editing). 134 135#### lib/ 136 137- **+hosts-by-system.nix**: Utility to group hosts by system type. 138- **+mk-os.nix**: Helper for creating OS-specific module sets. 139- **+unfree-module.nix**: Helper for enabling unfree modules. 140- **option.nix**: Option utilities for Nix modules. 141 142#### packages/ 143 144- **+gh-flake-update.nix**: Script to update flake inputs and create a GitHub PR. 145- **+os-rebuild.nix**: Universal rebuild script for any host. 146 147--- 148 149## For Contributors 150 151- Contributions are accepted mostly for files under `modules/community/`. 152- All other modules like `modules/hosts/HOST/`, or `modules/vic` are most 153 likely only useful for me, but the most I can move to community the better. 154- My hosts are exposed at [`modules/flake/osConfigurations.nix`](modules/flake/osConfigurations.nix). 155 156--- 157 158## Quaerendo Invenietis 159 160If you need help with something, just ask. I'll be happy to help. 161 162--- 163 164## CI & Caching 165 166- [GitHub Actions](.github/workflows/build-systems.yaml) builds and caches all hosts. 167- [Cachix](https://app.cachix.org/cache/vix) used for binary caching. 168 169There's also actions for reminding me to SOP rotate secrets and flake updates. 170 171--- 172 173## References 174 175- [Dendritic Pattern](https://github.com/mightyiam/dendritic) 176- [vic/flake-file](https://github.com/vic/flake-file) 177- [vic/import-tree](https://github.com/vic/import-tree) 178- [Dendrix Layers](https://github.com/vic/dendrix) 179 180--- 181 182_For more details, see the [modules](modules/) directory and comments in each file._