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

host enabled hjem/maid/homeManager if at least one user has class

+23 -46
+4 -1
modules/aspects/provides/hjem/hjem-os.nix
··· 15 15 { host, ... }: 16 16 { 17 17 options.hjem = { 18 - enable = lib.mkEnableOption "Enable hjem"; 18 + enable = lib.mkOption { 19 + type = lib.types.bool; 20 + default = den.lib.host-has-user-with-class host hjemClass; 21 + }; 19 22 module = lib.mkOption { 20 23 type = lib.types.deferredModule; 21 24 default = inputs.hjem."${host.class}Modules".default;
+1 -23
modules/aspects/provides/home-manager/hm-integration.nix
··· 43 43 44 44 in 45 45 { 46 - den.provides.home-manager = 47 - _: 48 - throw '' 49 - NOTICE: den.provides.home-manager aspect is not needed anymore. 50 - 51 - Enabling Home Manager is now made via the host config: 52 - 53 - Per host: 54 - 55 - den.hosts.x86_64-linux.igloo.home-manager.enable = true; 56 - 57 - On ALL hosts: 58 - 59 - den.base.host.home-manager.enable = true; 60 - 61 - See <den/home-manager/hm-os.nix> 62 - 63 - If you had includes at den._.home-manager, you can use: 64 - 65 - den.ctx.hm-host.includes = [ ... ]; 66 - 67 - For attaching aspects to home-manager enabled hosts. 68 - ''; 46 + den.provides.home-manager = {}; 69 47 70 48 den.ctx.home.description = "Standalone Home-Manager config provided by home aspect"; 71 49 den.ctx.home._.home = { home }: parametric.fixedTo { inherit home; } den.aspects.${home.aspect};
+4 -1
modules/aspects/provides/home-manager/hm-os.nix
··· 31 31 { host, ... }: 32 32 { 33 33 options.home-manager = { 34 - enable = lib.mkEnableOption "Enable Home Manager integration"; 34 + enable = lib.mkOption { 35 + type = lib.types.bool; 36 + default = den.lib.host-has-user-with-class host hm-class; 37 + }; 35 38 module = lib.mkOption { 36 39 type = lib.types.deferredModule; 37 40 default = inputs.home-manager."${host.class}Modules".home-manager;
+4 -1
modules/aspects/provides/maid/maid-os.nix
··· 14 14 { host, ... }: 15 15 { 16 16 options.nix-maid = { 17 - enable = lib.mkEnableOption "Enable nix-maid"; 17 + enable = lib.mkOption { 18 + type = lib.types.bool; 19 + default = den.lib.host-has-user-with-class host maidClass; 20 + }; 18 21 module = lib.mkOption { 19 22 type = lib.types.deferredModule; 20 23 default = inputs.nix-maid.nixosModules.default;
+8
modules/aspects/provides/os-user.nix
··· 47 47 in 48 48 { 49 49 den.ctx.user.includes = [ fwd ]; 50 + 51 + den.lib.host-has-user-with-class = host: class: 52 + lib.pipe host.users [ 53 + (lib.attrValues) 54 + (map (user: lib.elem class user.classes)) 55 + (lib.filter lib.id) 56 + (xs: lib.length xs > 0) 57 + ]; 50 58 }
-1
templates/bogus/modules/test-base.nix
··· 28 28 29 29 denModule = { 30 30 imports = [ inputs.den.flakeModule ]; 31 - den.base.host.home-manager.enable = true; 32 31 den.default.homeManager.home.stateVersion = "26.05"; 33 32 den.default.nixos = { 34 33 system.stateVersion = "26.05";
-3
templates/ci/modules/features/hjem-class.nix
··· 25 25 { 26 26 den.hosts.x86_64-linux.igloo = { 27 27 users.tux.classes = [ "hjem" ]; 28 - hjem.enable = true; 29 28 hjem.module = mockHjemModule; 30 29 }; 31 30 ··· 46 45 { 47 46 den.hosts.x86_64-linux.igloo = { 48 47 users.tux.classes = [ "hjem" ]; 49 - hjem.enable = true; 50 48 hjem.module = mockHjemModule; 51 49 }; 52 50 ··· 66 64 { 67 65 den.hosts.x86_64-linux.igloo = { 68 66 users.tux = { }; 69 - hjem.enable = false; 70 67 hjem.module = mockHjemModule; 71 68 }; 72 69
-3
templates/ci/modules/features/maid-class.nix
··· 29 29 { 30 30 den.hosts.x86_64-linux.igloo = { 31 31 users.tux.classes = [ "maid" ]; 32 - nix-maid.enable = true; 33 32 nix-maid.module = mockMaidModule; 34 33 }; 35 34 ··· 50 49 { 51 50 den.hosts.x86_64-linux.igloo = { 52 51 users.tux.classes = [ "maid" ]; 53 - nix-maid.enable = true; 54 52 nix-maid.module = mockMaidModule; 55 53 }; 56 54 ··· 70 68 { 71 69 den.hosts.x86_64-linux.igloo = { 72 70 users.tux = { }; 73 - nix-maid.enable = false; 74 71 nix-maid.module = mockMaidModule; 75 72 }; 76 73
-2
templates/ci/modules/test-support/eval-den.nix
··· 31 31 options.flake.packages = lib.mkOption { }; 32 32 options.expr = lib.mkOption { }; 33 33 options.expected = lib.mkOption { }; 34 - 35 - config.den.base.host.home-manager.enable = lib.mkDefault true; 36 34 }; 37 35 38 36 helpersModule =
+1 -4
templates/default/modules/hosts.nix
··· 2 2 # then config their aspects in as many files you want 3 3 { 4 4 # tux user at igloo host. 5 - den.hosts.x86_64-linux.igloo = { 6 - users.tux = { }; 7 - home-manager.enable = true; 8 - }; 5 + den.hosts.x86_64-linux.igloo.users.tux = { }; 9 6 10 7 # define an standalone home-manager for tux 11 8 # den.homes.x86_64-linux.tux = { };
-3
templates/example/modules/den.nix
··· 2 2 den.hosts.x86_64-linux.igloo.users.alice = { }; 3 3 den.hosts.aarch64-darwin.apple.users.alice = { }; 4 4 den.homes.x86_64-linux.alice = { }; 5 - 6 - # Enable HM on all hosts 7 - den.base.host.home-manager.enable = true; 8 5 }
+1 -4
templates/noflake/modules/den.nix
··· 10 10 }; 11 11 12 12 # tux user on igloo host, using nix-maid 13 - den.hosts.x86_64-linux.igloo = { 14 - nix-maid.enable = true; 15 - users.tux.classes = [ "maid" ]; 16 - }; 13 + den.hosts.x86_64-linux.igloo.users.tux.classes = [ "maid" ]; 17 14 18 15 # host aspect 19 16 den.aspects.igloo = {