Replies: 1 comment
-
The need for specialArgsUsing Communicating values in DendriticHowever in a Dendritic setup, each file is considered to be a Each Dendritic file can have multiple nix configuration classes: # there is nothing den specific here:
let
sharedValue = ...;
in
{
flake.modules.nixos.foo = {
# use sharedValue in nixos class module.
};
flake.modules.homeManager.foo = {
# use sharedValue in homeManager class module.
};
}as you can see, by simply using let-bindings it is possible to communicate values between different configuration classes without relying on using specialArgs. That's why the Dendritic recommendation is not to use them. The very same is possible in let
specialValue = ...;
in
{
den.aspects.foo = {
nixos = ...; # use specialValue in nixos class module.
homeManager = ...; use specialValue in homeManager class module.
};
}Passing values to other files not just in the same let-binding context. (original question)When passing values between files the most likely working approach is to define your own configuration options at the # modules/my-specials.nix
{ lib, ...}:
{
config.my-specials.specialValue = ...; # a value accessible on all modules.
options.my-specials.specialValue = lib.mkOption {
type = lib.types.anything; # or set a property type.
};
}Then you can use that value from other files: # here not using `den` but generic flake-parts Dendritic syntax:
{ config, ... }:
{
flake.modules.nixos.foo = ...; # access config.my-specials.specialValue
flake.modules.homeManager.foo = ...; # access config.my-specials.specialValue
}The
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Some people might want to have a migration path for configs already using
specialArgsbut using it is considered an anti-pattern in Dendritic setups.Beta Was this translation helpful? Give feedback.
All reactions