Open KiaraGrouwstra opened 1 year ago
This would be so cool
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 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 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.
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.
I was trying to make a module for this myself, but I don't know if I am knowledgeable enough to do it. So I ended up making one that just lets you set settings and keybindings declaratively. If you guys think I should contribute it, I might do it.
However I also figured out some other stuff and would like to share it here if it helps someone make declarative plugin installation for Lapce possible.
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 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 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.
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.
@KaiserCalm build something that achieves this. You can see my module in my config.
I would like to contribute this to home-manager. Config would look like this:
programs.lapce = {
enable = true;
name = "lapce-nightly";
package = pkgs.lapce;
settings = {
...
};
plugins = [
{
author = "timon-schelling";
name = "nushell-lsp";
version = "0.1.0-rc2";
hash = "sha256-/s982zGl85kxRoibwSpRiXxXD1Dgq6OUVvMXIUPP//4=";
}
{
author = "MrFoxPro";
name = "lapce-nix";
version = "0.0.1";
hash = "sha256-n+j8p6sB/Bxdp0iY6Gty9Zkpv9Rg34HjKsT1gUuGDzQ=";
}
];
keymaps = [
{
command = "open_log_file";
key = "Ctrl+Shift+L";
}
];
};
Plugin download would be implemented like in my personal module:
fetchPluginTarball = { author, name, version, hash }: pkgs.stdenvNoCC.mkDerivation (
let
url = "https://plugins.lapce.dev/api/v1/plugins/${author}/${name}/${version}/download";
file = "lapce-plugin-${author}-${name}-${version}.tar.zstd";
in
{
name = file;
unpackPhase = "true";
outputHashAlgo = "sha256";
outputHashMode = "flat";
outputHash = hash;
nativeBuildInputs = [ pkgs.curl pkgs.cacert ];
builder = builtins.toFile "download-lapce-plugin.sh" ''
source "$stdenv/setup"
url="$(curl ${url})"
curl -L "$url" -o "$out"
'';
}
);
fetchPlugin = { author, name, version, hash } @ args: pkgs.stdenvNoCC.mkDerivation {
name = "lapce-plugin-${author}-${name}-${version}";
src = fetchPluginTarball args;
unpackPhase = "true";
nativeBuildInputs = [ pkgs.zstd ];
installPhase = ''
mkdir -p $out
tar -C $out -xvf $src
'';
};
fetchPlugins = plugins: pkgs.linkFarm "lapce-plugins" (builtins.listToAttrs (
builtins.map (
{ author, name, version, ... } @ plugin:
{
name = "${author}-${name}-${version}";
value = fetchPlugin plugin;
}
) plugins
));
Symliked like this:
xdg =
let
appName = "lapce-nightly";
toml = pkgs.formats.toml { };
pluginsPkg = import ./plugins.nix { inherit plugins pkgs; };
in
{
configFile = {
"${appName}/settings.toml".source =
toml.generate "settings.toml" settings;
"${appName}/keymaps.toml".source =
toml.generate "keymaps.toml" { inherit keymaps; };
};
dataFile."${appName}/plugins".source = pluginsPkg;
};
@KiaraGrouwstra would this achieve your goals?
@timon-schelling using that snippet i don't see the listed plugins installed yet, but i agree home-manager seems a better place - i'll close this in favor of your ticket then.
@KiaraGrouwstra See my pr for implementation: module file.
Or you could use my fork in the meantime, like I do.
inputs.home-manager = {
# TODO: change to upstream once merged into home-manager
url = "git+https://github.com/timon-schelling/home-manager?ref=lapce";
inputs.nixpkgs.follows = "nixpkgs";
};
If you need help getting it to work feel free to ask :)
@KiaraGrouwstra I did open a PR (Not a new issue) that would add a module that achieves what you requested, but until that PR is merged I would not close this as complete.
nixpkgs has packaged the IDE lapce, but it seems this editor also offers plugins. it would be nice if those could be made reproducible as well.
see also: https://github.com/NixOS/nixpkgs/issues/259250, where @nrabulinski commented: