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

feat: forward classes (#164)

The functionality of `homeManager` itself was generalized into
`den.provides.forward`, this will pave the road for easily having
`hjem`, `nix-maid` and most importantly, allow the user to have custom
defined forward classes.

See discussion at #160

authored by oeiuwq.com and committed by

GitHub 933a84fd 36b571d0

+68 -34
+33
modules/aspects/provides/forward.nix
··· 1 + { lib, ... }: 2 + let 3 + 4 + description = '' 5 + WIP: Creates a class-forwarding aspect. 6 + ''; 7 + 8 + forward = 9 + cb: 10 + { class, aspect-chain }: 11 + let 12 + fwd = cb { inherit class aspect-chain; }; 13 + include = 14 + item: 15 + let 16 + from = fwd.from item; 17 + into = fwd.into item; 18 + aspect = fwd.aspect item; 19 + module = aspect.resolve { class = from; }; 20 + in 21 + lib.setAttrByPath into { imports = [ module ]; }; 22 + in 23 + { 24 + includes = map include fwd.each; 25 + }; 26 + 27 + in 28 + { 29 + den.provides.forward = { 30 + inherit description; 31 + __functor = _self: forward; 32 + }; 33 + }
+29 -25
modules/aspects/provides/home-manager/hm-integration.nix
··· 31 31 inherit (HM-OS-HOST) OS host; 32 32 33 33 hmClass = "homeManager"; 34 - hmUsers = builtins.filter (u: u.class == hmClass) (lib.attrValues host.users); 34 + hmModule = host.hm-module or inputs.home-manager."${host.class}Modules".home-manager; 35 + hmUsers = lib.filter (u: u.class == hmClass) (lib.attrValues host.users); 35 36 36 - hmUserModule = 37 + hmUserAspect = 37 38 user: 38 39 let 39 40 HM = den.aspects.${user.aspect}; 40 - aspect = HM { 41 - HM-OS-USER = { 42 - inherit 43 - OS 44 - HM 45 - host 46 - user 47 - ; 48 - }; 41 + HM-OS-USER = { 42 + inherit 43 + OS 44 + HM 45 + host 46 + user 47 + ; 49 48 }; 50 - module = aspect.resolve { class = hmClass; }; 51 49 in 52 - module; 53 - 54 - users = map (user: { 55 - name = user.userName; 56 - value.imports = [ (hmUserModule user) ]; 57 - }) hmUsers; 50 + HM { inherit HM-OS-USER; }; 58 51 59 - hmModule = host.hm-module or inputs.home-manager."${host.class}Modules".home-manager; 60 - aspect.${host.class} = { 61 - imports = [ hmModule ]; 62 - home-manager.users = lib.listToAttrs users; 63 - }; 64 - 52 + hmUsersAspect = den._.forward ( 53 + { class, aspect-chain }: 54 + den.lib.take.unused aspect-chain { 55 + each = hmUsers; 56 + from = _: hmClass; 57 + into = user: [ 58 + class 59 + "home-manager" 60 + "users" 61 + user.userName 62 + ]; 63 + aspect = hmUserAspect; 64 + } 65 + ); 65 66 in 66 - aspect; 67 + { 68 + ${host.class}.imports = [ hmModule ]; 69 + includes = [ hmUsersAspect ]; 70 + }; 67 71 68 72 in 69 73 {
+5 -8
templates/ci/flake.lock
··· 205 205 "nixpkgs": { 206 206 "locked": { 207 207 "lastModified": 1770843696, 208 - "narHash": "sha256-LovWTGDwXhkfCOmbgLVA10bvsi/P8eDDpRudgk68HA8=", 209 - "owner": "nixos", 210 - "repo": "nixpkgs", 208 + "narHash": "sha256-9SFCZkVcpDOV6unH5hVEy4+dB0rxMuUoBnDAO6vshac=", 211 209 "rev": "2343bbb58f99267223bc2aac4fc9ea301a155a16", 212 - "type": "github" 210 + "type": "tarball", 211 + "url": "https://releases.nixos.org/nixpkgs/nixpkgs-26.05pre944764.2343bbb58f99/nixexprs.tar.xz" 213 212 }, 214 213 "original": { 215 - "owner": "nixos", 216 - "ref": "nixpkgs-unstable", 217 - "repo": "nixpkgs", 218 - "type": "github" 214 + "type": "tarball", 215 + "url": "https://channels.nixos.org/nixpkgs-unstable/nixexprs.tar.xz" 219 216 } 220 217 }, 221 218 "nixpkgs-stable": {
+1 -1
templates/ci/flake.nix
··· 39 39 }; 40 40 url = "github:nix-community/nixos-wsl"; 41 41 }; 42 - nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; 42 + nixpkgs.url = "https://channels.nixos.org/nixpkgs-unstable/nixexprs.tar.xz"; 43 43 nixpkgs-lib.follows = "nixpkgs"; 44 44 nixpkgs-stable.url = "github:nixos/nixpkgs/release-25.05"; 45 45 provider = {