How can I reference current 'config' inside specialisation with inheritParentConfig = false?

Let’s consider following code:

{ config, ... }:
{
  config = {
    specialisation = {
      minimal = {
        inheritParentConfig = false;
        configuration = {
          _module.args.foo = config.foo;
        };
      };
    };
  };
}

Seems that config.foo here is referencing the config variable from first line, but that reference to the parent config, how can I just reference to current config?

Try:

{ config, ... }:
{
  config = {
    specialisation = {
      minimal = {
        inheritParentConfig = false;
        configuration = { config, ... }: { # made this into a function with a 'config' param
          _module.args.foo = config.foo;
        };
      };
    };
  };
}

specialisation.<name>.configuration is just a NixOS module, which can be either an attribute set, or a function which receives the “special arguments” like config, pkgs, etc. and returns an attribute set. Just like your top-level configuration.

1 Like

That solved my question. how can I mark this reply as a solution ?

It should be moved to the “Help” category, then you can do it.