···11-# Vic's Nix Environment
11+# vix - A Dendritic NixOS Configuration
22+33+A complete example of the **dendritic pattern** for NixOS, using [den](https://github.com/vic/den) to achieve composable, aspect-oriented system configuration.
44+55+This repository demonstrates how to structure a real-world NixOS setup using:
66+- [den](https://github.com/vic/den) - Dendritic configuration framework
77+- [flake-aspects](https://github.com/vic/flake-aspects) - Aspect-oriented programming for Nix
88+- [flake-file](https://github.com/vic/flake-file) - Auto-generated flake management
99+- [import-tree](https://github.com/vic/import-tree) - Automatic module discovery
1010+1111+## Try It Out
1212+1313+Experience the dendritic pattern immediately:
1414+```bash
1515+nix run github:vic/vix/den#vm
1616+```
1717+1818+This launches a VM configured with the same dendritic structure as the production system.
1919+2020+## Understanding the Dendritic Structure
2121+2222+### 🎯 Core Concept: Aspects Over Modules
2323+2424+Traditional NixOS configurations use modules that get imported into a monolithic tree. The dendritic pattern uses **aspects**—named, composable units that can be mixed and matched without creating deep import hierarchies.
2525+2626+### 📁 Repository Structure
2727+2828+```
2929+modules/
3030+├── dendritic.nix # Entry point: initializes dendritic setup
3131+├── vix.nix # Custom aspect namespace
3232+├── hosts.nix # Host declarations & default profiles
3333+├── vm.nix # VM launcher for development
3434+│
3535+├── community/ # Reusable aspects (candidate for upstreaming)
3636+│ ├── profile.nix # Host/user profile hooks
3737+│ ├── unfree.nix # Aspect for unfree packages
3838+│ ├── autologin.nix # Parametric autologin aspect
3939+│ ├── *-desktop.nix # Desktop environment aspects
4040+│ └── dev-laptop.nix # Composed laptop aspect
4141+│
4242+├── vic/ # User-specific aspects
4343+│ ├── common-host-env.nix # User environment composition
4444+│ ├── admin.nix # User permissions aspect
4545+│ ├── fish.nix # Shell configuration aspect
4646+│ ├── dots.nix # Dotfile management aspect
4747+│ └── *.nix # Individual feature aspects
4848+│
4949+└── hosts/
5050+ └── nargun.nix # Host-specific aspect composition with vm variant.
5151+```
5252+5353+## Key Benefits of This Structure
5454+5555+### 1. **Namespace Isolation** ([`vix.nix`](modules/vix.nix))
5656+5757+Created my own aspect namespace without polluting the global scope:
5858+5959+```nix
6060+# vix is actually: den.aspects.vix.provides.
6161+{ vix, ... }: { # read access
6262+ vix.gaming = ...; # write access
6363+}
6464+```
6565+6666+**Benefit**: All my aspects live under `vix.*`, making it clear what's yours vs. what comes from den or other sources.
6767+6868+### 2. **Declarative Host Registration** ([`hosts.nix`](modules/hosts.nix))
6969+7070+Declare hosts and users in one place:
7171+7272+```nix
7373+den.hosts.x86_64-linux.nargun.users.vic = { };
7474+den.hosts.x86_64-linux.nargun-vm.users.vic = { };
7575+```
7676+7777+**Benefit**: Clear overview of your infrastructure. No hidden host definitions scattered across files.
7878+7979+### 3. **Profile Hooks for Automatic Composition** ([`profile.nix`](modules/community/profile.nix))
8080+8181+Set default includes for all hosts and users:
8282+8383+```nix
8484+den.default.host._.host.includes = [
8585+ vix.host-profile
8686+ den.home-manager
8787+];
8888+8989+den.default.user._.user.includes = [
9090+ vix.user-profile
9191+];
9292+```
9393+9494+**Benefit**: Every host/user automatically gets base configuration without manual wiring. Add once, applies everywhere.
9595+9696+### 4. **Parametric Aspects** ([`profile.nix`](modules/community/profile.nix))
9797+9898+Profiles can dynamically select aspects based on host/user names:
9999+100100+```nix
101101+vix.host-profile = { host }: {
102102+ includes = [
103103+ (vix.${host.name} or { }) # Host-specific if exists
104104+ (vix.host-name host) # Parametric hostname setter
105105+ vix.state-version # Common to all hosts
106106+ ];
107107+};
108108+```
109109+110110+**Benefit**: Generic code that adapts to context. No hardcoded names, fully reusable.
111111+112112+### 5. **Aspect Composition** ([`nargun.nix`](modules/hosts/nargun.nix))
113113+114114+Hosts are built by composing aspects:
115115+116116+```nix
117117+vix.nargun.includes = [
118118+ vix.nargun._.base
119119+ vix.nargun._.hw
120120+];
121121+122122+vix.nargun.provides = {
123123+ hw.includes = [
124124+ vix.mexico # Locale configuration
125125+ vix.bootable # Boot loader setup
126126+ vix.kvm-amd # Virtualization support
127127+ vix.niri-desktop # Window manager
128128+ vix.kde-desktop # Fallback desktop
129129+ ];
130130+131131+ base.includes = [
132132+ vix.dev-laptop # Common laptop features
133133+ ];
134134+};
135135+```
136136+137137+**Benefit**:
138138+- Mix hardware configs, desktops, and features freely
139139+- Share common setups between real hardware and VM
140140+- Easy to see what a host includes at a glance
141141+142142+### 6. **Shared Configuration Between Host Variants** ([`nargun.nix`](modules/hosts/nargun.nix))
143143+144144+Production and VM hosts share a base:
145145+146146+```nix
147147+vix.nargun-vm.includes = [
148148+ vix.nargun._.base # Shared configuration
149149+ vix.nargun._.vm # VM-specific overrides
150150+];
151151+```
152152+153153+**Benefit**: Test your actual configuration in a VM with minimal differences. No "works on my VM" problems.
154154+155155+### 7. **Hierarchical Aspect Organization** ([`nargun.nix`](modules/hosts/nargun.nix))
156156+157157+Use `provides` to create sub-aspects:
158158+159159+```nix
160160+vix.nargun.provides = {
161161+ base.includes = [...]; # vix.nargun._.base
162162+ hw.includes = [...]; # vix.nargun._.hw
163163+ vm.includes = [...]; # vix.nargun._.vm
164164+};
165165+```
166166+167167+**Benefit**: Organize related configuration without creating separate files. The `_` makes sub-aspects non-recursive.
168168+169169+### 8. **User Environment Composition** ([`common-host-env.nix`](modules/vic/common-host-env.nix))
170170+171171+Compose user environments from small, focused aspects:
172172+173173+```nix
174174+vix.vic._.common-host-env = { host, user }: {
175175+ includes = map (f: f { inherit host user; }) [
176176+ vix.vic.provides.admin
177177+ vix.vic.provides.fish
178178+ vix.vic.provides.terminals
179179+ vix.vic.provides.editors
180180+ vix.vic.provides.doom-btw
181181+ vix.vic.provides.vim-btw
182182+ // ... more aspects
183183+ ];
184184+};
185185+```
186186+187187+**Benefit**:
188188+- Each aspect is small, testable, focused
189189+- Easy to enable/disable features
190190+- Functions receive context (`host`, `user`) for parametric behavior
191191+192192+### 9. **Parametric, Generic Aspects** ([`admin.nix`](modules/vic/admin.nix), [`fish.nix`](modules/vic/fish.nix))
193193+194194+Aspects accept parameters instead of hardcoding values:
195195+196196+```nix
197197+# admin.nix
198198+vix.vic.provides.admin = { user, ... }: {
199199+ nixos.users.users.${user.userName} = {
200200+ isNormalUser = true;
201201+ extraGroups = [ "wheel" "networkmanager" ];
202202+ };
203203+};
204204+205205+# fish.nix
206206+vix.vic.provides.fish = { user, ... }: {
207207+ nixos.users.users.${user.userName}.shell = pkgs.fish;
208208+ homeManager.programs.fish.enable = true;
209209+};
210210+```
211211+212212+**Benefit**: Aspects are reusable across different users/hosts. Change username once in host declaration, everything updates.
213213+214214+### 10. **Multi-Class Aspects** ([`fish.nix`](modules/vic/fish.nix))
215215+216216+Single aspect can configure multiple "classes" (nixos, homeManager, darwin, etc.):
217217+218218+```nix
219219+vix.vic.provides.fish = { user, ... }: {
220220+ nixos = { pkgs, ... }: {
221221+ programs.fish.enable = true;
222222+ users.users.${user.userName}.shell = pkgs.fish;
223223+ };
224224+225225+ homeManager = {
226226+ programs.fish.enable = true;
227227+ };
228228+};
229229+```
230230+231231+**Benefit**: Related configuration stays together. System-level and user-level config for one feature in one file.
232232+233233+### 11. **Reusable Community Aspects** ([`modules/community/`](modules/community/))
234234+235235+Structure promotes sharing:
236236+237237+```
238238+community/
239239+├── profile.nix # Integration hooks
240240+├── unfree.nix # Unfree package handling
241241+├── autologin.nix # Parametric autologin
242242+├── *-desktop.nix # Desktop environments
243243+└── dev-laptop.nix # Feature compositions
244244+```
245245+246246+**Benefit**:
247247+- Clear separation of reusable vs. personal
248248+- Easy to upstream to [denful](https://github.com/vic/denful)
249249+- Stop copy-pasting, start sharing
225033-[](https://github.com/vic/vix/actions/workflows/build-systems.yaml)
44-[](https://app.cachix.org/cache/vix)
55-[](https://vic.github.io/dendrix/Dendritic.html)
251251+### 12. **Functional Aspects with Parameters** ([`unfree.nix`](modules/community/unfree.nix))
625277-Welcome! 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.
253253+Aspects can be functions that return aspects:
825499----
255255+```nix
256256+vix.unfree = allowed-names: {
257257+ __functor = _: { class, aspect-chain }: {
258258+ ${class}.nixpkgs.config.allowUnfreePredicate =
259259+ pkg: builtins.elem (lib.getName pkg) allowed-names;
260260+ };
261261+};
102621111-## Table of Contents
263263+# Usage:
264264+vix.vic.provides.editors.includes = [
265265+ (vix.unfree [ "cursor" "vscode" ])
266266+];
267267+```
268268+269269+**Benefit**: Create aspect factories. Same pattern, different parameters. No duplication.
270270+271271+### 13. **Development Workflow with VM** ([`vm.nix`](modules/vm.nix))
272272+273273+Package your system as a runnable VM:
274274+275275+```nix
276276+packages.vm = pkgs.writeShellApplication {
277277+ name = "vm";
278278+ text = ''
279279+ ${inputs.self.nixosConfigurations.nargun-vm.config.system.build.vm}/bin/run-nargun-vm-vm "$@"
280280+ '';
281281+};
282282+```
122831313-1. [Overview](#overview)
1414-2. [Getting Started](#getting-started)
1515-3. [Host Configurations](#host-configurations)
1616-4. [Everyday Usage](#everyday-usage)
1717-5. [Shareable Modules & Features](#shareable-modules--features)
1818- - [Community Modules Overview](#community-modules-overview)
1919-6. [For Contributors](#for-contributors)
2020-7. [Quaerendo Invenietis](#quaerendo-invenietis)
2121-8. [CI & Caching](#ci--caching)
2222-9. [References](#references)
284284+**Benefit**:
285285+- Test configuration changes without rebooting
286286+- Share exact system state with others via `nix run`
287287+- Rapid iteration during development
232882424----
289289+### 14. **Smart Dotfile Management** ([`dots.nix`](modules/vic/dots.nix))
252902626-## Overview
291291+Out-of-store symlinks for live editing:
272922828-- **Dendritic Pattern:**
2929- 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).
3030- [`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.
293293+```nix
294294+dotsLink = path:
295295+ config.lib.file.mkOutOfStoreSymlink
296296+ "${config.home.homeDirectory}/.flake/modules/vic/dots/${path}";
312973232-- **Modular Structure:**
3333- - `modules/community/`: Shareable, generic modules and features for any NixOS/Darwin system.
3434- - `modules/vic/`: Personal, but some modules are reusable (see below).
3535- - `modules/hosts/`: Per-host configuration (see [osConfigurations.nix](modules/flake/osConfigurations.nix)).
298298+home.file.".config/nvim".source = dotsLink "config/nvim";
299299+```
363003737----
301301+**Benefit**: Edit dotfiles directly, changes reflect immediately without rebuilding. Best of both worlds.
383023939-## Getting Started
303303+## Getting Started with Dendritic
403044141-It's easy to get going! Clone the repo, link it, and (optionally) set up secrets:
305305+### 1. Bootstrap from Template
423064343-```fish
4444-git clone https://github.com/vic/vix ~/vix
4545-ln -sfn ~/vix ~/.flake
4646-# (Optional) Setup SOPS keys if using secrets
4747-nix run path:~/vix#vic-sops-get -- --keyservice tcp://SOPS_SERVER:5000 -f SSH_KEY --setup - >> ~/.config/sops/age/keys.txt
307307+```bash
308308+nix flake init -t github:vic/flake-file#dendritic
309309+nix flake update
48310```
493115050-- **NixOS:**
5151- `nixos-install --root /mnt --flake ~/vix#HOST`
5252-- **Darwin/WSL/Ubuntu:**
5353- `nix run path:~/vix#os-rebuild -- HOST switch`
312312+This creates:
313313+- [`modules/dendritic.nix`](modules/dendritic.nix) - Den initialization
314314+- Basic structure following the pattern
543155555----
316316+### 2. Create Your Namespace ([`vix.nix`](modules/vix.nix))
563175757-## Host Configurations
318318+```nix
319319+{ config, lib, ... }:
320320+{
321321+ den.aspects.myname.provides = { };
322322+ _module.args.myname = config.den.aspects.myname.provides;
323323+ flake.myname = config.den.aspects.myname.provides;
324324+ imports = [ (lib.mkAliasOptionModule [ "myname" ] [ "den" "aspects" "myname" "provides" ]) ];
325325+}
326326+```
583275959-All hosts are defined in [`modules/hosts/`](modules/hosts/), and exposed via [`osConfigurations.nix`](modules/flake/osConfigurations.nix).
328328+### 3. Register Hosts ([`hosts.nix`](modules/hosts.nix))
603296161-| Host | Platform | Users | Notes |
6262-| -------- | ------------ | ---------- | ----------------------- |
6363-| bombadil | NixOS ISO | vic | USB installer, CI build |
6464-| varda | MacOS (M4) | vic | Mac Mini |
6565-| yavanna | MacOS (x86) | vic | MacBook Pro |
6666-| nienna | NixOS | vic | MacBook Pro |
6767-| mordor | NixOS | vic | ASUS ROG Tower |
6868-| annatar | WSL2 | vic | ASUS ROG Tower |
6969-| nargun | NixOS | vic | Lenovo Laptop |
7070-| smaug | NixOS | vic | HP Laptop |
7171-| bill | Ubuntu (ARM) | runner/vic | GH Action Runner |
7272-| bert | MacOS (ARM) | runner/vic | GH Action Runner |
7373-| tom | Ubuntu | runner/vic | GH Action Runner |
330330+```nix
331331+{ myname, den, ... }:
332332+{
333333+ den.hosts.x86_64-linux.myhost.users.myuser = { };
743347575----
335335+ den.default.host._.host.includes = [
336336+ myname.host-profile
337337+ den.home-manager
338338+ ];
763397777-## Everyday Usage
340340+ den.default.user._.user.includes = [
341341+ myname.user-profile
342342+ ];
343343+}
344344+```
783457979-- **Rebuild any host:**
8080- `nix run path:~/vix#os-rebuild -- HOST switch`
8181-- **Rotate secrets:**
8282- `nix develop .#nixos -c vic-sops-rotate`
346346+### 4. Create Profile Hooks (see [`profile.nix`](modules/community/profile.nix))
833478484----
348348+```nix
349349+myname.host-profile = { host }: {
350350+ includes = [
351351+ (myname.${host.name} or { })
352352+ myname.state-version
353353+ ];
354354+};
853558686-## Shareable Modules & Features
356356+myname.user-profile = { host, user }: {
357357+ includes = [
358358+ ((myname.${user.name}._.common-host-env or (_: { })) { inherit host user; })
359359+ ];
360360+};
361361+```
873628888-This 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.
363363+### 5. Define Host Aspects (see [`nargun.nix`](modules/hosts/nargun.nix))
8936490365```nix
9191-# Example usage in your own flake
9292-{ inputs, lib, ...}: {
9393- imports = [
9494- # Use import-tree's API to select only the files you need
9595- inputs.dendrix.vic-vix.filter(lib.hasSuffix "xfce-desktop.nix")
366366+{ myname, ... }:
367367+{
368368+ myname.myhost.includes = [
369369+ myname.bootable
370370+ myname.networking
371371+ myname.my-desktop
96372 ];
97373}
98374```
99375100100-### Community Modules Overview
376376+### 6. Build User Environment (see [`common-host-env.nix`](modules/vic/common-host-env.nix))
101377102102-#### features/
378378+```nix
379379+myname.myuser._.common-host-env = { host, user }: {
380380+ includes = map (f: f { inherit host user; }) [
381381+ myname.myuser.provides.admin
382382+ myname.myuser.provides.shell
383383+ myname.myuser.provides.editor
384384+ ];
385385+};
386386+```
103387104104-- **\_macos-keys.nix**: MacOS-specific key management helpers.
105105-- **all-firmware.nix**: Installs all available firmware blobs for broad hardware support.
106106-- **bootable-private.nix**: Example for hiding private files in bootable images.
107107-- **bootable.nix**: Makes a NixOS system image bootable (for ISOs/USB).
108108-- **darwin.nix**: MacOS-specific system settings and tweaks.
109109-- **gnome-desktop.nix**: GNOME desktop environment configuration.
110110-- **kde-desktop.nix**: KDE desktop environment configuration.
111111-- **kvm+amd.nix**: KVM/QEMU virtualization support for AMD CPUs.
112112-- **kvm+intel.nix**: KVM/QEMU virtualization support for Intel CPUs.
113113-- **macos-keys.nix**: (Alias/duplicate) MacOS key management.
114114-- **nix-setttings.nix**: Common Nix settings.
115115-- **nixos.nix**: NixOS-specific system settings.
116116-- **nvidia.nix**: NVIDIA GPU support and configuration.
117117-- **platform.nix**: Platform detection and helpers (Linux, Darwin, WSL, etc).
118118-- **rdesk+inputleap+anydesk.nix**: Remote desktop and input sharing tools.
119119-- **unfree.nix**: Enables unfree packages and related options.
120120-- **wl-broadcom.nix**: Broadcom wireless support for Linux.
121121-- **wsl.nix**: WSL2-specific tweaks and integration.
122122-- **xfce-desktop.nix**: XFCE desktop environment configuration.
388388+## Design Principles
123389124124-#### flake/
390390+### Aspect Composition Over Module Imports
125391126126-- **formatter.nix**: Nix formatter configuration for consistent code style.
127127-- **systems.nix**: Supported system types/architectures for the flake.
392392+**Traditional NixOS:**
393393+```nix
394394+imports = [
395395+ ./hardware.nix
396396+ ./networking.nix
397397+ ./desktop.nix
398398+ ./users/vic.nix
399399+];
400400+```
128401129129-#### home/
402402+**Dendritic Pattern:**
403403+```nix
404404+vix.nargun.includes = [
405405+ vix.hardware
406406+ vix.networking
407407+ vix.desktop
408408+];
409409+```
410410+411411+Benefits:
412412+- Aspects are named and first-class
413413+- Can be referenced, composed, and parameterized
414414+- No relative path management
415415+- Clear dependency relationships
416416+417417+### Parametric by Default
418418+419419+All aspects should accept `{ host, user }` when relevant:
420420+421421+```nix
422422+# ❌ Hardcoded
423423+vix.vic.admin.nixos.users.users.vic = { ... };
130424131131-- **nix-index.nix**: Home-manager integration for `nix-index` (fast file search).
132132-- **nix-registry.nix**: Home-manager integration for Nix registry pinning.
133133-- **vscode-server.nix**: Home-manager config for VSCode server (remote editing).
425425+# ✅ Parametric
426426+vix.vic.provides.admin = { user, ... }: {
427427+ nixos.users.users.${user.userName} = { ... };
428428+};
429429+```
134430135135-#### lib/
431431+### Separate Personal from Shareable
136432137137-- **+hosts-by-system.nix**: Utility to group hosts by system type.
138138-- **+mk-os.nix**: Helper for creating OS-specific module sets.
139139-- **+unfree-module.nix**: Helper for enabling unfree modules.
140140-- **option.nix**: Option utilities for Nix modules.
433433+- `modules/community/` - Reusable, generic, upstreamable
434434+- `modules/{yourname}/` - Personal, specific to your needs
435435+- `modules/hosts/` - Host-specific configuration
141436142142-#### packages/
437437+When something in your personal namespace becomes useful, move it to `community/` and consider upstreaming to [denful](https://github.com/vic/denful).
143438144144-- **+gh-flake-update.nix**: Script to update flake inputs and create a GitHub PR.
145145-- **+os-rebuild.nix**: Universal rebuild script for any host.
439439+## Learning Path
146440147147----
441441+Follow this sequence to understand the pattern:
148442149149-## For Contributors
443443+1. **[`dendritic.nix`](modules/dendritic.nix)** - How den is initialized
444444+2. **[`vix.nix`](modules/vix.nix)** - Creating a custom namespace
445445+3. **[`hosts.nix`](modules/hosts.nix)** - Host registration and default hooks
446446+4. **[`profile.nix`](modules/community/profile.nix)** - Profile system for automatic composition
447447+5. **[`nargun.nix`](modules/hosts/nargun.nix)** - Host aspect composition example
448448+6. **[`common-host-env.nix`](modules/vic/common-host-env.nix)** - User environment composition
449449+7. **[`admin.nix`](modules/vic/admin.nix)**, **[`fish.nix`](modules/vic/fish.nix)** - Simple parametric aspects
450450+8. **[`unfree.nix`](modules/community/unfree.nix)** - Advanced: functional aspects
451451+9. **[`vm.nix`](modules/vm.nix)** - Development workflow
150452151151-- Contributions are accepted mostly for files under `modules/community/`.
152152-- All other modules like `modules/hosts/HOST/`, or `modules/vic` are most
153153- likely only useful for me, but the most I can move to community the better.
154154-- My hosts are exposed at [`modules/flake/osConfigurations.nix`](modules/flake/osConfigurations.nix).
453453+## Contributing to the Dendritic Ecosystem
155454156156----
455455+Found something useful in this repo? Instead of copy-pasting:
157456158158-## Quaerendo Invenietis
457457+1. Move it to `modules/community/` if it's not already there
458458+2. Make it parametric and generic
459459+3. Open an issue to discuss upstreaming to [denful](https://github.com/vic/denful)
159460160160-If you need help with something, just ask. I'll be happy to help.
461461+The goal is to build a library of well-maintained, composable aspects that everyone can benefit from.
161462162162----
463463+## Migration Notes
163464164164-## CI & Caching
465465+This repository represents a complete rewrite of vix using the dendritic pattern. The old monolithic approach is preserved in the `main` branch for reference.
165466166166-- [GitHub Actions](.github/workflows/build-systems.yaml) builds and caches all hosts.
167167-- [Cachix](https://app.cachix.org/cache/vix) used for binary caching.
467467+**Development workflow:** Boot from stable `main` branch, edit this `den` branch, test changes via `nix run .#vm` without rebooting.
168468169169-There's also actions for reminding me to SOP rotate secrets and flake updates.
469469+## Why Dendritic?
170470171171----
471471+Traditional NixOS configurations grow into tangled import trees. You end up with:
472472+- Deep hierarchies hard to navigate
473473+- Unclear dependencies
474474+- Difficulty reusing configuration
475475+- Copy-paste proliferation
172476173173-## References
477477+The dendritic pattern solves this by:
478478+- **Named aspects** instead of file paths
479479+- **Composition** instead of inheritance
480480+- **Parameters** instead of hardcoded values
481481+- **Namespaces** instead of global scope
482482+- **Automatic discovery** via import-tree
483483+- **First-class functions** for aspect factories
174484175175-- [Dendritic Pattern](https://github.com/mightyiam/dendritic)
176176-- [vic/flake-file](https://github.com/vic/flake-file)
177177-- [vic/import-tree](https://github.com/vic/import-tree)
178178-- [Dendrix Layers](https://github.com/vic/dendrix)
485485+The result: configuration that's easier to understand, modify, test, and share.
179486180487---
181488182182-_For more details, see the [modules](modules/) directory and comments in each file._
489489+**See also:** [den documentation](https://github.com/vic/den), [flake-aspects](https://github.com/vic/flake-aspects), [denful](https://github.com/vic/denful)
···11-# this private file exists just to make an example
22-# how to hide private files from dennix, even in a
33-# community shared tree.
44-{
55- flake.modules.nixos.bootable =
66- { modulesPath, ... }:
77- {
88-99- time.timeZone = "America/Mexico_City";
1010-1111- imports = [
1212- # include this once instead of doing in every host.
1313- (modulesPath + "/installer/scan/not-detected.nix")
1414- ];
1515- };
1616-}
-80
modules/community/features/bootable.nix
···11-{
22-33- flake.modules.nixos.bootable =
44- { lib, ... }:
55- {
66- # Bootloader.
77- boot.loader.systemd-boot.enable = true;
88- boot.loader.efi.canTouchEfiVariables = true;
99- powerManagement.enable = true;
1010-1111- # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant.
1212-1313- # Configure network proxy if necessary
1414- # networking.proxy.default = "http://user:password@proxy:port/";
1515- # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";
1616-1717- # Enable networking
1818- networking.networkmanager.enable = true;
1919-2020- # Select internationalisation properties.
2121- i18n.defaultLocale = "en_US.UTF-8";
2222-2323- # Enable the X11 windowing system.
2424- services.xserver.enable = true;
2525-2626- # Configure keymap in X11
2727- services.xserver.xkb = {
2828- layout = "us";
2929- variant = "";
3030- };
3131-3232- # Enable CUPS to print documents.
3333- # services.printing.enable = true;
3434-3535- # Enable sound with pipewire.
3636- # sound.enable = true;
3737- hardware.bluetooth.enable = true;
3838- hardware.bluetooth.powerOnBoot = true;
3939- services.pulseaudio.enable = false;
4040- services.blueman.enable = true;
4141- security.rtkit.enable = true;
4242- services.pipewire = {
4343- enable = true;
4444- alsa.enable = true;
4545- alsa.support32Bit = true;
4646- pulse.enable = true;
4747- # If you want to use JACK applications, uncomment this
4848- #jack.enable = true;
4949-5050- # use the example session manager (no others are packaged yet so this is enabled by default,
5151- # no need to redefine it in your config for now)
5252- #media-session.enable = true;
5353- };
5454-5555- # Enable touchpad support (enabled default in most desktopManager).
5656- # services.xserver.libinput.enable = true;
5757-5858- # Some programs need SUID wrappers, can be configured further or are
5959- # started in user sessions.
6060- # programs.mtr.enable = true;
6161- # programs.gnupg.agent = {
6262- # enable = true;
6363- # enableSSHSupport = true;
6464- # };
6565-6666- # List services that you want to enable:
6767-6868- # Enable the OpenSSH daemon.
6969- # services.openssh.enable = true;
7070-7171- # Open ports in the firewall.
7272- # networking.firewall.allowedTCPPorts = [ ... ];
7373- # networking.firewall.allowedUDPPorts = [ ... ];
7474- # Or disable the firewall altogether.
7575- # networking.firewall.enable = false;
7676-7777- networking.useDHCP = lib.mkDefault true;
7878- };
7979-8080-}
···11-# Do not modify this file! It was generated by ‘nixos-generate-config’
22-# and may be overwritten by future invocations. Please make changes
33-# to /etc/nixos/configuration.nix instead.
44-{
55-66- flake.modules.nixos.mordor = {
77- boot.initrd.availableKernelModules = [
88- "xhci_pci"
99- "ahci"
1010- "usbhid"
1111- "usb_storage"
1212- "sd_mod"
1313- ];
1414- };
1515-}
···11-# Edit this configuration file to define what should be installed on
22-# your system. Help is available in the configuration.nix(5) man page
33-# and in the NixOS manual (accessible by running ‘nixos-help’).
44-55-{
66- inputs,
77- ...
88-}:
99-let
1010- flake.modules.nixos.nienna.imports = with inputs.self.modules.nixos; [
1111- vic
1212- xfce-desktop
1313- macos-keys
1414- kvm-intel
1515- wl-broadcom
1616- nienna-unfree
1717- ];
1818- nienna-unfree = inputs.self.lib.unfree-module [
1919- "broadcom-sta"
2020- ];
2121-in
2222-{
2323- inherit flake;
2424-}
-24
modules/hosts/nienna/filesystems.nix
···11-# Do not modify this file! It was generated by ‘nixos-generate-config’
22-# and may be overwritten by future invocations. Please make changes
33-# to /etc/nixos/configuration.nix instead.
44-{
55- flake.modules.nixos.nienna = {
66-77- fileSystems."/" = {
88- device = "/dev/disk/by-uuid/389d7756-a765-4be8-81eb-6712e893e705";
99- fsType = "ext4";
1010- };
1111-1212- fileSystems."/boot" = {
1313- device = "/dev/disk/by-uuid/67E3-17ED";
1414- fsType = "vfat";
1515- options = [
1616- "fmask=0077"
1717- "dmask=0077"
1818- ];
1919- };
2020-2121- swapDevices = [ ];
2222-2323- };
2424-}
-19
modules/hosts/nienna/hardware-configuration.nix
···11-# Do not modify this file! It was generated by ‘nixos-generate-config’
22-# and may be overwritten by future invocations. Please make changes
33-# to /etc/nixos/configuration.nix instead.
44-{
55-66- flake.modules.nixos.nienna = {
77- boot.initrd.availableKernelModules = [
88- "uhci_hcd"
99- "ehci_pci"
1010- "ahci"
1111- "firewire_ohci"
1212- "usbhid"
1313- "usb_storage"
1414- "sd_mod"
1515- "sdhci_pci"
1616- ];
1717- };
1818-1919-}
-15
modules/hosts/smaug/configuration.nix
···11-# Edit this configuration file to define what should be installed on
22-# your system. Help is available in the configuration.nix(5) man page
33-# and in the NixOS manual (accessible by running ‘nixos-help’).
44-{ inputs, ... }:
55-{
66- flake.modules.nixos.smaug.imports = with inputs.self.modules.nixos; [
77- vic
88- xfce-desktop
99- macos-keys
1010- kvm-intel
1111- wl-broadcom
1212- nvidia
1313- all-firmware
1414- ];
1515-}
-32
modules/hosts/smaug/filesystems.nix
···11-# Do not modify this file! It was generated by ‘nixos-generate-config’
22-# and may be overwritten by future invocations. Please make changes
33-# to /etc/nixos/configuration.nix instead.
44-{
55-66- flake.modules.nixos.smaug = {
77-88- fileSystems."/" = {
99- device = "/dev/disk/by-label/nixos";
1010- fsType = "ext4";
1111- };
1212-1313- fileSystems."/boot" = {
1414- device = "/dev/disk/by-label/boot";
1515- fsType = "vfat";
1616- options = [
1717- "fmask=0077"
1818- "dmask=0077"
1919- ];
2020- };
2121-2222- fileSystems."/home" = {
2323- device = "/dev/disk/by-label/home";
2424- fsType = "ext4";
2525- };
2626-2727- swapDevices = [
2828- { device = "/dev/disk/by-label/swap"; }
2929- ];
3030-3131- };
3232-}
···11-{
22- lib,
33- inputs,
44- ...
55-}:
66-{
77- jj-git-init.description = "init jj to follow git branch";
88- jj-git-init.argumentNames = [ "branch" ];
99- jj-git-init.body = ''
1010- jj git init --colocate
1111- jj bookmark track "$branch@origin"
1212- jj config set --repo "revset-aliases.'trunk()'" "$branch@origin"
1313- '';
1414-1515- jj-desc.body = ''
1616- jj describe --edit -m "$(echo -e "\n")$(jj status --color never | awk '{print "JJ: " $0}')$(echo -e "\n")$(jj show --git --color never | awk '{print "JJ: " $0}')"
1717- '';
1818-1919- mg.body = "spc u SPC gg -r \"$PWD\" RET";
2020- spc.body = "SPC $argv -- -nw";
2121- vspc.body = "SPC $argv -- -c";
2222- fish_hybrid_key_bindings.description = "Vi-style bindings that inherit emacs-style bindings in all modes";
2323- fish_hybrid_key_bindings.body = ''
2424- for mode in default insert visual
2525- fish_default_key_bindings -M $mode
2626- end
2727- fish_vi_key_bindings --no-erase
2828- '';
2929- vix-activate.description = "Activate a new vix system generation";
3030- vix-activate.body = "nix run /hk/vix";
3131- vix-shell.description = "Run nix shell with vix's nixpkgs";
3232- vix-shell.body = "nix shell --inputs-from $HOME/.nix-out/nixpkgs";
3333- vix-nixpkg-search.description = "Nix search on vix's nixpkgs input";
3434- vix-nixpkg-search.body = "nix search --inputs-from $HOME/.nix-out/vix nixpkgs $argv";
3535- rg-vix-inputs.description = "Search on vix flake inputs";
3636- rg-vix-inputs.body =
3737- let
3838- maybeFlakePaths = f: if builtins.hasAttr "inputs" f then flakePaths f else [ ];
3939- flakePaths =
4040- flake: [ flake.outPath ] ++ lib.flatten (lib.mapAttrsToList (_: maybeFlakePaths) flake.inputs);
4141- paths = builtins.concatStringsSep " " (flakePaths inputs.self);
4242- in
4343- "rg $argv ${paths}";
4444- rg-vix.description = "Search on current vix";
4545- rg-vix.body = "rg $argv $HOME/.nix-out/vix";
4646- rg-nixpkgs.description = "Search on current nixpkgs";
4747- rg-nixpkgs.body = "rg $argv $HOME/.nix-out/nixpkgs";
4848- rg-home-manager.description = "Search on current home-manager";
4949- rg-home-manager.body = "rg $argv $HOME/.nix-out/home-manager";
5050- rg-nix-darwin.description = "Search on current nix-darwin";
5151- rg-nix-darwin.body = "rg $argv $HOME/.nix-out/nix-darwin";
5252- nixos-opt.description = "Open a browser on search.nixos.org for options";
5353- nixos-opt.body = ''open "https://search.nixos.org/options?sort=relevance&query=$argv"'';
5454- nixos-pkg.description = "Open a browser on search.nixos.org for packages";
5555- nixos-pkg.body = ''open "https://search.nixos.org/packages?sort=relevance&query=$argv"'';
5656- repology-nixpkgs.description = "Open a browser on search for nixpkgs on repology.org";
5757- repology-nixpkgs.body = ''open "https://repology.org/projects/?inrepo=nix_unstable&search=$argv"'';
5858-}
-60
modules/vic/_fish/tv.fish
···11-bind \t __tv_complete
22-33-function __tv_complete -d 'fish completion widget with tv'
44- # modified from https://github.com/junegunn/fzf/wiki/Examples-(fish)#completion
55- # As of 2.6, fish's "complete" function does not understand
66- # subcommands. Instead, we use the same hack as __fish_complete_subcommand and
77- # extract the subcommand manually.
88- set -l cmd (commandline -co) (commandline -ct)
99-1010- switch $cmd[1]
1111- case env sudo
1212- for i in (seq 2 (count $cmd))
1313- switch $cmd[$i]
1414- case '-*'
1515- case '*=*'
1616- case '*'
1717- set cmd $cmd[$i..-1]
1818- break
1919- end
2020- end
2121- end
2222-2323- set -l cmd_lastw $cmd[-1]
2424- set cmd (string join -- ' ' $cmd)
2525-2626- set -l complist (complete -C$cmd)
2727- set -l result
2828-2929- # do nothing if there is nothing to select from
3030- test -z "$complist"; and return
3131-3232- set -l compwc (echo $complist | wc -w)
3333- if test $compwc -eq 1
3434- # if there is only one option dont open fzf
3535- set result "$complist"
3636- else
3737- set result (string join -- \n $complist | column -t -l 2 -o \t | tv --select-1 --no-status-bar --keybindings='tab="confirm_selection"' --inline --input-header "$cmd" | string split -m 2 -f 1 \t | string trim --right)
3838- end
3939-4040- set -l prefix (string sub -s 1 -l 1 -- (commandline -t))
4141- for i in (seq (count $result))
4242- set -l r $result[$i]
4343- switch $prefix
4444- case "'"
4545- commandline -t -- (string escape -- $r)
4646- case '"'
4747- if string match '*"*' -- $r >/dev/null
4848- commandline -t -- (string escape -- $r)
4949- else
5050- commandline -t -- '"'$r'"'
5151- end
5252- case '~'
5353- commandline -t -- (string sub -s 2 (string escape -n -- $r))
5454- case '*'
5555- commandline -t -- $r
5656- end
5757- commandline -i ' '
5858- end
5959- commandline -f repaint
6060-end