One module that combines home manager and system packages?

I’d like to write a module that combines setting some dconf.settings for my user, and also installs a system-wide package.

Here was my first attempt, a module imported from within config.home-manager.users.${user}; However, osConfig is not available within the set passed to mkIf:

{ osConfig, lib, pkgs, config, user, ... }:
let cfg = config.d.programs.blackbox;
  options.d.programs.blackbox = {
    enable = lib.mkOption {
      type = lib.types.bool;
      default = true;

  config = lib.mkIf cfg.enable {
    osConfig.environment.systemPackages = with pkgs; [

    dconf.settings = {
      "com/raggesilver/BlackBox" = with; {
        fill-tabs = false;
        # ... more settings

I’m open to any ideas, as I’m mostly poking around trying to find a good way forward. Also, it isn’t obvious to me why I can’t access osConfig here.

Overall, what I’m trying to do is create several individual files, each handling “everything to do with X”, where X might be blackbox-terminal, or firefox, or syncthing. So for example, syncthing might have a system package, and a system service with syncthing devices and folders, as well as a user/home-manager gnome extension, with user/home-manager dconf.settings.

The motivation for this architecture is driven by individual quirks within each package:

  • blackbox: is not available as a home-manager program, and must be installed as a systemPackage. But individual properties and configuration are handled by dconf.settings in the home-manager.
  • firefox: has policies and better extension UX at the system level, but updated preferences via home-manager.
  • syncthing: has declarative devices and folders at the system level, but the gnome extension showing its status must be installed via user gnome extension.

Any suggestions or prior art here?


Seems like osConfig gives you a read-only access to the config, not a write one. And since you’re trying to write to it, it’s being blocked.

I would suggest importing this module in your system config instead of your home one and not the other way around.

See this comment which shows the snippet of a module that edits both system config and HM config.

1 Like