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 85 lines 1.5 kB view raw
1{ 2 lib, 3 inputs, 4 config, 5 ... 6}: 7let 8 den.lib = inputs.target.lib { inherit inputs lib config; }; 9 takes = den.lib.canTake; 10 11 flake.tests."test exactly fails" = { 12 expr = takes.exactly { 13 a = 1; 14 b = 2; 15 } ({ a }: a); 16 expected = false; 17 }; 18 19 flake.tests."test exactly succeeds" = { 20 expr = takes.exactly { a = 1; } ({ a }: a); 21 expected = true; 22 }; 23 24 flake.tests."test function with no named arguments can take anything" = { 25 expr = takes { } (x: x); 26 expected = true; 27 }; 28 29 flake.tests."test function called with non attrs" = { 30 expr = takes 22 ({ host }: [ host ]); 31 expected = false; 32 }; 33 34 flake.tests."test function missing required attr" = { 35 expr = takes { } ({ host }: [ host ]); 36 expected = false; 37 }; 38 39 flake.tests."test function satisfied required attr" = { 40 expr = takes { 41 host = 1; 42 } ({ host, ... }: [ host ]); 43 expected = true; 44 }; 45 46 flake.tests."test function missing second required attr" = { 47 expr = 48 takes 49 { 50 host = 1; 51 } 52 ( 53 { host, user }: 54 [ 55 host 56 user 57 ] 58 ); 59 expected = false; 60 }; 61 62 flake.tests."test function optional second attr" = { 63 expr = 64 takes 65 { 66 host = 1; 67 foo = 9; 68 } 69 ( 70 { 71 host, 72 user ? 0, 73 }: 74 [ 75 host 76 user 77 ] 78 ); 79 expected = true; 80 }; 81 82in 83{ 84 inherit flake; 85}