BirdeeHub / nixCats-nvim

A framework for configuring neovim like neovim via nix, and having multiple config profiles. (with example config(s) and in-editor help)
https://nixcats.org/nixCats_installation.html
MIT License
260 stars 12 forks source link

Help with HomeManager Module #49

Closed Saboti closed 2 weeks ago

Saboti commented 2 weeks ago

Hi BirdeeHub,

first, I realy like your NixCat work! Already got it to work with the nixExpressionFlakeOutputs.

In Inputs:

    nixCats = {
      url = "github:BirdeeHub/nixCats-nvim?dir=nix";
    };

included this in my homeManager default.nix:

let
  #myNixCats = import ./nixCats { inherit inputs; };
  myNixCats = import ./nixCats-kickstart { inherit inputs; };
in

The Folder nixCats or nixCats-kickstart is in the same folder as the default.nix for Home Manager. In the folder is the default.nix config from the nixExpressionFlakeOutputs.

But i don't understand how to include nixCats as a HomeManager Module which would be my goal :) Any help would be appreciated.

Regards Tobias

BirdeeHub commented 2 weeks ago

https://github.com/BirdeeHub/nixCats-nvim/blob/b02e9655894c402e9398369b94fab57d2bf5f359/nix/templates/module/homeCat.nix#L4C1-L6C5

So, this is the template for home manager.

You can see at the location I linked to, it has inputs.nixCats.homeModule ?

you would use myNixCats.homeModule there

The nixExpressionFlakeOutputs template exports the same items as the main flake template, and you can clone the example flake and explore them in the repl if you get stuck, or explore your own by exporting myNixCats as an output of your system flake :)

BirdeeHub commented 2 weeks ago

the modules are similar to override. They allow you to import from an existing nixCats based configuration, and then modify them on install. Override also does this, but if you are using nixos or home manager, the module fits in nicer :)

Theres also these docs for the module options and hopefully you can see how they map to the normal ones?

https://nixcats.org/nixCats_modules.html

BirdeeHub commented 2 weeks ago

If you just want to import the packages from your config in your nixExpressionFlakeOutputs template implementation as-is, I would suggest just putting myNixCats.packages.${pkgs.system}.packagename into your home or system packages lists however, as its less complication.

Saboti commented 2 weeks ago

If you just want to import the packages from your config in your nixExpressionFlakeOutputs template implementation as-is, I would suggest just putting myNixCats.packages.${pkgs.system}.packagename into your home or system packages lists however, as its less complication.

exactly this i have done so far. In my home.packages = with pkgs; [ ... myNixCats.packages.${system}.nvim ]; I have this included.

Sorry, I picked up Nix recently so don't understanding all the concepts :) I always thinking i have to include Module in my HomeManager Config in my flake.nix like:

          {
            home-manager = {
              useGlobalPkgs = true;
              useUserPackages = true;
              extraSpecialArgs = { inherit inputs username useremail system; };
              users.${username} = { ... }:
                with inputs; {
                  imports = [ ./home-manager catppuccin.homeManagerModules.catppuccin ];
                };
            };

and than add the Module in the home manager Configuration and config it there. But I see now this is not how it works since the Package and everything has to be build first. I think I just stick to the working Version I have :) Thank you for the explanations.

Saboti commented 2 weeks ago

Now I did understand it. Found a example in another Repo. I had the following Problem:

       at /nix/store/x4nlzgz862i6hkjy7r0zwxgdwnkdkcg3-source/home-manager/nixCats-homeModule/default.nix:5:5:

            4|   imports = [
            5|     inputs.nixCats.homeModule
             |     ^
            6|   ];

this error happend how I defined the Input:

    nixCats = {
      url = "github:BirdeeHub/nixCats-nvim?dir=nix";
    };

Solution: I removed the ?dir=nix and now its working for me :)

I created a new folder in my home-manager config and put there your homeModule as default.nix with the lua config etc. This folder i included in the import of my main home-manager config.

Hope it's understandable what I have done. No native speaker ;)

BirdeeHub commented 2 weeks ago

So, in the nixCats repo there are 2 flakes.

1, in the nix dir which is used by the 2 starter templates, which outputs JUST the nixCats library and has no dependencies. It does not output packages or modules. Modules need to be based on a package, and this outputs no packages. So no modules.

You import it with dir=nix and use it to make your own configuration, which then outputs its own modules based on itself

The 2 starter templates use this first flake, inside the nix dir, because you are meant to make your own configuration, not import my crappy example one.

  1. The other flake is the flake you see right there in the root level when you open the repo. This one outputs the example configuration, along with the modules and packages based on it. It is an example of how to use the default template, and also to give people something they can run to try it out.

Your config based on the default template or the nixExpressionFlakeOutputs template will output all the same things as the flake I listed as #2 above does, and it will import number 1 to do it.

If you want to use the module based on the example configuration, go right ahead, as long as you know that is what is happening

Saboti commented 2 weeks ago

Thank you very much for your patience with my questions :) With the last explanation and some github search I do now understand it.

Found many examples where they use the "wrong" input. I will close the Issue now.

BirdeeHub commented 2 weeks ago

Yeah I know haha, but yeah ultimately its fine, people are free to use it as they wish, its just better the other way IMO :)

BirdeeHub commented 2 weeks ago

I wish I would have done it differently and had the example config in its own repo and had the dependencyless flake that outputs the library here, but it began this way, and gained the other flake later. Plus, its nice to give people something to run out of the box, and the templates hopefully usually guide people correctly

BirdeeHub commented 2 weeks ago

Its also possible people using the main flake have been using it for longer than the other flake has been around and they havent found it yet. That was added in the last 3 or 4 months.