Home Manager: attribute missing from `config.services`

Hi, I’m trying to add an autostart in my home.nix (following input-remapper - ERROR: Request to autoload ... before a user told the service about their session using set_config_dir · Issue #304006 · NixOS/nixpkgs · GitHub)

# home.nix of my hostname
{
  inputs,
  lib,
  config,
  pkgs,
  ...
}:
{
  imports = [
    ../../home-manager/home.nix
  ];

  xdg.configFile."autostart/input-mapper-autoload.desktop" =
    lib.mkIf config.services.input-remapper.enable
      {
        source = "${config.services.input-remapper.package}/share/applications/input-remapper-autoload.desktop";
      };
}

and I do have in default.nix:

services.input-remapper = {
  enable = true;
  enableUdevRules = true;
};

(see geobert/nixos-cfg - Codeberg.org for whole config)

and I get this error:

error: attribute 'input-remapper' missing
┃        at /nix/store/sa9s2prvxdwhva96409gx1rgd07rnvb4-source/nixos/delorean/home.nix:13:14:
┃            12|   xdg.configFile."autostart/input-mapper-autoload.desktop" =
┃            13|     lib.mkIf config.services.input-remapper.enable
┃              |              ^
┃            14|       {

I did change nixosConfig for config as I don’t have nixosConfig.

What am I missing?
Thanks!

If, and only if, you are using HM as a system module, you can use osConfig from the module args to check for host level configuration.

I assume you are presenting HM config in the first snippet as it litereally lists an HM import and also xdg.configFile is not a thing on the system.

The so called default.nix is very likely system config though, as mentioning “udev” in HM doesn’t make sense. HM can not affect udev rules in any way. They are a system level concern and require elevated permissions to be changed.

1 Like

added osConfig to the parameters of home.nix and used it instead of config and it worked :slight_smile: