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 cross 82 lines 1.9 kB view raw
1{ den, withSystem, ... }: 2let 3 inherit (den.lib) 4 parametric 5 take 6 ; 7in 8{ 9 den.provides.inputs' = parametric.exactly { 10 description = '' 11 Provides the `flake-parts` `inputs'` (the flake's `inputs` with system pre-selected) 12 as a top-level module argument. 13 14 This allows modules to access per-system flake outputs without needing 15 `pkgs.stdenv.hostPlatform.system`. 16 17 ## Usage 18 19 **Global (Recommended):** 20 Apply to all hosts, users, and homes. 21 22 den.default.includes = [ den._.inputs' ]; 23 24 **Specific:** 25 Apply only to a specific host, user, or home aspect. 26 27 den.aspects.my-laptop.includes = [ den._.inputs' ]; 28 den.aspects.alice.includes = [ den._.inputs' ]; 29 30 **Note:** This aspect is contextual. When included in a `host` aspect, it 31 configures `inputs'` for the host's OS. When included in a `user` or `home` 32 aspect, it configures `inputs'` for the corresponding Home Manager configuration. 33 ''; 34 35 includes = [ 36 ( 37 { OS, host }: 38 let 39 unused = take.unused OS; 40 in 41 withSystem host.system ( 42 { inputs', ... }: 43 unused { 44 ${host.class}._module.args.inputs' = inputs'; 45 } 46 ) 47 ) 48 ( 49 { 50 OS, 51 HM, 52 user, 53 host, 54 }: 55 let 56 unused = take.unused [ 57 OS 58 HM 59 ]; 60 in 61 withSystem host.system ( 62 { inputs', ... }: 63 unused { 64 ${user.class}._module.args.inputs' = inputs'; 65 } 66 ) 67 ) 68 ( 69 { HM, home }: 70 let 71 unused = take.unused HM; 72 in 73 withSystem home.system ( 74 { inputs', ... }: 75 unused { 76 ${home.class}._module.args.inputs' = inputs'; 77 } 78 ) 79 ) 80 ]; 81 }; 82}