Skip to content

Instantly share code, notes, and snippets.

@unclechu
Created August 20, 2021 13:34
Show Gist options
  • Save unclechu/f8d19a4e71a4641c02e5adbbfe064265 to your computer and use it in GitHub Desktop.
Save unclechu/f8d19a4e71a4641c02e5adbbfe064265 to your computer and use it in GitHub Desktop.
Neovim 0.5.0 issue reproducible environment to demo that Perl integration is not working
# How to use/test:
# nix-build neovim.nix -o neovim
# neovim/bin/nvim
let
nixpkgs-unstable-pin = fetchTarball {
url = "https://releases.nixos.org/nixos/unstable/nixos-21.11pre308897.e41ba381140/nixexprs.tar.xz";
sha256 = "1smkm0z569lp321m7jsyy1fvnvl2nc8vh2nak946r9fd4hl4px4p";
};
in
{ pkgs ? import nixpkgs-unstable-pin {}
}:
let
inherit (pkgs) callPackage lib makeWrapper symlinkJoin neovim;
perlForNeovim = callPackage ./perl.nix {};
in
symlinkJoin {
name = "${lib.getName neovim}-wrapper";
nativeBuildInputs = [ makeWrapper ];
paths = [ neovim ];
postBuild = ''
wrapProgram "$out"/bin/nvim \
--prefix PATH : ${lib.escapeShellArg (lib.makeBinPath [ perlForNeovim ])}
'';
}
# Author: Viacheslav Lotsmanov
# License: MIT https://raw.githubusercontent.com/unclechu/neovimrc/master/LICENSE
# This module is intended to be called with ‘nixpkgs.callPackage’
{ fetchurl, lib, buildPerlPackage, perlPackages }:
with perlPackages;
rec {
# Automatically generated using “nix-generate-from-cpan Neovim::Ext”
NeovimExt = buildPerlPackage {
pname = "Neovim-Ext";
version = "0.05";
src = fetchurl {
url = "mirror://cpan/authors/id/J/JA/JACQUESG/Neovim-Ext-0.05.tar.gz";
sha256 = "9f3d91b040ed218b4d9523708c680533b33b4e81efcaf3e6c01ae51da2bfdd2c";
};
buildInputs = [ ArchiveZip FileSlurper FileWhich ProcBackground TestPod TestPodCoverage ];
propagatedBuildInputs = [ ClassAccessor EvalSafe IOAsync MsgPackRaw ];
meta = {
description = "Perl bindings for neovim";
license = with lib.licenses; [ artistic1 gpl1Plus ];
};
# The test is huge and it fails. It tries to download Neovim executable binary. Insane.
doCheck = false;
};
# A dependency of “NeovimExt”
EvalSafe = buildPerlPackage {
pname = "Eval-Safe";
version = "0.02";
src = fetchurl {
url = "mirror://cpan/authors/id/M/MA/MATHIAS/Eval-Safe/Eval-Safe-0.02.tar.gz";
sha256 = "55a52c233e2dae86113f9f19b34f617edcfc8416f9bece671267bd1811b12111";
};
meta = {
description = "Simplified safe evaluation of Perl code";
license = lib.licenses.mit;
};
# Bug fix when “*-devdoc” package is not found
outputs = [ "out" "dev" ];
};
# A dependency of “NeovimExt”
MsgPackRaw = buildPerlPackage {
pname = "MsgPack-Raw";
version = "0.05";
src = fetchurl {
url = "mirror://cpan/authors/id/J/JA/JACQUESG/MsgPack-Raw-0.05.tar.gz";
sha256 = "8559e2b64cd98d99abc666edf2a4c8724c9534612616af11f4eb0bbd0d422dac";
};
buildInputs = [ TestPod TestPodCoverage ];
meta = {
description = "Perl bindings to the msgpack C library";
license = with lib.licenses; [ artistic1 gpl1Plus ];
};
};
}
# Author: Viacheslav Lotsmanov
# License: MIT https://raw.githubusercontent.com/unclechu/neovimrc/master/LICENSE
# This module is intended to be called with ‘nixpkgs.callPackage’
{ callPackage
, makeWrapper
, symlinkJoin
, lib
, perl
, perlPackages
# Overridable dependencies
, localPerlDependencies ? callPackage ./perl-pependencies.nix {}
# Build options
, extraPerlDependencies ? []
}:
let
perlDeps = [
localPerlDependencies.NeovimExt
perlPackages.Appcpanminus # Neovim :checkhealth reports it’s missing
perlPackages.locallib
] ++ extraPerlDependencies;
# This is a hack to have no warnings in “:checkhealth” in Neovim.
# Obtained initially from “perl -I ~/perl5/lib/perl5/ -Mlocal::lib”.
localLibVars = lib.splitString "\n" ''
export PATH="''${HOME}/perl5/bin''${PATH:+:''${PATH}}"
export PERL5LIB="''${HOME}/perl5/lib/perl5''${PERL5LIB:+:''${PERL5LIB}}"
export PERL_LOCAL_LIB_ROOT="''${HOME}/perl5''${PERL_LOCAL_LIB_ROOT:+:''${PERL_LOCAL_LIB_ROOT}}"
export PERL_MB_OPT="--install_base \"''${HOME}/perl5\""
export PERL_MM_OPT="INSTALL_BASE=''${HOME}/perl5"
'';
in
symlinkJoin {
name = "perl-for-neovim";
nativeBuildInputs = [ makeWrapper ];
paths = [ perl ];
postBuild = ''
wrapProgram "$out"/bin/perl --prefix PERL5LIB : ${perlPackages.makeFullPerlPath perlDeps} ${
builtins.concatStringsSep " "
(map (x: "--run " + lib.escapeShellArg x) localLibVars)
}
'';
}
@rodcomucci
Copy link

Hello, on line 14 of the perl.nix file there is a spelling error: instead of './perl-pependencies.nix', it should be './perl-dependencies.nix'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment