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 main 91 lines 2.1 kB view raw
1{ 2 inputs, 3 lib, 4 withSystem, 5 ... 6}: 7let 8 # isolated test, prevent polution between tests. 9 denTest = module: { 10 inherit ((evalDen module).config) expr expected; 11 }; 12 13 evalDen = 14 module: 15 lib.evalModules { 16 specialArgs = { 17 inherit inputs; 18 inherit withSystem; 19 }; 20 modules = [ 21 module 22 testModule 23 helpersModule 24 ]; 25 }; 26 27 testModule = { 28 imports = [ inputs.den.flakeModule ]; 29 options.flake.nixosConfigurations = lib.mkOption { }; 30 options.flake.darwinConfigurations = lib.mkOption { }; 31 options.flake.homeConfigurations = lib.mkOption { }; 32 options.flake.packages = lib.mkOption { }; 33 options.expr = lib.mkOption { }; 34 options.expected = lib.mkOption { }; 35 config.den.schema.user.classes = lib.mkDefault [ "homeManager" ]; 36 }; 37 38 helpersModule = 39 { config, ... }: 40 let 41 42 iceberg = config.flake.nixosConfigurations.iceberg.config; 43 apple = config.flake.darwinConfigurations.apple.config; 44 igloo = config.flake.nixosConfigurations.igloo.config; 45 tuxHm = igloo.home-manager.users.tux; 46 pinguHm = igloo.home-manager.users.pingu; 47 48 sort = lib.sort (a: b: a < b); 49 show = items: builtins.trace (lib.concatStringsSep " / " (lib.flatten [ items ])); 50 51 funnyNames = 52 aspect: 53 let 54 resolve = config.den.lib.aspects.resolve; 55 mod = resolve "funny" [ ] aspect; 56 namesMod = { 57 options.names = lib.mkOption { 58 type = lib.types.listOf lib.types.str; 59 default = [ ]; 60 }; 61 }; 62 res = lib.evalModules { 63 modules = [ 64 mod 65 namesMod 66 ]; 67 }; 68 in 69 sort res.config.names; 70 71 in 72 { 73 _module.args = { 74 inherit 75 show 76 funnyNames 77 apple 78 igloo 79 iceberg 80 tuxHm 81 pinguHm 82 ; 83 }; 84 }; 85 86in 87{ 88 _module.args = { inherit denTest evalDen; }; 89 90 flake.packages.x86_64-linux.hello = inputs.nixpkgs.legacyPackages.x86_64-linux.hello; 91}