Modular, context-aware and aspect-oriented dendritic Nix configurations. Discussions: https://oeiuwq.zulipchat.com/join/nqp26cd4kngon6mo3ncgnuap/ den.oeiuwq.com
configurations den dendritic nix aspect oriented
at cross 181 lines 5.9 kB view raw view rendered
1<p align="right"> 2 <a href="https://github.com/sponsors/vic"><img src="https://img.shields.io/badge/sponsor-vic-white?logo=githubsponsors&logoColor=white&labelColor=%23FF0000" alt="Sponsor Vic"/> 3 </a> 4 <a href="https://github.com/vic/den/releases"><img src="https://img.shields.io/github/v/release/vic/den?style=plastic&logo=github&color=purple"/></a> 5 <a href="https://vic.github.io/dendrix/Dendritic-Ecosystem.html#vics-dendritic-libraries"> <img src="https://img.shields.io/badge/Dendritic-Nix-informational?logo=nixos&logoColor=white" alt="Dendritic Nix"/> </a> 6 <a href="LICENSE"> <img src="https://img.shields.io/github/license/vic/den" alt="License"/> </a> 7 <a href="https://github.com/vic/den/actions"> 8 <img src="https://github.com/vic/den/actions/workflows/test.yml/badge.svg" alt="CI Status"/> </a> 9</p> 10 11# den - an aspect-oriented approach to Dendritic Nix configurations. 12 13> den and [vic](https://bsky.app/profile/oeiuwq.bsky.social)'s [dendritic libs](https://vic.github.io/dendrix/Dendritic-Ecosystem.html#vics-dendritic-libraries) made for you with Love++ and AI--. If you like my work, consider [sponsoring](https://github.com/sponsors/vic) 14 15<table> 16<tr> 17<td> 18<div style="max-width: 320px;"> 19 20<img width="300" height="300" alt="den" src="https://github.com/user-attachments/assets/af9c9bca-ab8b-4682-8678-31a70d510bbb" /> 21 22- Dendritic: each module configures **same** concern over **different** Nix classes. 23 24- Create [DRY](modules/aspects/provides/unfree.nix) & [`class`-generic](modules/aspects/provides/primary-user.nix) modules. 25 26- [Parametric](modules/aspects/provides/define-user.nix) over `host`/`home`/`user`. 27 28- [Share](templates/default/modules/namespace.nix) aspects across systems & repos. 29 30- Context-aware [dependencies](modules/aspects/dependencies.nix): user/host contributions. 31 32- [Routable](templates/default/modules/aspects/eg/routes.nix) configurations. 33 34- Custom factories for any Nix `class`. 35 36- Use `stable`/`unstable` channels per config. 37 38- Freeform `host`/`user`/`home` [schemas](modules/_types.nix) (no `specialArgs`). 39 40- Multi-platform, multi-tenant hosts. 41 42- [Batteries](modules/aspects/provides/): Opt-in, replaceable aspects. 43 44- Opt-in [`<angle/brackets>`](https://vic.github.io/den/angle-brackets.html) aspect resolution. 45 46- Templates [tested](templates/default/modules/tests.nix) along [examples](templates/examples/modules/_example/ci). 47 48- Concepts [documented](https://vic.github.io/den). 49 50Need more **batteries**? See [vic/denful](https://github.com/vic/denful). 51 52**❄️ Try it now!** 53 54Launch our template VM: 55 56```console 57nix run github:vic/den 58``` 59 60Or, initialize a project: 61 62```console 63nix flake init -t github:vic/den 64nix flake update den 65nix run .#vm 66``` 67 68**Real-world examples for inspiration** 69 70- [`vic/vix`](https://github.com/vic/vix/tree/den) 71- [`quasigod.xyz/nixconfig`](https://tangled.org/quasigod.xyz/nixconfig) 72- [GitHub Search](https://github.com/search?q=vic%2Fden+language%3ANix&type=code). 73 74**Available templates** 75 76- [`default`](templates/default) batteries-included layout. 77- [`minimal`](templates/minimal) truly minimalistic start. 78- [`examples`](templates/examples) tests for all features. 79- [`bogus`](templates/bogus) reproduce and report bugs. 80 81</div> 82</td> 83<td> 84 85🏠 Define [Hosts, Users](templates/examples/modules/_example/hosts.nix) & [Homes](templates/examples/modules/_example/homes.nix) concisely. 86 87See schema in [`_types.nix`](modules/_types.nix). 88 89```nix 90# modules/hosts.nix 91{ 92 # same home-manager vic configuration 93 # over laptop, macbook and standalone-hm 94 den.hosts.x86_64-linux.lap.users.vic = {}; 95 den.hosts.aarch64-darwin.mac.users.vic = {}; 96 den.homes.aarch64-darwin.vic = {}; 97} 98``` 99 100```console 101$ nixos-rebuild switch --flake .#lap 102$ darwin-rebuild switch --flake .#mac 103$ home-manager switch --flake .#vic 104``` 105 106🧩 [Aspect-oriented](https://github.com/vic/flake-aspects) incremental features. ([example](templates/default/modules/den.nix)) 107 108Any module can contribute configurations to aspects. 109 110```nix 111# modules/my-laptop.nix 112{ den, inputs, ... }: { 113 114 # Example: enhance the my-laptop aspect. 115 # This can be done from any file, multiple times. 116 den.aspects.my-laptop = { 117 118 # this aspect includes configurations 119 # available from other aspects 120 includes = [ 121 # your own parametric aspects 122 den.aspects.workplace-vpn 123 # den's opt-in batteries includes. 124 den.provides.home-manager 125 ]; 126 127 # any file can contribute to this aspect, so 128 # best practice is to keep concerns separated, 129 # each on their own file, instead of having huge 130 # modules in a single file: 131 132 # any NixOS configuration 133 nixos = { 134 # A nixos class module, see NixOS options. 135 # import third-party NixOS modules 136 imports = [ 137 inputs.disko.nixosModules.disko 138 ]; 139 disko.devices = { /* ... */ }; 140 }; 141 # any nix-darwin configuration 142 darwin = { 143 # import third-party Darwin modules 144 imports = [ 145 inputs.nix-homebrew.darwinModules.nix-homebrew 146 ]; 147 nix-homebrew.enableRosetta = true; 148 }; 149 # For all users of my-laptop 150 homeManager.programs.vim.enable = true; 151 152 }; 153} 154 155# modules/vic.nix 156{ den, ... }: { 157 den.aspects.vic = { 158 homeManager = { /* ... */ }; 159 # User contribs to host 160 nixos.users.users = { 161 vic.description = "oeiuwq"; 162 }; 163 includes = [ 164 den.aspects.tiling-wm 165 den._.primary-user 166 ]; 167 }; 168} 169``` 170 171</td> 172</tr> 173</table> 174 175You are done! You know everything to start creating configurations with `den`. 176 177Feel free to to **explore** the codebase, particularly our [included batteries](modules/aspects/provides) and [tests](templates/examples/modules/_example/ci). 178 179## Learn more at our [documentation website](https://vic.github.io/den) 180 181Join our [community discussion](https://github.com/vic/den/discussions).