nix-community / home-manager

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

bug: Unable to build flake without `home.homeDirectory` error #6036

Open jclark-dot-org opened 1 day ago

jclark-dot-org commented 1 day ago

Are you following the right branch?

Is there an existing issue for this?

Issue description

Short Version: I'm trying to setup nix/nix-darwin/home-manager/flakes for the first time. Every time I try to build my config for the first time, I get the error:

      error: A definition for option `home-manager.users.jclark.home.homeDirectory' is not of type `path'. Definition values:
       - In `/nix/store/1gkcml61pcjwxsmlkchr2wpivl0n4mhh-source/nixos/common.nix': null

Based on the specific error referencing home-manager.users... I assume this is a home-manager issue, but please let me know if this should be a nix-darwin issue instead.

Details

  1. In a fresh Mac OS Sonoma 10.7 install, I installed Nix: sh <(curl -L https://nixos.org/nix/install)
  2. I have created a minimal flake (shown below) in ~/dev/system-config.
  3. Per the nix-darwin README, I tried to "install nix-darwin" via flake: nix --extra-experimental-features "nix-command flakes" run nix-darwin -- switch --flake ~/dev/system-config.

This results in the following error:

building the system configuration...
warning: Git tree '/Users/jclark/dev/system-config' is dirty
error:
       … while evaluating the attribute 'value'
         at /nix/store/0z5aw6jjbjq9sqcd03gfa7zkk25nzwgc-source/lib/modules.nix:816:9:
          815|     in warnDeprecation opt //
          816|       { value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          817|         inherit (res.defsFinal') highestPrio;

       … while evaluating the option `system.build':

       … while evaluating the attribute 'mergedValue'
         at /nix/store/0z5aw6jjbjq9sqcd03gfa7zkk25nzwgc-source/lib/modules.nix:851:5:
          850|     # Type-check the remaining definitions, and merge them. Or throw if no definitions.
          851|     mergedValue =
             |     ^
          852|       if isDefined then

       … while evaluating definitions from `/nix/store/95qf9prv27r48w7by4zlp38y1zkf8q3k-source/modules/system':

       … while evaluating the option `home-manager.users.jclark.home.homeDirectory':

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: A definition for option `home-manager.users.jclark.home.homeDirectory' is not of type `path'. Definition values:
       - In `/nix/store/1gkcml61pcjwxsmlkchr2wpivl0n4mhh-source/nixos/common.nix': null

My current ~/dev/system-config/flake.nix appears below. A few notes:

Maintainer CC

No response

System information

- system: `"aarch64-darwin"`
 - host os: `Darwin 23.6.0, macOS 14.7`
 - multi-user?: `yes`
 - sandbox: `no`
 - version: `nix-env (Nix) 2.24.10`
 - channels(root): `"nixpkgs"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixpkgs`
frankiewiczkamil commented 11 hours ago

Hello Jason, I've encountered a similar problem and in my case adding users.users.xxx.home = "/Users/xxx"; helped. In your case it would look like:

home-manager = {
    users.users.jclark.home = "/Users/jclark";
    useGlobalPkgs = true;
    useUserPackages = true;

related issue