nix-community / home-manager

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

bug: home-manager installation deleted my `~/.config/home-manager/home.nix` file #3783

Open samuela opened 1 year ago

samuela commented 1 year ago

Are you following the right branch?

Is there an existing issue for this?

Issue description

I just ran the installer off of master two days ago and it overwrote my perfectly customized home.nix config 😟 Unfortunately I did not log exactly which commit this was, but I can confirm that it did destroy my home.nix. In particular, I ran

nix-channel --add "https://github.com/nix-community/home-manager/archive/master.tar.gz" home-manager
nix-channel --update
# See https://github.com/nix-community/home-manager/issues/2564#issuecomment-994943471
export NIX_PATH="${NIX_PATH:+$NIX_PATH:}$HOME/.nix-defexpr/channels:/nix/var/nix/profiles/per-user/root/channels"
nix-shell "<home-manager>" -A install
home-manager switch

Maintainer CC

No response

System information

- system: `"x86_64-linux"`
 - host os: `Linux 5.15.0-1030-gcp, Ubuntu, 20.04.5 LTS (Focal Fossa), nobuild`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.11.1`
 - channels(root): `"nixpkgs"`
 - channels(sam.ainsworth): `"home-manager, nixgl"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixpkgs`
ncfavier commented 1 year ago

The default configuration path was changed in https://github.com/nix-community/home-manager/commit/cae54dc45c0d61c99c1dc8b04bc42f36c76f9771 from ~/.config/nixpkgs/home.nix to ~/.config/home-manager/home.nix. Maybe your old home.nix is still in the old path?

samuela commented 1 year ago

on further investigation i believe this was actually due to the location of home.nix moving from ~/.config/nixpkgs/home.nix to ~/.config/home-manager/home.nix. The UX here is a bit awkward. How're users supposed to know to move their configurations?

EDIT: @ncfavier beat me to it!

ncfavier commented 1 year ago

You don't have to run the installer every time you update. If you hadn't, the next switch would have warned you about the deprecated path.

Maybe we could add a check for ~/.config/nixpkgs/home.nix here just in case?

samuela commented 1 year ago

You don't have to run the installer every time you update.

Yeah, unfortunately I'm in a situation where I need to reinstall nix and home-manager (automatically) on every boot

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.