tangled
alpha
login
or
join now
oeiuwq.com
/
den
8
fork
atom
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
8
fork
atom
overview
issues
4
pulls
2
pipelines
Update README.md
authored by
oeiuwq.com
and committed by
GitHub
2 weeks ago
e084f0ed
21a1d36a
+77
-35
1 changed file
expand all
collapse all
unified
split
README.md
+77
-35
README.md
···
36
36
37
37
uses `den.lib` to provide batteries + `host`/`user`/`home` schemas for NixOS/nix-darwin/home-manager.
38
38
39
39
+
40
40
+
</div>
41
41
+
</td>
42
42
+
<td>
43
43
+
44
44
+
39
45
### Templates:
40
46
41
47
[default](https://den.oeiuwq.com/tutorials/default/): +flake-file +flake-parts +home-manager
···
65
71
nix flake init -t github:vic/den && nix run .#vm
66
72
```
67
73
68
68
-
</div>
69
74
</td>
70
70
-
<td>
71
75
72
72
-
### Code example (OS configuration domain)
76
76
+
77
77
+
</tr>
78
78
+
</table>
79
79
+
80
80
+
81
81
+
82
82
+
## Code example (OS configuration domain)
73
83
74
84
```nix
75
75
-
# hosts & homes have extensible schema types.
85
85
+
# Define hosts, users & homes
76
86
den.hosts.x86_64-linux.lap.users.vic = {};
77
87
den.hosts.aarch64-darwin.mac.users.vic = {};
78
88
den.homes.aarch64-darwin.vic = {};
79
89
```
80
90
91
91
+
```console
92
92
+
$ nixos-rebuild switch --flake .#lap
93
93
+
$ darwin-rebuild switch --flake .#mac
94
94
+
$ home-manager switch --flake .#vic
95
95
+
```
96
96
+
97
97
+
```nix
98
98
+
# extensible base modules for common, typed schemas
99
99
+
den.base.user = { user, lib, ... }: {
100
100
+
config.classes =
101
101
+
if user.userName == "vic" then [ "hjem" "maid" ]
102
102
+
else lib.mkDefault [ "homeManager" ];
103
103
+
104
104
+
options.mainGroup = lib.mkOption { default = user.userName; };
105
105
+
};
106
106
+
```
107
107
+
81
108
```nix
82
109
# modules/my-laptop.nix
83
110
{ den, inputs, ... }: {
84
111
den.aspects.my-laptop = {
85
85
-
includes = [
86
86
-
den.aspects.work-vpn
87
87
-
];
112
112
+
# re-usable configuration aspects
113
113
+
includes = [ den.aspects.work-vpn ];
114
114
+
88
115
# regular nixos/darwin modules or any other Nix class
89
89
-
nixos = { pkgs, ... }: {
90
90
-
imports = [ inputs.disko.nixosModules.disko ];
91
91
-
};
92
92
-
darwin = { ... };
116
116
+
nixos = { pkgs, ... }: { imports = [ inputs.disko.nixosModules.disko ]; };
117
117
+
darwin = { pkgs, ... }: { environment.packages = [ pkgs.hello ]; };
118
118
+
119
119
+
# host can contribute to its users' environment
93
120
homeManager.programs.vim.enable = true;
94
121
};
95
122
}
···
99
126
# modules/vic.nix
100
127
{ den, ... }: {
101
128
den.aspects.vic = {
102
102
-
homeManager = { pkgs, ... }: ...;
103
103
-
nixos.users.users.vic.description = "oeiuwq";
104
104
-
includes = [
105
105
-
den.aspects.tiling-wm
106
106
-
den.provides.primary-user
107
107
-
den.aspects.vic._.conditional
108
108
-
];
129
129
+
# supports multiple home environments
130
130
+
homeManager = { pkgs, ... }: { };
131
131
+
hjem.files.".envrc".text = "use flake ~/hk/home";
132
132
+
maid.kconfig.settings.kwinrc.Desktops.Number = 3;
109
133
110
110
-
provides = {
111
111
-
conditional = { host, user }:
112
112
-
lib.optionalAttrs (host.hasX && user.hasY) {
113
113
-
nixos.imports = [
114
114
-
inputs.someX.nixosModules.default
115
115
-
];
116
116
-
nixos.someX.foo = user.someY;
117
117
-
};
118
118
-
};
134
134
+
# user can contribute configurations to all hosts it lives on
135
135
+
darwin.services.karabiner-elements.enable = true;
136
136
+
137
137
+
# user class forwards into {nixos/darwin}.users.users.<userName>
138
138
+
user = { pkgs, ... }: {
139
139
+
packages = [ pkgs.helix ];
140
140
+
description = "oeiuwq";
119
141
};
142
142
+
143
143
+
includes = [
144
144
+
den.provides.primary-user # re-usable batteries
145
145
+
(den.provides.user-shell "fish") # parametric aspects
146
146
+
den.aspects.tiling-wm # your own aspects
147
147
+
den.aspects.gaming.provides.emulators
148
148
+
];
120
149
};
121
150
}
122
151
```
123
152
124
124
-
```console
125
125
-
$ nixos-rebuild switch --flake .#lap
126
126
-
$ darwin-rebuild switch --flake .#mac
127
127
-
$ home-manager switch --flake .#vic
128
128
-
```
153
153
+
```nix
154
154
+
# custom user-defined Nix classes.
129
155
130
130
-
</td>
131
131
-
</tr>
132
132
-
</table>
156
156
+
# any aspect can use my `persys` class to forward configs into
157
157
+
# nixos.environment.persistance."/nix/persist/system"
158
158
+
# **ONLY** when environment.persistance option is present at host.
159
159
+
persys = { host }: den._.forward {
160
160
+
each = lib.singleton true;
161
161
+
fromClass = _: "persys";
162
162
+
intoClass = _: host.class;
163
163
+
intoPath = _: [ "environment" "persistance" "/nix/persist/system" ];
164
164
+
fromAspect = _: den.aspects.${host.aspect};
165
165
+
guard = { options, ... }: options ? environment.persistance;
166
166
+
};
167
167
+
168
168
+
# enable on all hosts
169
169
+
den.ctx.host.includes = [ persys ];
170
170
+
171
171
+
# becomes nixos.environment.persistance."/nix/persist/system".hideMounts = true;
172
172
+
# no mkIf, set configs and guard ensures to include only when Impermanence exists
173
173
+
den.aspects.my-laptop.persys.hideMounts = true;
174
174
+
```