Importing den aspects in non-den configuration #569
Replies: 3 comments 3 replies
|
Take a look at the flake parts demo for inspiration, I think. Technically, you can resolve a set of aspects to any flake output, including nixosModules. Also, this section of the docs might be especially helpful. |
|
You can manually resolve an aspect into a module. |
|
Hello, I've had some success using {
den,
inputs,
...
}:
let
inherit (den.lib.aspects) resolve;
aspectToHomeModule =
name: aspect:
{ config, lib, ... }:
let
inherit resolve;
inherit aspect;
module = resolve "homeManager" aspect;
in
{
imports = [ module ];
};
aspectsToHomeModules =
aspects: _:
let
inherit aspectToHomeModule;
in
{
imports = builtins.attrValues (builtins.mapAttrs aspectToHomeModule aspects);
};
in
{
flake.homeModules = aspectsToHomeModules den.aspects;
}This create an "unconditionnal" module for each aspect, that needs to be imported one by one in the consuming flake My issue is with adding "conditional" imports based on an option named after the aspect. It create infinite recursion due to using config in imports. Is there a way to prevent the infinite recursion ? I've tried playing with meta and functor without success. |
Uh oh!
There was an error while loading. Please reload this page.
Say I have a nix config repo (a) making use of den aspects for defining hosts and users.
If I wanted to import some of these definitions as "traditional" nixosModules in another config repo (b) which doesn't use den:
How would I currently do that?
All reactions