Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
2 tasks done
jclark-dot-org opened this issue Nov 3, 2024 · 4 comments
Open
2 tasks done

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

jclark-dot-org opened this issue Nov 3, 2024 · 4 comments
Assignees
Labels
bug triage Issues or feature request that have not been triaged yet

Comments

@jclark-dot-org
Copy link

Are you following the right branch?

  • My Nixpkgs and Home Manager versions are in sync

Is there an existing issue for this?

  • I have searched the existing issues

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:

  • The machine name charybdis and user name jclark are correct for the machine.
  • I have removed a lot of my initial content to reduce the chance I had made a mistake with optional packages/settings
  • I chose the stateVersions listed based on a tutorial video I used to learn nix
  • None of the examples or tutorials I have looked at actually use home.homeDirectory, so I didn't have it my flake. Once I got the error, I tried setting it two different ways; see the two commented lines near the end of the file. Uncommenting either line makes no difference to the error message I receive.
{
  description = "First Flake";
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";

    home-manager.url = "github:nix-community/home-manager/master";
    home-manager.inputs.nixpkgs.follows = "nixpkgs";

    darwin.url = "github:lnl7/nix-darwin";
    darwin.inputs.nixpkgs.follows = "nixpkgs";
  };
  outputs = inputs: {
    darwinConfigurations.charybdis = inputs.darwin.lib.darwinSystem {
      system = "aarch64-darwin";
      pkgs = import inputs.nixpkgs {system = "aarch64-darwin";};
      modules = [
        ({pkgs, ...}: {
          system = {
            stateVersion = 4;
            activationScripts.postUserActivation.text = ''
              # Following line should allow us to avoid a logout/login cycle
              /System/Library/PrivateFrameworks/SystemAdministration.framework/Resources/activateSettings -u
            '';

            defaults.finder = {
              AppleShowAllExtensions = true;
              ShowPathbar = true;
              ShowStatusBar = true;
              _FXShowPosixPathInTitle = true;
              _FXSortFoldersFirst = true;
              FXEnableExtensionChangeWarning = false;
              FXPreferredViewStyle = "Nlsv";
            };
          };
          environment = {
            shells = [pkgs.bash pkgs.zsh];
            loginShell = [pkgs.zsh];
            systemPackages = [
              pkgs.coreutils
              pkgs._1password-gui
            ];
          };
          programs.zsh.enable = true;
          programs.zsh.enableCompletion = true;
          nix.extraOptions = ''
            experimental-features = nix-command flakes
          '';
          fonts.fontDir.enable = false; # nix will install new fonts but won't uninstall fonts; allows manually installed fonts
          fonts.fonts = [(pkgs.nerdfonts.override {fonts = ["Meslo"];})];
          services.nix-daemon.enable = true;

        })
        inputs.home-manager.darwinModules.home-manager
        {
          home-manager = {
            useGlobalPkgs = true;
            useUserPackages = true;
            users.jclark.imports = [
              ({pkgs, ...}: {
                home = {
                  stateVersion = "22.11";
                  # homeDirectory = "/Users/jclark";
                  # homeDirectory = /Users/jclark;
                  packages = with pkgs; [
                    less
                    colorls
                  ];
                  sessionVariables = {
                    PAGER = "less";
                  };
                };
                programs = {
                  git.enable = true;
                };
              })
            ];
          };
        }
      ];
    };
  };
}

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`
@jclark-dot-org jclark-dot-org added bug triage Issues or feature request that have not been triaged yet labels Nov 3, 2024
@jclark-dot-org jclark-dot-org changed the title bug: bug: Unable to build flake without home.homeDirectory error Nov 3, 2024
@frankiewiczkamil
Copy link

frankiewiczkamil commented Nov 4, 2024

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

@jclark-dot-org
Copy link
Author

@frankiewiczkamil I tried that; it resulted in a new error:

error: The option `home-manager.users.users.jclark' does not exist.

@frankiewiczkamil
Copy link

frankiewiczkamil commented Nov 10, 2024

Oh, that seems to be because you are using the nested structure for home-manager function argument. I guess in this case it should look like:

inputs.home-manager.darwinModules.home-manager
{
    users.users.jclark.home = "/Users/jclark";
    home-manager = {
    useGlobalPkgs = true;
    useUserPackages = true;
    #... further stuff

Sorry about the mistake in my previous comment. I'm still a rookie in nix, so I didn't spot that difference at first glance. Hope this one will work 🤞

@bcvanmeurs
Copy link

Thanks @frankiewiczkamil, this solved my issue as well. I wonder if the docs should be updated as the minimal example in the documentation does not include this and I couldn't get it to work without it. But I am very new to nix, so I am not sure if I am not doing something else wrong.

It seems redundant to me to both have to specify:
users.users.bram.home = "/Users/bram"; in flake.nix and
home.homeDirectory = "/Users/bram"; in home.nix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug triage Issues or feature request that have not been triaged yet
Projects
None yet
Development

No branches or pull requests

6 participants