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
1{ den, eg, ... }:
2{
3 den.aspects.alice = {
4
5 # Alice can include other aspects.
6 # For small, private one-shot aspects, use let-bindings like here.
7 # for more complex or re-usable ones, define on their own modules,
8 # as part of any aspect-subtree.
9 includes =
10 let
11 # hack for nixf linter to keep findFile :/
12 unused = den.lib.take.unused __findFile;
13 __findFile = unused den.lib.__findFile;
14
15 customEmacs.homeManager =
16 { pkgs, ... }:
17 {
18 programs.emacs.enable = true;
19 programs.emacs.package = pkgs.emacs30-nox;
20 };
21 in
22 [
23 # from local bindings.
24 customEmacs
25 # from the aspect tree, cooper example is defined bellow
26 den.aspects.cooper
27 den.aspects.setHost
28 # from the `eg` namespace.
29 eg.autologin
30 # den included batteries that provide common configs.
31 <den/primary-user> # alice is admin always.
32 (<den/user-shell> "fish") # default user shell
33 ];
34
35 # Alice configures NixOS hosts it lives on.
36 nixos =
37 { pkgs, ... }:
38 {
39 users.users.alice.packages = [ pkgs.vim ];
40 };
41
42 # Alice home-manager.
43 homeManager =
44 { pkgs, ... }:
45 {
46 home.packages = [ pkgs.htop ];
47 };
48
49 # <user>.provides.<host>, via eg/routes.nix
50 provides.igloo =
51 { host, ... }:
52 {
53 nixos.programs.nh.enable = host.name == "igloo";
54 };
55 };
56
57 # This is a context-aware aspect, that emits configurations
58 # **anytime** at least the `user` data is in context.
59 # read more at https://vic.github.io/den/context-aware.html
60 den.aspects.cooper =
61 { user, ... }:
62 {
63 nixos.users.users.${user.userName}.description = "Alice Cooper";
64 };
65
66 den.aspects.setHost =
67 { host, ... }:
68 {
69 networking.hostName = host.hostName;
70 };
71}