Configuring a module alias for home-manager?

Hello, I would like to define a shortcut option name for my home-manager configuration, to make things nicer when splitting my system configuration into multiple nix files.

I have tried this:

{ config, lib, pkgs, ...}: {
  imports = [
    (pkgs.lib.mkAliasOptionModule ["home-manager" "users" "rodney"] ["my"])
    # bug: use lib not pkgs.lib

  home-manager = {
    useGlobalPkgs = true; # use nixpkgs from nixos
    useUserPackages = true; # install to /etc/profiles

  my.programs.home-manager.enable = true;
  my.home.file."test".text = "works\n";

But I get:

error: infinite recursion encountered

or sometimes

error: The option `home-manager.users' in `/home/rodney/ops/home-manager/nixos' is a prefix of options in `/home/rodney/ops/laptop/modules/common/enable-home-manager.nix'.

depending on where I put the alias and imports.

Does anyone know how to do this?

Doh, just after posting, I realised that the infinite recursion was due to using pkgs.lib instead of lib. So after fixing that, now I’m back to the second error about the option home-manager.users being a prefix.

can you show more of the error? It looks like it might be cut off.

Nevermind, after trying this on my end, the errror seems to be extremely unhelpful anyhow :laughing:

second edit
@rvl, you have the arguments backward. Simply switch them around and it should work. Of course, after looking at the original parameters, I don’t blame you, as their naming is fairly unintuitive.

Aha, that’s it - thanks @nrdxp.