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.

feat: host-aspects battery for projecting host homeManager to users (#466)

## Summary
- New battery `den._.host-aspects` that projects all homeManager-class
configs from the host's aspect tree onto users who opt in
- Wraps `host.aspect` with `fixedTo { host, user }` so the pipeline
resolves it with `class = "homeManager"`, collecting only homeManager
keys
- Other class keys (nixos, darwin) are ignored naturally by the pipeline

## Usage

```nix
den.aspects.tux.includes = [ den._.host-aspects ];
```

## Test plan
- [x] Host aspect with homeManager key projects to opted-in user
- [x] Host aspect with only nixos key does not leak into user's
homeManager
- [x] Multiple host sub-aspects with homeManager keys all project
- [x] User who does NOT include the battery does not receive host
homeManager configs
- [x] No circular evaluation when accessing both host and user configs
- [x] Full CI suite passes (498/498)

Co-authored-by: Victor Borja <vborja@apache.org>

authored by

Jason Bowman
Victor Borja
and committed by
GitHub
fed2e347 4ad6f25d

+147
+27
modules/aspects/provides/host-aspects.nix
··· 1 + { den, ... }: 2 + let 3 + inherit (den.lib) parametric; 4 + 5 + description = '' 6 + Projects all homeManager-class configs from the host's aspect tree 7 + onto users who opt in. 8 + 9 + ## Usage 10 + 11 + den.aspects.tux.includes = [ den._.host-aspects ]; 12 + 13 + Any host aspect that defines a `homeManager` key will have that 14 + config forwarded to the user's homeManager evaluation. Other class 15 + keys (nixos, darwin) are ignored — the pipeline resolves with 16 + class = "homeManager" so only homeManager modules are collected. 17 + ''; 18 + 19 + from-host = { host, user }: parametric.fixedTo { inherit host user; } host.aspect; 20 + 21 + in 22 + { 23 + den.provides.host-aspects = parametric.exactly { 24 + inherit description; 25 + includes = [ from-host ]; 26 + }; 27 + }
+120
templates/ci/modules/features/host-aspects.nix
··· 1 + # Battery: host-aspects — projects host homeManager configs to opted-in users. 2 + { denTest, ... }: 3 + { 4 + flake.tests.host-aspects = { 5 + 6 + # Host aspect with homeManager key projects to user who includes den._.host-aspects. 7 + test-host-hm-projects-to-user = denTest ( 8 + { 9 + den, 10 + lib, 11 + tuxHm, 12 + ... 13 + }: 14 + { 15 + den.hosts.x86_64-linux.igloo.users.tux = { }; 16 + 17 + den.aspects.igloo.homeManager.programs.vim.enable = true; 18 + den.aspects.tux.includes = [ den._.host-aspects ]; 19 + 20 + expr = tuxHm.programs.vim.enable; 21 + expected = true; 22 + } 23 + ); 24 + 25 + # Host aspect with only nixos key does NOT leak into user's homeManager. 26 + test-nixos-only-does-not-leak = denTest ( 27 + { 28 + den, 29 + lib, 30 + tuxHm, 31 + ... 32 + }: 33 + { 34 + den.hosts.x86_64-linux.igloo.users.tux = { }; 35 + 36 + den.aspects.igloo.nixos.networking.hostName = "igloo"; 37 + den.aspects.tux.includes = [ den._.host-aspects ]; 38 + 39 + expr = tuxHm.programs.vim.enable; 40 + expected = false; 41 + } 42 + ); 43 + 44 + # Verify no circular eval when accessing both host and user configs. 45 + test-no-circular-eval = denTest ( 46 + { 47 + den, 48 + lib, 49 + igloo, 50 + tuxHm, 51 + ... 52 + }: 53 + { 54 + den.hosts.x86_64-linux.igloo.users.tux = { }; 55 + 56 + den.aspects.igloo.homeManager.programs.vim.enable = true; 57 + den.aspects.igloo.nixos.networking.hostName = "igloo"; 58 + den.aspects.tux.includes = [ den._.host-aspects ]; 59 + 60 + expr = { 61 + hostName = igloo.networking.hostName; 62 + vim = tuxHm.programs.vim.enable; 63 + }; 64 + expected = { 65 + hostName = "igloo"; 66 + vim = true; 67 + }; 68 + } 69 + ); 70 + 71 + # Multiple host sub-aspects with homeManager keys all project. 72 + test-multiple-host-aspects = denTest ( 73 + { 74 + den, 75 + lib, 76 + tuxHm, 77 + ... 78 + }: 79 + { 80 + den.hosts.x86_64-linux.igloo.users.tux = { }; 81 + 82 + den.aspects.igloo.includes = [ 83 + { homeManager.programs.vim.enable = true; } 84 + { homeManager.programs.git.enable = true; } 85 + ]; 86 + 87 + den.aspects.tux.includes = [ den._.host-aspects ]; 88 + 89 + expr = { 90 + vim = tuxHm.programs.vim.enable; 91 + git = tuxHm.programs.git.enable; 92 + }; 93 + expected = { 94 + vim = true; 95 + git = true; 96 + }; 97 + } 98 + ); 99 + 100 + # User who does NOT include den._.host-aspects does not receive host homeManager. 101 + test-opt-in-only = denTest ( 102 + { 103 + den, 104 + lib, 105 + tuxHm, 106 + ... 107 + }: 108 + { 109 + den.hosts.x86_64-linux.igloo.users.tux = { }; 110 + 111 + den.aspects.igloo.homeManager.programs.vim.enable = true; 112 + # tux does NOT include den._.host-aspects 113 + 114 + expr = tuxHm.programs.vim.enable; 115 + expected = false; 116 + } 117 + ); 118 + 119 + }; 120 + }