nix-community / home-manager

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

bug: flakes initialization doc instructions do not work #4656

Open nathan-at-least opened 11 months ago

nathan-at-least commented 11 months ago

Are you following the right branch?

Is there an existing issue for this?

Issue description

Problem

Following the docs to install home-manager on nixos stable as a stand-alone flake doesn't work.

Background

I'm fairly new to nixos having used nix atop debian a bit.

I've not used home-manager before.

I've just installed nixos, and the first thing I want to do with a new user account is convert it to a standalone setup home manager using flakes. I am not too familiar or experienced with flakes, but they seem like the new/better way to do things, and the advantages make sense to me.

README.md

First, I read over the README.md and it says:

Home Manager provides both the channel-based setup and the flake-based one. See Nix Flakes for a description of the flake-based setup.

Tangent: That link goes to the table of contents for the manual (not a flakes specific chapter), so it may be broken: image. However, when I click the chapter 3 in the table of contents, it scrolls to the correct location with the same URL. Not sure why this happens (on Chrome). Also, I noticed whenever I open those navigation urls in a new window, or follow a link from an external site, they do not scroll to the appropriate location, but after the page renders, then the table-of-content works.

Anyway, there's a chapter called 3. Nix Flakes, so I browse there.

3.1 Prerequisites

I followed 3.1 Prerequisites:

{ config, pkgs, ... }:

{
  home.stateVersion = "23.05";
  programs.home-manager.enable = true;
}

3.2 Stand-alone Setup

Next I followed 3.2 Stand-alone Setup:

$ nix run home-manager/release-23.05 -- init --switch
The file /home/<my user>/.config/home-manager/home.nix already exists, leaving it unchanged...
Creating /home/<my user>/.config/home-manager/flake.nix...

Creating initial Home Manager generation...

warning: Git tree `/home/<my user>/.config/home-manager` is dirty
error: getting status of '/nix/store/6l7jwnx9gq0djk22pjr9b12qv0jqm5ad-source/flake.nix`: No such file or directory
warning: Git tree `/home/<my user>/.config/home-manager` is dirty
error: getting status of '/nix/store/6l7jwnx9gq0djk22pjr9b12qv0jqm5ad-source/flake.nix`: No such file or directory
warning: Git tree `/home/<my user>/.config/home-manager` is dirty
error: getting status of '/nix/store/6l7jwnx9gq0djk22pjr9b12qv0jqm5ad-source/flake.nix`: No such file or directory
Uh oh, the installation failed! Please create an issue at

    https://github.com/nix-community/home-manager/issues

if the error seems to be the fault of Home Manager.

Unsure How To Proceed

The init --switch command fails, so I don't know how to proceed.

To recap my approach:

It seems like this would be a common path, so if I missed something in the docs, let me know. (In that case, I might submit doc improvements.) Otherwise, if it's a bug, that would be good to sort out also.

Maintainer CC

No response

System information

- system: `"x86_64-linux"`
- host os: `Linux 6.1.61, NixOS, 23.05 (Stoat), 23.05.4738.41de143fda10
- multi-user?: `yes`
- sandbox: `yes`
- version: `nix-env (Nix) 2.13.6`
- nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
berbiche commented 11 months ago

Hi Nathan,

Thanks for the thorough bug report.

To resolve your issue, you will need to run git add to track all the required files in your flake repository (/home/<your user>/.config/home-manager/).

As far as I know, Flakes only work with git repositories, so you must track all files that your flake.nix (and its evaluation) will require.

Additional information about their usage is documented here:

stale[bot] commented 8 months 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.