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

Home-manager as module #109

Open
RAVENz46 opened this issue Aug 20, 2024 · 2 comments
Open

Home-manager as module #109

RAVENz46 opened this issue Aug 20, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@RAVENz46
Copy link

Is your feature request related to a problem? Please describe.

Currently, to upgrade packages, we need to run system-manager switch and home-manager switch separetly.

Describe the solution you'd like

It would be nice intagrating home-manager like nixos-modules, nix-darwin, nix-os-droid.

Describe alternatives you've considered

Alias💩?

Additional context

@RAVENz46 RAVENz46 added the enhancement New feature or request label Aug 20, 2024
@r-vdp
Copy link
Member

r-vdp commented Aug 20, 2024

Did you try just including HM in the same way as you do on nixos? Did anything break?

@booxter
Copy link

booxter commented Sep 9, 2024

@r-vdp

I've tried to mimic how nix-darwin is configured for home-manager here.

The relevant code is:

    mkHome = username: modules: {
      home-manager = {
        useGlobalPkgs = true;
        useUserPackages = true;
        backupFileExtension = "backup";
        extraSpecialArgs = { inherit inputs username; };
        users."${username}".imports = modules;
      };
    };
    globalModules = { username }: [
      (mkHome username [
        ./modules/home-manager
        inputs.nixvim.homeManagerModules.nixvim
      ])
    ];
    globalModulesSystemManager = { system, username }: globalModules { inherit username; } ++ [
      ./modules/system-manager
      (home-manager system).nixosModules.home-manager
    ];

...


    systemConfigs.default = let
      system = "x86_64-linux";
    in inputs.system-manager.lib.makeSystemConfig {
      extraSpecialArgs = { inherit username; };
      modules = (globalModulesSystemManager { inherit system username; });
    };

When I try to build this, I get the following error:

       … while evaluating the attribute 'value'
         at /nix/store/x615nvk9kw68cmsg01aahd1v0kzv9ifn-source/lib/modules.nix:619:53:
          618|                 (n: value:
          619|                   [{ inherit (module) file; inherit value; }]
             |                                                     ^
          620|                 )

       error: attribute 'name' missing
       at /nix/store/h9yqjv446d8x118pkzx5kxgj5yvds9a5-home-manager/nixos/common.nix:34:27:
           33|
           34|           home.username = config.users.users.${name}.name;
             |                           ^
           35|           home.homeDirectory = config.users.users.${name}.home;

I am not sure why darwin flavor of the home-manager module works, but it looks like the nixosModules.home-manager doesn't get name passed to the module. I tried to add name = username; to extraSpecialArgs but it doesn't seem to help. I am not sure how to bend all of it to make it work, since I am still vague on how all the layers of indirection. I wonder if you have some specific idea on how to fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants