nix-community / home-manager

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

Add `finalPackage` for kakoune #2633

Open harris-chris opened 2 years ago

harris-chris commented 2 years ago

Hello - I'd like to use the home-manager-built kakoune executable as an input in other derivations. My understanding is that this is not possible unless the home-manager derivation is set to expose the final output - as is the case with the home-manager emacs.nix - my source for this here: https://discourse.nixos.org/t/using-home-manager-generated-packages-as-dependencies/16952 Would it be possible to have kakoune.nix configured in the same way?

mainrs commented 2 years ago

Out of curiosity: What do you want to do with an exposed kakoune? :)

harris-chris commented 2 years ago

Sure - I'd like to create a derivation that wraps kakoune such that there's only one kakoune server per workspace, and all kakoune clients attach to that. So the dependency would have kakoune and wmctrl (to recover the workspace name) as dependencies.

teto commented 2 years ago

yes. PR welcome. You can copy what is done for neovim

stale[bot] commented 2 years ago

Thank you for your contribution! I marked this issue as stale due to inactivity. Please be considerate of people watching this issue and receiving notifications before commenting 'I have this issue too'. We welcome additional information that will help resolve this issue. Please read the relevant sections below before commenting.

If you are the original author of the issue

* If this is resolved, please consider closing it so that the maintainers know not to focus on this. * If this might still be an issue, but you are not interested in promoting its resolution, please consider closing it while encouraging others to take over and reopen an issue if they care enough. * If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.

If you are not the original author of the issue

* If you are also experiencing this issue, please add details of your situation to help with the debugging process. * If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.

Memorandum on closing issues

Don't be afraid to manually close an issue, even if it holds valuable information. Closed issues stay in the system for people to search, read, cross-reference, or even reopen – nothing is lost! Closing obsolete issues is an important way to help maintainers focus their time and effort.

harris-chris commented 2 years ago

Hello - I am just getting onto this. I have forked & feature-branched this repo, and (without any profound insight into what I'm actually doing) altered the local copy of kakoune.nix to finish like this, similar to neovim or emacs:

      finalPackage = mkOption {
        ...
        description = ''
          The Kakoune package including any overrides and extra packages.
        '';
      };
    };
  };

  config = mkIf cfg.enable {
    home.packages = [ cfg.finalPackage ];
    xdg.configFile."kak/kakrc".source = configFile;
    programs.kakoune = {
      finalPackage = kakouneWithPlugins;
    };
  };
}

This seems to work (in that if I home-manager switch, no errors are thrown), but I'd like to test it in an example where I create a wrapper around the kakoune program, which was the original purpose: https://discourse.nixos.org/t/using-home-manager-generated-packages-as-dependencies/16952 I am not sure how I should be doing this - how can I refer to this finalPackage-d kakoune from other derivations? I guess not just as nixpkgs.kakoune? Any help appreciated.

teto commented 2 years ago

what about programs.kakoune.finalPackage ?

harris-chris commented 2 years ago

Thanks, that sounds like it should work, but where is this programs.kakoune.finalPackage available from? I guess from within my home-managerconfig, but not anywhere on the system? I've just tried setting my home.nix to look something like this:

programs = rec {
    wrapkak = pkgs.writeShellScriptBin "wrapkak"
    ''
      #! ${pkgs.bash}/bin/bash
      echo "stay calm this is a wrapper"
      exec ${kakoune.finalPackage}/bin/kak $@
    '';
    kakoune = {
      enable = true;
      plugins = with pkgs.kakounePlugins; [
        kak-fzf
        powerline-kak
        kakboard
      ];
      ... rest of the kakoune config here ...
  };

but it says it can't find kakoune.finalPackage. I'm not sure if that's because my changes to the home-manager kakoune.nix were wrong, or whether I'm just calling it from the wrong place.

teto commented 2 years ago

grep the code for "finalPackage" and I am sure you will find your solution ;)