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