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

clarify schema base modules and batteries

thanks @drupol

+86 -61
+23 -42
docs/src/content/docs/reference/batteries.mdx
··· 18 18 ### `den._.define-user` 19 19 20 20 Creates OS-level user accounts (`users.users.<name>`) with `isNormalUser`, 21 - `home`, and group. Sets `home-manager.users.<name>` when home-manager 22 - integration is active. 21 + and `home` directory. Works on NixOS/Darwin/WSL/HomeManager. 23 22 24 23 ### `den._.os-user` 25 24 26 - Assigns a user into the host by setting group membership and ensuring 27 - the user account exists at the OS level. 25 + A `user` class automatically enabled by Den to forward settings into the host's 26 + `users.users.<userName>`. Forwards work into NixOS/Darwin classes. 28 27 29 28 ### `den._.primary-user` 30 29 31 - Marks a user as the primary user of a host. Sets `nix.settings.trusted-users` 32 - and can configure auto-login or default shell based on other batteries. 30 + Marks a user as the primary user (admin level) of a host. Works in NixOS/Darwin/WSL. 33 31 34 32 ### `den._.user-shell` 35 33 36 - Sets the user's login shell. Reads `user.shell` and configures both 37 - `users.users.<name>.shell` and the home-manager `programs.<shell>.enable`. 34 + Sets the user's login shell. 35 + `users.users.<name>.shell` enabling the shell at host, and the home-manager `programs.<shell>.enable`. 38 36 39 37 ### `den._.tty-autologin` 40 38 ··· 43 41 44 42 ### `den._.wsl` 45 43 46 - WSL-specific configuration. Enables `wsl.enable`, sets the default user, 47 - and adjusts networking for WSL2 environments. 44 + WSL-specific activation. Enables `den.ctx.wsl-host` when the `host.wsl.enable = true` 45 + and includes NixOS-WSL module. 48 46 49 47 ### `den._.forward` 50 48 51 - Forwards aspect configuration from one aspect to another. Used to chain 52 - aspects without duplicating declarations. 49 + Forwards aspect configuration from one aspect to another. 50 + Used for separation of conncerns. See Custom Classes section. 53 51 54 52 ### `den._.import-tree` 55 53 56 - Uses `inputs.import-tree` to recursively import a directory tree as 57 - aspect modules. Enables file-system-driven aspect organization. 54 + Provides `inputs.import-tree` helpers to import trees of non-dendritic 55 + legacy modules, like a directory containing only nixos modules. 58 56 59 57 ## Flake-parts batteries 58 + 59 + These only work when the module system is flake-parts'. 60 60 61 61 ### `den._.inputs'` 62 62 ··· 70 70 71 71 ## Home-manager batteries 72 72 73 - ### `den._.hm-integration` 73 + Defines `den.ctx.hm-host` which activates when at least one user has `homeManager` classes. 74 + The `hm-host` context can be used to set `home-manager.useGlobalPkgs` and `useUserPackages`. 74 75 75 - Integrates home-manager into NixOS/Darwin hosts. Imports the appropriate 76 - home-manager module (`nixos` or `darwin`), enables 77 - `home-manager.useGlobalPkgs` and `useUserPackages`. 76 + Merges home-manager configuration into the host OS module system. Bridges 77 + `home-manager.users.<name>` with the user's `homeManager` class. 78 78 79 - ### `den._.hm-os` 79 + Imports the appropriate home-manager module (`nixos` or `darwin`). 80 80 81 - Merges home-manager configuration into the host OS module system. Bridges 82 - `home-manager.users.<name>` with the user's aspect. 83 81 84 82 ## Hjem batteries 85 83 86 - ### `den._.hjem-integration` 87 - 88 84 Integrates [hjem](https://github.com/feel-co/hjem) as an alternative to 89 - home-manager. Imports hjem's NixOS module. 90 - 91 - ### `den._.hjem-os` 85 + home-manager. Imports hjem's NixOS/Darwin module. 92 86 93 87 Merges hjem user configuration into the host. Sets `hjem.users.<name>` 94 - from the user's aspect. 88 + from the user's `hjem` class. 95 89 96 90 ## Maid batteries 97 91 98 - ### `den._.maid-integration` 99 - 100 92 Integrates [maid](https://github.com/maid-nix/maid) as an alternative 101 93 home management system. 102 94 103 - ### `den._.maid-os` 104 - 105 - Merges maid configuration into the host OS for each user. 106 - 107 - ## Unfree batteries 95 + Merges maid configuration into the host OS `users.users.<name>.maid` for each user `maid` class. 108 96 109 97 ### `den._.unfree` 110 98 111 - Allows unfree packages globally via 112 - `nixpkgs.config.allowUnfree = true`. 113 - 114 - ### `den._.unfree-predicate` 115 - 116 - Allows unfree packages selectively using a predicate builder. Accepts 117 - a list of package names and builds 118 - `nixpkgs.config.allowUnfreePredicate`. 99 + Allows unfree packages by name via `nixpkgs.config.allowUnfreePredicate`.
+63 -19
docs/src/content/docs/reference/schema.mdx
··· 10 10 [`modules/_types.nix`](https://github.com/vic/den/blob/main/modules/_types.nix) 11 11 </Aside> 12 12 13 + ## Schema Base Modules 14 + 15 + Each of `host`, `user`, `home` configuration objects have freeform-types, 16 + meaning you can assign any attribute into them as meta-data. 17 + 18 + However, at times you might want to have shared meta-data between all hosts 19 + or all users. 20 + 21 + The base modules, `den.base.*` serve for this purpose. 22 + They are **not aspects**, they are meta-data (the attributes of host) that aspects 23 + can later read for providing configuration. 24 + 25 + For example, instead of: 26 + 27 + ```nix 28 + den.hosts.x86_64-linux.igloo = { 29 + hardedned = true; # custom free-form metadata 30 + 31 + # repetitive 32 + users.alice.classes = [ "homeManager" ]; 33 + users.bob.classes = [ "homeManager" ]; 34 + }; 35 + ``` 36 + 37 + You can do: 38 + 39 + ```nix 40 + # This is not an aspect, it is a meta-configuration of the host capabilities. 41 + den.base.host = { host, lib, ... }: { 42 + options.hardened = lib.mkEnableOption "Is it secure"; 43 + config.hardened = lib.mkDefault true; 44 + }; 45 + 46 + # The meta-configuration module for all users 47 + den.base.user = { user, lib, ... }: { 48 + config.classes = lib.mkDefault [ "homeManager" ]; 49 + }; 50 + ``` 51 + 52 + All hosts you create will be `hardened = true` by default. And aspects will 53 + be able to read `host.hardened` value. 54 + 55 + ## `den.base` 56 + 57 + Base modules merged into all hosts, users, or homes. 58 + 59 + | Option | Type | Description | 60 + |--------|------|-------------| 61 + | `den.base.conf` | `deferredModule` | Applied to host, user, and home | 62 + | `den.base.host` | `deferredModule` | Applied to all hosts (imports `conf`) | 63 + | `den.base.user` | `deferredModule` | Applied to all users (imports `conf`) | 64 + | `den.base.home` | `deferredModule` | Applied to all homes (imports `conf`) | 65 + 66 + ```nix 67 + den.base.conf = { lib, ... }: { 68 + # shared across all host/user/home declarations 69 + }; 70 + den.base.host = { ... }: { 71 + # host-specific base config 72 + }; 73 + ``` 74 + 75 + 13 76 ## `den.hosts` 14 77 15 78 Type: `attrsOf systemType` ··· 98 161 | `*` | `den.base.home` options | | Options from base module | 99 162 | `*` | | | free-form attributes | 100 163 101 - ## `den.base` 102 - 103 - Base modules merged into all hosts, users, or homes. 104 - 105 - | Option | Type | Description | 106 - |--------|------|-------------| 107 - | `den.base.conf` | `deferredModule` | Applied to host, user, and home | 108 - | `den.base.host` | `deferredModule` | Applied to all hosts (imports `conf`) | 109 - | `den.base.user` | `deferredModule` | Applied to all users (imports `conf`) | 110 - | `den.base.home` | `deferredModule` | Applied to all homes (imports `conf`) | 111 - 112 - ```nix 113 - den.base.conf = { lib, ... }: { 114 - # shared across all host/user/home declarations 115 - }; 116 - den.base.host = { ... }: { 117 - # host-specific base config 118 - }; 119 - ```