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