home-manager icon indicating copy to clipboard operation
home-manager copied to clipboard

bug: flakes initialization doc instructions do not work

Open nathan-at-least opened this issue 1 year ago • 2 comments

Are you following the right branch?

  • [X] My Nixpkgs and Home Manager versions are in sync

Is there an existing issue for this?

  • [X] I have searched the existing issues

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:

  • My nix version is 2.13.6 which seems greater than 2.4.
  • I enable experimental features in nixos by adding the nix = { … } snippet to /etc/nixos/configuration.nix and running nixos-rebuild --switch as root.
  • Prepared my ~/.config/home-manager/home.nix as follows:
{ 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:

  • Fresh new nixos stable 23.05 installation.
  • Installing home manager via a flake as a stand-alone installation.

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`

nathan-at-least avatar Nov 12 '23 21:11 nathan-at-least

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:

  • https://zero-to-nix.com/concepts/flakes
  • https://nixos.wiki/wiki/Flakes

berbiche avatar Nov 12 '23 23:11 berbiche

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.

stale[bot] avatar Feb 14 '24 00:02 stale[bot]