Home-manager: NixOS flake setup assistance

I previously had home-manager working on my machine, but after refactoring some things to separate files, it seems to be mysteriously broken, and I can’t seem to fix it.

The error message is error: The option 'specialisation.fun.configuration.home-manager' does not exist.

Disabling the specialisation fun does not fix it, as it applies to all of them.

I don’t have my dotfiles hosted online, so I’ll just show the relevant ones here:

flake.nix
{
  description = "Athyfr's NixOS system flake";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    nixpkgs-quick-update.url = "github:NixOS/nixpkgs/nixos-unstable";
    nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-25.11";

    home-manager = {
      url = "github:nix-community/home-manager";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    plasma-manager = {
      url = "github:nix-community/plasma-manager";
      inputs = {
        nixpkgs.follows = "nixpkgs";
        home-manager.follows = "home-manager";
      };
    };
  };

  outputs =
    inputs@{ self, home-manager, ... }:
    {
      nixosConfigurations =
        let
          hostName = "athyfr-nixos-laptop";
          hostPlatform = "x86_64-linux";

         pkgs-quick-update = import inputs.nixpkgs-quick-update { system = "x86_64-linux"; };
         pkgs-stable = import inputs.nixpkgs-stable { system = "x86_64-linux"; };
        in
        {
          athyfr-nixos-laptop = inputs.nixpkgs.lib.nixosSystem {
            system = hostPlatform;

            specialArgs = {
              inherit hostPlatform inputs;

              inherit home-manager;

              inherit pkgs-quick-update pkgs-stable;
            };

            modules = [
              { networking = { inherit hostName; }; }

              # To ensure boot is functional
              ./configuration.nix
              ./hardware-configuration.nix
              ./modules/nushell-config.nix

              {
                specialisation = {
                  sysman.configuration = specialisations/sysman.nix;
                  sysman.inheritParentConfig = false;

                  fun.configuration = specialisations/fun.nix;
                  fun.inheritParentConfig = false;

                  school.configuration = specialisations/school.nix;
                  school.inheritParentConfig = false;
                };
              }
            ];
          };
        };
    };
}
specialisations/sysman.nix
{ inputs, ... }:

{
  system.nixos.tags = [ "sysman" ];

  imports = [
    ./base.nix
    "${inputs.self}/modules/browser.nix"
    "${inputs.self}/modules/desktop.nix"
    "${inputs.self}/modules/features.nix"
    "${inputs.self}/modules/security.nix"
    "${inputs.self}/modules/users/main-accounts.nix" # Home-manager
    "${inputs.self}/modules/virtualization.nix"
    "${inputs.self}/modules/privileges.nix"
    "${inputs.self}/modules/tty.nix"
    "${inputs.self}/modules/fancy-hardware.nix"
  ];

  quick = {
    tty.enable = false;
  };
}
modules/users/main-accounts.nix
{
  pkgs,
  inputs,
  home-manager,
  ...
}:

{
  modules = [
    home-manager.nixosModules.home-manager
  ];

  users.users.sysman = {
    home = “/home/sysman”;
    isNormalUser = true;
    shell = pkgs.nushell;
    hashedPassword = "<hash>";

    extraGroups = [
      "nixer"
      "wheel"
      "adbusers"
      "audio"
      "sound"
      "video"
      "networkmanager"
      "input"
      "tty"
    ];
  };

  home-manager.users.sysman = import “${inputs.self}/home-manager/sysman.nix”;
}

specialisations/base.nix
{ pkgs, inputs, ... }:

{
  modules = [
    inputs.home-manager.nixosModules.home-manager
  ];

  imports = [
    "${inputs.self}/hardware-configuration.nix"
    "${inputs.self}/configuration.nix"
    "${inputs.self}/modules/nushell-config.nix"
  ];

  home-manager = {
    useGlobalPkgs = true;
    useUserPackages = false;
    sharedModules = [
      inputs.plasma-manager.homeModules.plasma-manager
    ];
    backupFileExtension = "backup";
    overwriteBackup = true;
  };
}

Any idea where the issue might lie?

Thanks!

EDIT: Problem wasn’t solved.


Nevermind, I forgot to import an important module (that I defined.)

Thanks anyway!

Glad you got it solved, but I’ll add in a comment: Looks like you’re importing the home-manager.nixosModules.home-manager module twice. I believe this turns out harmless here, but it’s generally a good idea to avoid it, regardless.

1 Like

Nevermind, spoke too soon.

That didn’t fix it.

Updating main question..

specialisations/base.nix makes no sense to me at all. It’s like a mix of nixos options and arguments to nixosSystem, which do not make sense to mix. (But you’re using it as a nixos module)

Yeah, I kind of just threw it together without thinking about it, as before everything in specialisations was embedded in flake.nix

I’ll cut down base.nix.

Solved it. I just haven’t been around here (Nix/NixOS) to understand the difference between imports and modules, but now I get that they’re only different in where they’re used; they function pretty much the same.

This reminds me of system being used in inputs.nixpkgs.lib.nixosSystem, but hostPlatform being used elsewhere.. Is there a reason for the inconsistency of this naming convention?

(I replaced modules with imports, as it was in a custom module, so imports was what was needed.)