Flake not running home manager

I have the following flake which is working fine for my machines for nixos stuff but the home manager stuff doesn’t appear to be running.

It just runs as if there were no changes but no home-manager stuff is done.

If I change the home.nix reference to a file that doesn’t exist it doesn’t even complain which leads me to believe that, that bit of code is not even running.

I’m new to flakes - what am I doing wrong here?

I generally run it like this: sudo nixos-rebuild switch --flake ".#carverlinux-prl"

1 Like

That flake seems to contain distinct HM and system configuration. nixos-rebuild just takes care of the system configuration.

For HM you need to use the home-manager CLI.

Ah thanks @NobbZ

Read further and trying to get modules working with a simple POC based on the home manager docs:

{
  description = "Home Manager configuration of Jane Doe";

  inputs = {
    # Specify the source of Home Manager and Nixpkgs.
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
    home-manager = {
      url = "github:nix-community/home-manager";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs = { nixpkgs, home-manager, ... }:
    let
      system = "x86_64-linux";
      pkgs = nixpkgs.legacyPackages.${system};
    in {
      homeConfigurations.vagrant = home-manager.lib.homeManagerConfiguration {
        inherit pkgs;

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

        # Optionally use extraSpecialArgs
        # to pass through arguments to home.nix
      };
    };
}

and here is home.nix

{ config, pkgs, ... }:

{
  # Home Manager needs a bit of information about you and the
  # paths it should manage.
  home.username = "vagrant";
  home.homeDirectory = "/home/vagrant";

  home.packages = [                               1
    pkgs.htop
  ];
  # 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 can update Home Manager without changing this value. See
  # the Home Manager release notes for a list of state version
  # changes in each release.
  home.stateVersion = "22.05";

  # Let Home Manager install and manage itself.
  programs.home-manager.enable = true;
}

However I get the following error:

sudo nixos-rebuild switch --flake .
error: flake 'path:/home/vagrant/home-manager' does not provide attribute 'packages.x86_64-linux.nixosConfigurations."carverlinux".config.system.build.nixos-rebuild',
'legacyPackages.x86_64-linux.nixosConfigurations."carverlinux".config.system.build.nixos-rebuild' or 'nixosConfigurations."carverlinux".config.system.build.nixos-rebuild'
make: *** [Makefile:9: pc] Error 1

Why is this complaining? it’s basically the guide straight out of the home manager docs?

You are still using a flake with a HM standalone configuration and the ixos-rebuild tool.

For a standalone HM you need to use the home-manager CLI.

If you want to make the user config part of your system configuration and make it being built and activated together with your system, you need to follow the module approach.

Oh right so when I run:

sudo home-manager switch --flake .
error: flake 'path:/home/vagrant/home-manager' does not provide attribute 'packages.x86_64-linux.homeConfigurations."root".activationPackage', 'legacyPackages.x86_64-linux.homeConfigurations."root".activationPackage' or 'homeConfigurations."root".activationPackage'

I still get the same cryptic error

and running without root (just gives me a permission denied error)

home-manager switch --flake .
error: creating directory '/home/vagrant/.cache/nix/eval-cache-v4': Permission denied
error: creating directory '/home/vagrant/.cache/nix/eval-cache-v4': Permission denied

It is not the same error.

It is complaining about a home configuration now for root. You do not want to do that anyway. Use your user.

Probably because you ran using sudo much more often then necassary and therefore got files that should be owned by your user actually owned by root in your users home.

Just kick away ~/.cache/nix and let nix rebuild it on subsequent runs, and in future be more careful with sudo.

ah right - ok a bit further - any idea about this one?

home-manager switch --flake .
error: A definition for option `home.packages."[definition 1-entry 1]"' is not of type `package'. Definition values:
       - In `/nix/store/2bq6gjnhlsgpj4ks0sgpn8z3skmf2ksd-source/home.nix': 1
(use '--show-trace' to show detailed location information)

(this is the home.nix file)

{ config, pkgs, ... }:

{
  # Home Manager needs a bit of information about you and the
  # paths it should manage.
  home.username = "vagrant";
  home.homeDirectory = "/home/vagrant";

  home.packages = [                               1
    pkgs.htop
  ];
  # 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 can update Home Manager without changing this value. See
  # the Home Manager release notes for a list of state version
  # changes in each release.
  home.stateVersion = "22.05";

  # Let Home Manager install and manage itself.
  programs.home-manager.enable = true;
}

Far to the right, there is a superflous 1.

2 Likes

:sweat_smile::sweat_smile::sweat_smile::sweat_smile::sweat_smile:

working thank you

1 Like