nixd icon indicating copy to clipboard operation
nixd copied to clipboard

problems with home-manager.nixosModules.home-manager

Open Blezz-tech opened this issue 9 months ago • 1 comments

nixd works for home-manager.nixosModules.home-manager somehow partially

Shows the versions of the programs image

But let's try to get hints for programs from the home-manager image

Not work helper message image

my flake.nix

{
  description = "Jenya NixOS Flake Configuration";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";

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

  outputs = { nixpkgs, home-manager, ... }@inputs: {
    nixosConfigurations = {
      "pc-full" = nixpkgs.lib.nixosSystem {
        specialArgs = { inherit inputs; };
        modules = [
          ./nixos
          home-manager.nixosModules.home-manager
          {
            home-manager = {
              useGlobalPkgs = true;
              useUserPackages = true;
              users.jenya = import ./home;
              extraSpecialArgs.inputs = inputs;
            };
          }
        ];
      };
    };
  };
}

Blezz-tech avatar May 01 '24 15:05 Blezz-tech

users.jenya = import ./home;

Looks like you are using HM attributes in an nested import. It's generally hard to check this dataflow. (i.e. nixd cannot know imported file will be used as a part of NixOS modules, or HM modules, or nested in some attribute paths.

Maybe you could write standalone HM options and follow nixd examples in this repo.

inclyc avatar May 02 '24 03:05 inclyc

My nix-darwin and home-manager configs are in separate files as well. They're both rather big, so having them in separate files makes it a bit easier to update etc.

It'd be cool if you could supply some sort of hint similar to JSDoc import types or Deno's @deno-types.

I have no idea if this makes any sense, but maybe it would look something like this in home.nix.

{ pkgs, ... }:

# type = (import "github:nix-community/home-manager").home-manager.users.<name>
{
  home = {
    stateVersion = "23.11";
  };

  programs = {
    bash.enable = true;
    git = {
      enable = true;
      delta.enable = true;
      lfs.enable = true;
    };
  };
}

han-tyumi avatar Jun 11 '24 19:06 han-tyumi

My nix-darwin and home-manager configs are in separate files as well.

Type hints in comment is a planned feature.

inclyc avatar Jun 12 '24 01:06 inclyc

users.jenya = import ./home;

Looks like you are using HM attributes in an nested import. It's generally hard to check this dataflow. (i.e. nixd cannot know imported file will be used as a part of NixOS modules, or HM modules, or nested in some attribute paths.

Maybe you could write standalone HM options and follow nixd examples in this repo.

Excuse me. I forgot to answer. I did as you said and wrote standalone HM options.

This work:

{
  description = "Jenya NixOS Flake Configuration";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";

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

  outputs = { nixpkgs, home-manager, ... }@inputs:
    let
      system = "x86_64-linux";
      username = "jenya";
    in
    {
      nixosConfigurations."pc" = nixpkgs.lib.nixosSystem {
        specialArgs = { inherit inputs username; };
        modules = [ ./nixos ];
      };
      homeConfigurations.${username} = home-manager.lib.homeManagerConfiguration {
        pkgs = nixpkgs.legacyPackages.${system};
        modules = [ ./home ];
        extraSpecialArgs = {
          inherit inputs system username;
        };
      };
    };
}

Thank you!

Blezz-tech avatar Jun 12 '24 09:06 Blezz-tech