Home-manager standalone expects home.nix to be in store after using the module version

Hello,
After an attempt to use both standalone and module home-manager installations (which didn’t work quite well), I decided to revert my setup to use the standalone installation by doing the following:

  1. Cleared any configuration related to home-manager in configuration.nix, did nix flake update and sudo nixos-rebuild switch --flake .
  2. Uninstall home-manager standalone installation with nix run home-manager/master -- uninstall and rm -rf ~/.config/home-manager
  3. Reinstall home-manager with nix run home-manager/master -- init --switch
  4. Replace all the files with the configuration I had before installing home-manager as a module
  5. Update the flake inputs nix flake update

After trying to do home-manager switch again, it seems that it reverted to trying to use some path in the store as the default, instead of ~/.config/home-manager/home.nix as it can be seen here:

error:
       … while evaluating a branch condition
         at /nix/store/7hw19rbs6p20l2gxbf13la04pcs2znmz-source/lib/lists.nix:125:9:
          124|       fold' = n:
          125|         if n == len
             |         ^
          126|         then nul

       … while calling the 'length' builtin
         at /nix/store/7hw19rbs6p20l2gxbf13la04pcs2znmz-source/lib/lists.nix:123:13:
          122|     let
          123|       len = length list;
             |             ^
          124|       fold' = n:

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: path '/nix/store/b1i707d2pa2q1ysgkc4lnc3rzg2aa553-source/home.nix' does not exist

Trying to set the flake to the expected one (home-manager switch --flake flake.nix) yields the same result.
This can technically be solved by adding the -f parameter to the switch command, like this: home-manager switch -f home.nix, but from my understanding, this no longer makes use of the flake.
I looked into the --help section of the home-manager command, but I haven’t found anything particularly useful other than these two options:

  -f FILE           The home configuration file.
                    Default is '~/.config/nixpkgs/home.nix'.
  --flake flake-uri Use Home Manager configuration at flake-uri
                    Default is '~/.config/home-manager'.

I wanted to know if its possible that home-manager module installation made any modification to the home-manager command, or if I’ve done something wrong with the flake pointing somehow to the wrong home.nix file

System details:
Nixos version: 25.05.20250113.9abb87b (Warbler)
Home-manager version: 25.05-pre

Relevant files:
/etc/nixos/flake.nix

{
  description = "NixOS configuration.";
  
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
  };

  outputs = { self, nixpkgs, ... }@inputs: {
    nixosConfigurations.nixos = nixpkgs.lib.nixosSystem {
      system = "x86_64-linux";
      modules = [
        ./configuration.nix
      ];
    };
  };
}

~/.config/home-manager/flake.nix

{
  description = "Home Manager configuration of cricro";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
    catppuccin.url = "github:catppuccin/nix";
    home-manager = {
      url = "github:nix-community/home-manager";
      inputs.nixpkgs.follows = "nixpkgs";
    };
    hyprland.url = "github:hyprwm/Hyprland";
  };

  outputs = { nixpkgs, catppuccin, home-manager, ... }@inputs:
    let
      system = "x86_64-linux";
      pkgs = import nixpkgs {
        system = "${system}";
        config = {
          allowUnfree = true;
          allowUnfreePredicate = _: true;
        };
      };
    in {
      homeConfigurations."cricro" = home-manager.lib.homeManagerConfiguration {
        inherit pkgs;

        # Specify your home configuration modules here, for example,
        # the path to your home.nix.
        modules = [
          ./home.nix
          catppuccin.homeManagerModules.catppuccin
        ];

        # Optionally use extraSpecialArgs
        # to pass through arguments to home.nix
        extraSpecialArgs = { inherit pkgs; inherit inputs; };
      };
    };
}

~/.config/home-manager/home.nix (common.nix only contains additional programs that I share between hosts)

{ pkgs, ... }:

{
    # Home Manager needs a bit of information about you and the paths it should
    # manage.
    home.username = "cricro";
    home.homeDirectory = "/home/cricro";
  
    # This value determines the Home Manager release that your configuration is
    # compatible with. This helps avoid breakage when a new Home Manager release
    # introduces backwards incompatible changes.
    #
    # You should not change this value, even if you update Home Manager. If you do
    # want to update the value, then make sure to first check the Home Manager
    # release notes.
    home.stateVersion = "24.11"; # Please read the comment before changing.

    imports = [ ./common.nix ];
    home.packages = with pkgs; [
        libreoffice
        webcord
        obs-studio
        playerctl
        pavucontrol
        godot_4
        reco
    ];

    programs.mpv = {
      enable = true;
      package = pkgs.mpv-unwrapped.wrapper {
        mpv = pkgs.mpv-unwrapped;
        scripts = with pkgs.mpvScripts; [
          mpris
        ];
      };
    };

    home.file = {
    ".config/" = {
      source = ./config;
      recursive = true;
    };
  };
}

This is because you’re using flakes for your hm config.

In flakes world where everything is well thought out, stable and definitely production ready, you must stage every single file in git because ???.

Your home.nix is not staged in git, so from flakes’ PoV, it doesn’t exist.

You don’t need to stage it; you can use git add --intent-to-add <paths> (git add -N <paths>), which will not stage it but add it to the git index.

But yes, when using flakes in a git repo, nix will only see whatever is in the git index.

1 Like

Definitely a silly mistake on my end, since I end up swapping home.nix in the two hosts I have, I’d added it to .gitignore, making it unusable.
Thanks for the help!

1 Like