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
8
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix(core): make entity.aspect be real aspect reference not an string (#433)

this allows people to customize the aspect being used to configure their
host/user/home, even if it is in another namespace than den.aspects.

Fixes #416

authored by

Victor Borja and committed by
GitHub
57f46a21 fa6a8c2d

+39 -26
+1 -1
modules/aspects/definition.nix
··· 11 11 allUsers = lib.concatMap (h: builtins.attrValues h.users) allHosts; 12 12 13 13 deps = map (from: { 14 - ${from.aspect} = parametric (lib.genAttrs (from.classes or [ from.class ]) (_: { })); 14 + ${from.name} = parametric (lib.genAttrs (from.classes or [ from.class ]) (_: { })); 15 15 }) (allHosts ++ allHomes ++ allUsers); 16 16 in 17 17 {
+1 -2
modules/aspects/provides/home-manager.nix
··· 22 22 }; 23 23 24 24 homeCtx = { 25 - home.provides.home = 26 - { home }: den.lib.parametric.fixedTo { inherit home; } den.aspects.${home.aspect}; 25 + home.provides.home = { home }: den.lib.parametric.fixedTo { inherit home; } home.aspect; 27 26 home.into.default = lib.singleton; 28 27 }; 29 28
+7 -8
modules/aspects/provides/mutual-provider.nix
··· 34 34 }; 35 35 ''; 36 36 37 - find-mutual = from: to: den.aspects.${from.aspect}._.${to.aspect} or { }; 38 - user-to-hosts = user: den.aspects.${user.aspect}._.to-hosts or { }; 39 - host-to-users = host: den.aspects.${host.aspect}._.to-users or { }; 40 - user-to-users = user: den.aspects.${user.aspect}._.to-users or { }; 37 + find-mutual = from: to: from.aspect._.${to.aspect.name} or { }; 38 + to-hosts = from: from.aspect._.to-hosts or { }; 39 + to-users = from: from.aspect._.to-users or { }; 41 40 42 41 mutual-user-user = host: user: { 43 42 includes = map ( ··· 45 44 parametric.fixedTo { inherit host user; } { 46 45 includes = [ 47 46 (find-mutual from user) 48 - (user-to-users from) 47 + (to-users from) 49 48 ]; 50 49 } 51 50 ) (builtins.filter (u: u != user) (builtins.attrValues host.users)); ··· 58 57 includes = [ 59 58 (find-mutual host user) 60 59 (find-mutual user host) 61 - (host-to-users host) 62 - (user-to-hosts user) 60 + (to-users host) 61 + (to-hosts user) 63 62 (mutual-user-user host user) 64 63 ]; 65 64 }; ··· 67 66 mutual-standalone-home = 68 67 { home }: 69 68 parametric.fixedTo { inherit home; } ( 70 - if home.hostName == null then { } else den.aspects.${home.aspect}._.${home.hostName} or { } 69 + if home.hostName == null then { } else home.aspect._.${home.hostName} or { } 71 70 ); 72 71 73 72 in
+1 -1
modules/aspects/provides/os-user.nix
··· 40 40 "users" 41 41 user.userName 42 42 ]; 43 - fromAspect = _: den.lib.parametric.fixedTo { inherit host user; } den.aspects.${user.aspect}; 43 + fromAspect = _: den.lib.parametric.fixedTo { inherit host user; } user.aspect; 44 44 adaptArgs = args: args // { osConfig = args.config; }; 45 45 }; 46 46
+1 -1
modules/context/host.nix
··· 20 20 21 21 ctx.host.into.user = { host }: map (user: { inherit host user; }) (lib.attrValues host.users); 22 22 ctx.host.into.default = lib.singleton; 23 - ctx.host.provides.host = { host }: fixedTo { inherit host; } den.aspects.${host.aspect}; 23 + ctx.host.provides.host = { host }: fixedTo { inherit host; } host.aspect; 24 24 25 25 in 26 26 {
+1 -1
modules/context/user.nix
··· 28 28 ctx.user.into.default = lib.singleton; 29 29 ctx.user.provides.user = take.exactly from-user; 30 30 31 - from-user = { host, user }: fixedTo { inherit host user; } den.aspects.${user.aspect}; 31 + from-user = { host, user }: fixedTo { inherit host user; } user.aspect; 32 32 33 33 in 34 34 {
+20 -5
nix/lib/types.nix
··· 35 35 class = strOpt "os-configuration nix class for host" ( 36 36 if lib.hasSuffix "darwin" config.system then "darwin" else "nixos" 37 37 ); 38 - aspect = strOpt "main aspect name of <class>" config.name; 38 + aspect = lib.mkOption { 39 + description = "Aspect that configures this host."; 40 + type = lib.types.raw; # no merging 41 + defaultText = "den.aspects.<name>"; 42 + default = den.aspects.${config.name}; 43 + }; 39 44 description = strOpt "host description" "${config.class}.${config.hostName}@${config.system}"; 40 45 users = lib.mkOption { 41 46 description = "user accounts"; ··· 128 133 defaultText = lib.literalExpression ''[ "user" ]''; 129 134 default = [ "user" ]; 130 135 }; 131 - aspect = strOpt "main aspect name" config.name; 136 + aspect = lib.mkOption { 137 + description = "Aspect that configures this user."; 138 + type = lib.types.raw; # no merging 139 + defaultText = "den.aspects.<name>"; 140 + default = den.aspects.${config.name}; 141 + }; 132 142 host = lib.mkOption { 133 143 default = host; 134 144 defaultText = lib.literalExpression "host"; ··· 188 198 config._module.args.host = hostByName; 189 199 config._module.args.user = userByName; 190 200 options = { 191 - name = strOpt "home configuration name" name; 201 + name = strOpt "home configuration name" userName; 192 202 userName = strOpt "user account name" userName; 193 203 hostName = strOpt "host name" hostName; 194 204 user = lib.mkOption { ··· 201 211 }; 202 212 system = strOpt "platform system" system; 203 213 class = strOpt "home management nix class" "homeManager"; 204 - aspect = strOpt "main aspect name" userName; 214 + aspect = lib.mkOption { 215 + description = "Aspect that configures this home."; 216 + type = lib.types.raw; # no merging 217 + defaultText = "den.aspects.<name>"; 218 + default = den.aspects.${config.name}; 219 + }; 205 220 description = strOpt "home description" "home.${config.name}@${config.system}"; 206 221 pkgs = lib.mkOption { 207 222 description = '' ··· 248 263 { 249 264 homeManager = [ 250 265 "homeConfigurations" 251 - config.name 266 + name 252 267 ]; 253 268 } 254 269 .${config.class};
+1 -1
templates/ci/modules/features/cross-context-forward.nix
··· 187 187 lib.optionalAttrs (primaryUser != null) ( 188 188 den._.forward { 189 189 each = lib.singleton host; 190 - fromAspect = h: den.lib.parametric.fixedTo { host = h; } den.aspects.${h.aspect}; 190 + fromAspect = h: den.lib.parametric.fixedTo { host = h; } h.aspect; 191 191 fromClass = _: "homeManager"; 192 192 intoClass = _: host.class; 193 193 intoPath = _: [
+1 -1
templates/ci/modules/features/deadbugs/cybolic-routes.nix
··· 19 19 let 20 20 inherit (den.lib) parametric; 21 21 # eg, `<user>._.<host>` and `<host>._.<user>` 22 - mutual = from: to: den.aspects.${from.aspect}._.${to.aspect} or { }; 22 + mutual = from: to: from.aspect._.${to.aspect.name} or { }; 23 23 24 24 routes = 25 25 { host, user, ... }@ctx:
+4 -4
templates/ci/modules/features/homes.nix
··· 87 87 inherit (den.homes.x86_64-linux."tux@igloo") 88 88 userName 89 89 hostName 90 - aspect 90 + name 91 91 host 92 92 user 93 93 ; ··· 96 96 keyboard = config.flake.homeConfigurations."tux@igloo".config.home.keyboard; 97 97 }; 98 98 expected = { 99 - homeSchema.aspect = "tux"; 99 + homeSchema.name = "tux"; 100 100 homeSchema.userName = "tux"; 101 101 homeSchema.hostName = "igloo"; 102 102 homeSchema.host = null; ··· 132 132 inherit (den.homes.x86_64-linux."tux@igloo") 133 133 userName 134 134 hostName 135 - aspect 135 + name 136 136 ; 137 137 }; 138 138 configuredUserName = config.flake.homeConfigurations."tux@igloo".config.home.username; 139 139 hasOsConfig = config.flake.homeConfigurations."tux@igloo".config.home.keyboard.model; 140 140 }; 141 141 expected = { 142 - homeSchema.aspect = "tux"; # re-uses same aspect as hosted HM. 142 + homeSchema.name = "tux"; # re-uses same aspect as hosted HM. 143 143 homeSchema.userName = "tux"; 144 144 homeSchema.hostName = "igloo"; 145 145 configuredUserName = "tux";
+1 -1
templates/microvm/modules/microvm-integration.nix
··· 100 100 "vms" 101 101 vm.name 102 102 ]; 103 - fromAspect = _: den.aspects.${vm.aspect}; 103 + fromAspect = _: vm.aspect; 104 104 }; 105 105 106 106 in