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: allow host-aspects to work with other user classes (#470)

Iterates over `user.classes` instead of just being fixed to
`homeManager` only. Add tests for hjem class.

authored by

Victor Borja and committed by
GitHub
483f5ec6 6efae0bf

+40 -21
+1 -12
.github/workflows/test.yml
··· 23 23 - run: | 24 24 git fetch --depth 1 origin refs/heads/main 25 25 test "refs/heads/main" == "${{github.ref}}" || (git diff --name-only origin/main..${{ github.sha }} -- | grep '.nix') 26 - ci-fast: 27 - if: ${{github.ref != 'refs/heads/main' && ! contains( github.event.pull_request.labels.*.name, 'allow-ci')}} 26 + ci-deep: 28 27 needs: [non-draft] 29 - name: ci-fast 30 - runs-on: ubuntu-latest 31 - steps: 32 - - uses: wimpysworld/nothing-but-nix@v10 33 - - uses: cachix/install-nix-action@v31 34 - - uses: DeterminateSystems/magic-nix-cache-action@v13 35 - - uses: actions/checkout@v6 36 - - run: nix-shell --run 'just ci' 37 - ci-deep: 38 - needs: [allow-ci] 39 28 strategy: 40 29 matrix: 41 30 os: [ubuntu-latest, macos-latest]
+10 -9
modules/aspects/provides/host-aspects.nix
··· 1 - { den, ... }: 1 + { den, lib, ... }: 2 2 let 3 3 inherit (den.lib) parametric; 4 4 5 5 description = '' 6 - Projects all homeManager-class configs from the host's aspect tree 6 + Projects all `user.classes` like `homeManager` from the host's aspect tree 7 7 onto users who opt in. Requires the fx pipeline. 8 8 9 9 ## Usage ··· 11 11 den.aspects.tux.includes = [ den._.host-aspects ]; 12 12 13 13 Any host aspect that defines a `homeManager` key will have that 14 - config forwarded to the user's homeManager evaluation. Other class 14 + config forwarded to the user's homeManager evaluation. Other host-class 15 15 keys (nixos, darwin) are ignored — host.aspect is resolved 16 - specifically for class "homeManager". 16 + specifically for `user.classes`. 17 17 ''; 18 18 19 19 from-host = 20 20 { host, user }: 21 - { 22 - homeManager = den.lib.aspects.resolve "homeManager" ( 23 - parametric.fixedTo { inherit host user; } host.aspect 24 - ); 25 - }; 21 + lib.listToAttrs ( 22 + map (class: { 23 + name = class; 24 + value = den.lib.aspects.resolve class (parametric.fixedTo { inherit host user; } host.aspect); 25 + }) user.classes 26 + ); 26 27 27 28 in 28 29 {
+29
templates/ci/modules/features/host-aspects.nix
··· 317 317 } 318 318 ); 319 319 320 + # Host aspect with hjem key projects to user who includes den._.host-aspects. 321 + test-host-hjem-projects-to-user = denTest ( 322 + { 323 + den, 324 + lib, 325 + igloo, 326 + ... 327 + }: 328 + { 329 + den.hosts.x86_64-linux.igloo = { 330 + users.tux.classes = [ "hjem" ]; 331 + hjem.module.options.hjem.users = lib.mkOption { 332 + type = lib.types.lazyAttrsOf ( 333 + lib.types.submodule { 334 + options.foo = lib.mkOption { }; 335 + } 336 + ); 337 + }; 338 + 339 + }; 340 + 341 + den.aspects.igloo.hjem.foo = true; 342 + den.aspects.tux.includes = [ den._.host-aspects ]; 343 + 344 + expr = igloo.hjem.users.tux.foo; 345 + expected = true; 346 + } 347 + ); 348 + 320 349 }; 321 350 }