`config` in home-manager not picking up custom option

My config is not public and is a little complicated, so I’m sorry that I can’t post an exact repro (and I realize this limits how helpful the community can be).

I have a flake-based setup and use home-manager. I’m hoping to configure some values in home-manager based on whether or not a GUI is available, using a custom option module (which I am importing in all my nixosConfigurations):

# options.nix
{lib, ...}:
with lib; {
  options.local.hasGui = mkOption {
    type = types.bool;
    default = false;

In my per-machine nixos modules, I can set e.g. config.local.hasGui = true;, and I can see that it seems to be working (with a builtins.trace call elsewhere or in another module).

However, in my home-manager config, it shows the same value as being false. My home.nix begins with:

# home.nix
{ pkgs, lib, config, ... }: {

so I thought the config settings throughout the whole system were coalesced and I would be able to access my custom option from my hm settings. Why is that not working?

Isn’t config passed implicitly to imported modules? (I’m importing the home-manager modules in my flake.nix, and it’s otherwise been working fine so I think it’s done correctly.)

EDIT: Summary – I created the custom option as per above. I set its value to true in one of my nixos configurations, but it simultaneously gives me false in my home-manager config. Isn’t config the same everywhere?

1 Like

Think I got it after finding a small note in the docs, in the NixOS Module section:

Home Manager will pass osConfig as a module argument to any modules you create. This contains the system’s NixOS configuration.

Changing the home.nix args from above to:


and I’m now seeing osConfig.local.hasGui is true as expected.