Missing executable `home-manager`

Can you look on my code and tell why home-manager executable is not available despite setting option programs.home-manager.enable to true at the home-manager shared module?

flake.nix:

{
  description = "whiteman808's config for NixOS";

  inputs = {
    ## NixOS ecosystem
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
    nixpkgs-unstable.url = "nixpkgs/nixos-unstable";

    # home-manager, used for managing user configuration
    home-manager = {
      url = "github:nix-community/home-manager/release-25.05";
      # The `follows` keyword in inputs is used for inheritance.
      # Here, `inputs.nixpkgs` of home-manager is kept consistent with
      # the `inputs.nixpkgs` of the current flake,
      # to avoid problems caused by different versions of nixpkgs.
      inputs.nixpkgs.follows = "nixpkgs";
    };

    # credential management in flake
    sops-nix = {
      url = "github:Mic92/sops-nix";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs = { self, nixpkgs, nixpkgs-unstable, home-manager, sops-nix }:
    let
      inherit (self) outputs;

      lib = nixpkgs.lib // home-manager.lib;
      projectRoot = self.sourceInfo.outPath;

      # explicitly disable non-free shit
      allowUnfree = false;

      supportedSystems = [ "x86_64-linux" "aarch64-linux" ];
      pkgsFor = lib.genAttrs supportedSystems (system:
        let
          overlay-unstable = final: prev: {
            unstable = import nixpkgs-unstable {
              inherit system;
              config.allowUnfree = allowUnfree;
            };
          };

          pkgs = import nixpkgs {
            inherit system;
            config.allowUnfree = allowUnfree;
            overlays = [ overlay-unstable ];
          };
        in pkgs);
      forAllSystems = f:
        builtins.listToAttrs (map (system: {
          name = system;
          value = f pkgsFor.${system};
        }) supportedSystems);

      globalModule = system:
        let sopsKeyFile = "/home/whiteman808/.config/sops/age/keys.txt";
        in {
          system.stateVersion = "25.05";
          sops.age.keyFile = sopsKeyFile;
          home-manager.useGlobalPkgs = true;
          home-manager.useUserPackages = true;
          home-manager.backupFileExtension = "backup";
          home-manager.sharedModules = [
            sops-nix.homeManagerModules.sops
            {
              sops.age.keyFile = sopsKeyFile;
              home.stateVersion = "25.05";
              programs.home-manager.enable = true;
            }
          ];
          home-manager.extraSpecialArgs = {
            inherit self outputs projectRoot;
            pkgs = pkgsFor.${system};
          };
          home-manager.users.root = (import ./home/root {
            inherit self outputs;
            pkgs = pkgsFor.${system};
          });
        };
    in {
      formatter = forAllSystems (pkgs: pkgs.nixfmt);
      packages = forAllSystems (pkgs: import ./pkgs { inherit pkgs; });

      nixosConfigurations = {
        <some-computer-name> = let system = "x86_64-linux";
        in lib.nixosSystem {
          inherit system;
          pkgs = pkgsFor.${system};
          modules = [
            (globalModule system)
            sops-nix.nixosModules.sops
            home-manager.nixosModules.home-manager
            ./hosts/<some-computer-name>
          ];
          specialArgs = { inherit self outputs projectRoot; };
        };
      };
    };
}

If you’re going to use this, don’t use the home-manager CLI. CLI is for standalone only.

1 Like

The docs are confusing, if you read them top-to-bottom you might be under the impression that you need to run home-manager, but nixos-rebuild takes over its job in this configuration.

1 Like