nix-community / home-manager

Manage a user environment using Nix [maintainer=@rycee]
https://nix-community.github.io/home-manager/
MIT License
6.56k stars 1.73k forks source link

bug: switch complains about a missing attribute `activationPackage` #2678

Open viraptor opened 2 years ago

viraptor commented 2 years ago

Is there an existing issue for this?

Issue description

I was using home-manager on macos mojave just fine. Since updating to the newest release wiped my /nix, I had to reinstall.

On a completely clean install now (enabled home-manager channel and installed it only), I get:

home-manager switch
error: flake 'path:/Users/viraptor/.config/nixpkgs' does not provide attribute 'packages.x86_64-darwin.homeConfigurations."viraptor".activationPackage', 'legacyPackages.x86_64-darwin.homeConfigurations."viraptor".activationPackage' or 'homeConfigurations."viraptor".activationPackage'

I reduced my flake.nix to this minimal version and it still triggers the issue:

{
  description = "A Home Manager flake";

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

  outputs = inputs: {
    homeConfigurations = {
      "viraptor@Stans-MacBook-Pro.local" = inputs.home-manager.lib.homeManagerConfiguration {
        system = "x86_64-darwin";
        homeDirectory = "/Users/viraptor";
        username = "viraptor";
        stateVersion = "21.11";

        configuration = {pkgs, ...}: {
          programs.home-manager.enable = true;
          home.packages = [
            pkgs.btop
          ];
        };
      };
    };
  };
}

Maintainer CC

No response

System information

- system: `"x86_64-darwin"`
 - host os: `Darwin 21.3.0, macOS 10.16`
 - multi-user?: `yes`
 - sandbox: `no`
 - version: `nix-env (Nix) 2.6.0`
 - channels(viraptor): `"home-manager-21.11.tar.gz"`
 - channels(root): `"nixpkgs"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixpkgs`
viraptor commented 2 years ago

After some debugging I understand what went wrong - the update changed my hostname, so it didn't match the configured one anymore. It would be great if the error message for that situation was more explicit about what element is actually missing. (i.e. the whole user@host config tree)

stale[bot] commented 2 years ago

Thank you for your contribution! I marked this issue as stale due to inactivity. Please be considerate of people watching this issue and receiving notifications before commenting 'I have this issue too'. We welcome additional information that will help resolve this issue. Please read the relevant sections below before commenting.

If you are the original author of the issue

* If this is resolved, please consider closing it so that the maintainers know not to focus on this. * If this might still be an issue, but you are not interested in promoting its resolution, please consider closing it while encouraging others to take over and reopen an issue if they care enough. * If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.

If you are not the original author of the issue

* If you are also experiencing this issue, please add details of your situation to help with the debugging process. * If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.

Memorandum on closing issues

Don't be afraid to manually close an issue, even if it holds valuable information. Closed issues stay in the system for people to search, read, cross-reference, or even reopen – nothing is lost! Closing obsolete issues is an important way to help maintainers focus their time and effort.

viraptor commented 2 years ago

A better error would still be nice.

stale[bot] commented 2 years ago

Thank you for your contribution! I marked this issue as stale due to inactivity. Please be considerate of people watching this issue and receiving notifications before commenting 'I have this issue too'. We welcome additional information that will help resolve this issue. Please read the relevant sections below before commenting.

If you are the original author of the issue

* If this is resolved, please consider closing it so that the maintainers know not to focus on this. * If this might still be an issue, but you are not interested in promoting its resolution, please consider closing it while encouraging others to take over and reopen an issue if they care enough. * If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.

If you are not the original author of the issue

* If you are also experiencing this issue, please add details of your situation to help with the debugging process. * If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.

Memorandum on closing issues

Don't be afraid to manually close an issue, even if it holds valuable information. Closed issues stay in the system for people to search, read, cross-reference, or even reopen – nothing is lost! Closing obsolete issues is an important way to help maintainers focus their time and effort.

YellowOnion commented 1 year ago

@viraptor how did you find the "hostname" stuff? I get the same error about activationPackage.

dacioromero commented 1 year ago

I ran into this issue too though a bit different because I omitted .lan from my hostname since that's nix-darwin does it.

nix-darwin and home-manager use hostname -s and hostname respectively which can be cofusing on MacOS if you use home-manager standalone instead of the nix-darwin module. You'll end up having homeConfigurations."user@host.lan" and darwinConfigurations."host".

https://github.com/LnL7/nix-darwin/blob/6349b99bc2b96ded34d068a88c7c5ced406b7f7f/pkgs/nix-tools/darwin-rebuild.sh#L129

https://github.com/nix-community/home-manager/blob/478610aa37c8339eacabfa03f07dacf5574edd47/home-manager/home-manager#L109

This seems related: https://github.com/nix-community/home-manager/pull/3458

EDIT: I just had the original reported issue. My domain changes from .lan to .local depending on the network I'm connected to.

stale[bot] commented 1 year ago

Thank you for your contribution! I marked this issue as stale due to inactivity. Please be considerate of people watching this issue and receiving notifications before commenting 'I have this issue too'. We welcome additional information that will help resolve this issue. Please read the relevant sections below before commenting.

If you are the original author of the issue

* If this is resolved, please consider closing it so that the maintainers know not to focus on this. * If this might still be an issue, but you are not interested in promoting its resolution, please consider closing it while encouraging others to take over and reopen an issue if they care enough. * If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.

If you are not the original author of the issue

* If you are also experiencing this issue, please add details of your situation to help with the debugging process. * If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.

Memorandum on closing issues

Don't be afraid to manually close an issue, even if it holds valuable information. Closed issues stay in the system for people to search, read, cross-reference, or even reopen – nothing is lost! Closing obsolete issues is an important way to help maintainers focus their time and effort.

RyanPrussin commented 1 month ago

I also had the exact same issue today. The device hostname was changed from Ryans-MBP to Ryans-MacBook-Pro.

I don't remember making this change anytime recently and it had been working until recently, so I'm suspicious this was a change that came about from a recent update to macOS (I'm currently on macOS Sonoma 14.4.1 23E224, M2 Max).