Cant run home-manager init

When I try and run home-manager init I get the following

$ home-manager init
Could not find suitable profile directory, tried /home/<ME>/.local/state/home-manager/profiles and /nix/var/nix/profiles/per-user/<ME>
  • This is happening on a fresh install, I’ve logged in and rebooted several times, I’m going through the process of restoring my files and packages from my previous nixos build and I’m trying to integrate packages slowly and more carefully this time and (re)building step by step.
  • My previous nixos system became unstable and I was unable to rebuild at all, it was my first nixos install and I learned a lot but I was integrating everything into /etc/nixos/configuration.nix and I want to do things differently this time and make use of home manager and flakes and other nixos features.

My main configuration.nix includes the following if it helps.

{ config, pkgs, ... }: 
let
  # - enable unstable packages
  unstable = import
    (builtins.fetchTarball https://github.com/nixos/nixpkgs/tarball/nixos-unstable)
    # reuse current configuration
    { config = config.nixpkgs.config; };
in {
  ...
  # -- enable flakes and it's companion feature nix command
  # --- needed for enabling home manager
  nix.settings.experimental-features = [ "nix-command" "flakes" ];
  ...
  environment.systemPackages = with pkgs; [
    # - nixos specific packages
    unstable.home-manager
  ...
  ]
  ...
}

Just a thought: I’m wondering if it may have something to do with my nix version which is 23.05? I’m struggling to understand how that works but it may or may not be related to the issue with home manager.

Any help or insights are greatly appreciated. :slight_smile:

home-manager from unstable mixed with home-manager from stable seems like a bad idea. No idea if that’s the issue in this case, but since home-manager relies on the libraries of the nixpkgs version it’s designed against usually you can’t mix-and-match like this.

This may be caused by mixing and matching incompatible versions of nix and home-manager. Which of each are you using (you’re not pinning the home-manager version, so it’s impossible to know from your config)? Have you used the nix profile command and converted to a 2.0 profile?

Good point, I only tried the unstable version after having the exact same issue with the stable version. I’ll edit my original post to show the stable version to avoid further confusion.

As for my versions of nix and home-manager
For nix

$ nix --version
nix (Nix) 2.13.5

When I try and do anything at all with home-manager I get the same error

$ home-manager --help
Could not find suitable profile directory, tried /home/<ME>/.local/state/home-manager/profiles and /nix/var/nix/profiles/per-user/<ME>

$ home-manager --version
Could not find suitable profile directory, tried /home/<ME>/.local/state/home-manager/profiles and /nix/var/nix/profiles/per-user/<ME>

$ home-manager
Could not find suitable profile directory, tried /home/<ME>/.local/state/home-manager/profiles and /nix/var/nix/profiles/per-user/<ME>

The home-manager version listed in stable ls shown as 2023-05-30

Apparently I can’t edit my original post anymore so here’s a better representation of my config

I just changed unstable.home-manager to home-manager

{ config, pkgs, ... }: 
let
  # - enable unstable packages
  unstable = import
    (builtins.fetchTarball https://github.com/nixos/nixpkgs/tarball/nixos-unstable)
    # reuse current configuration
    { config = config.nixpkgs.config; };
in {
  ...
  # -- enable flakes and it's companion feature nix command
  # --- needed for enabling home manager
  nix.settings.experimental-features = [ "nix-command" "flakes" ];
  ...
  environment.systemPackages = with pkgs; [
    # - nixos specific packages
    home-manager
  ...
  ]
  ...
}

Well home-manager appears to be working now although I’m not sure why. In the course of troubleshooting I ran nix profile upgrade and rebuilt several times but when I run nix profile list I still get nothing.

Hum, odd. Just running some nix profile commands may well have fixed it, but if so listing the profiles should at least show you your home-manager profile.

Not a problem if home-manager just works, I guess.

Unrelated, but you probably want to at least specify a hash for this, or be consistent and switch to a channel. As-is, nix will download a different unstable commit for you every time you evaluate this after a few hours have passed.