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 17a4db0fc851af67ea713dc9caa33b413e2dbcde 98 lines 1.6 kB view raw
1{ 2 den, 3 lib, 4 ... 5}: 6let 7 inherit (den.lib) 8 owned 9 statics 10 parametric 11 ; 12 13 inherit (den.lib.take) exactly; 14 15 dependencies = [ 16 (exactly osDependencies) 17 (exactly hmUserDependencies) 18 (exactly hmStandaloneDependencies) 19 ]; 20 21 osDependencies = 22 { OS, host }: 23 { 24 includes = [ 25 (owned den.default) 26 (statics den.default) 27 (owned OS) 28 (statics OS) 29 { 30 includes = 31 let 32 users = builtins.attrValues host.users; 33 contrib = osUserDependencies { inherit OS host; }; 34 in 35 map contrib users; 36 } 37 ]; 38 }; 39 40 osUserDependencies = 41 { OS, host }: 42 user: 43 let 44 USR = den.aspects.${user.aspect}; 45 in 46 { 47 includes = [ 48 (owned USR) 49 (statics USR) 50 (USR { inherit OS host user; }) 51 ]; 52 }; 53 54 # from OS home-managed integration. 55 hmUserDependencies = 56 { 57 OS-HM, 58 host, 59 user, 60 }: 61 let 62 inherit (OS-HM) OS HM; 63 context = { 64 inherit 65 OS 66 HM 67 user 68 host 69 ; 70 }; 71 in 72 { 73 includes = [ 74 (owned den.default) 75 (statics den.default) 76 (owned HM) 77 (statics HM) 78 (owned OS) 79 (statics OS) 80 (parametric.fixedTo context OS) 81 ]; 82 }; 83 84 hmStandaloneDependencies = 85 { HM, home }: 86 { 87 includes = [ 88 (owned den.default) 89 (statics den.default) 90 (owned HM) 91 (statics HM) 92 ]; 93 }; 94 95in 96{ 97 den.default.includes = dependencies; 98}