I’m trying to manage the coc-ltex
extension with Nix which a Node package which requires the ltex-ls
Node and a Java install. However, even if the dependencies are installed on the system, the extension can’t find them.
Taking a look at the directory structure when the extension is installed through CoC, one may see that it expects to find the dependencies inside the installation directory:
$ tree -L 3
├── dist
│ └── extension.js
├── i18n
│ ├── messages.nls.de.json
│ └── messages.nls.json
├── img
│ └── logo-ltex.png
├── lib
│ └── ltex-ls-15.2.0 <--- ltex-ls
│ ├── bin
│ ├── jdk-11.0.12+7 <--- Java install "inside" ltex-ls
│ └── lib
├── package.json
├── package.nls.de.json
└── package.nls.json
Since the structures are “nested”, I couldn’t get around this issue by linking paths with a buildEnv
so I use a dirty hack: I add a patchPhase
to the coc-ltex
Node package where I manually add links to the dependencies as follows:
coc-ltex = let
ltex = pkgs.ltex-ls;
jdk = pkgs.jdk11_headless;
in pkgs.vimPlugins.coc-ltex.overrideAttrs (old: {
buildInputs = with pkgs; [
ltex
jdk
];
patchPhase = ''
mkdir -p $out/lib/${ltex.name}/${jdk.name}
ln -s ${ltex}/bin $out/lib/${ltex.name}/bin
ln -s ${ltex}/lib $out/lib/${ltex.name}/lib
ln -s ${jdk}/bin $out/lib/${ltex.name}/${jdk.name}/bin
ln -s ${jdk}/lib $out/lib/${ltex.name}/${jdk.name}/lib
'';
});
How can I fixed this issue with a less dirty trick?
I don’t know much yet about packaging Node packages with Nix, is it something usual (does not look like) that can be easily fixed in the build process?