1{
2 fetchFromGitHub,
3 gnupg,
4 gpgme,
5 isLuaJIT,
6 lib,
7 libgit2,
8 libgpg-error,
9 lua,
10 nix,
11 openssl,
12 pkg-config,
13 rustPlatform,
14}:
15let
16 luaMajorMinor = lib.take 2 (lib.splitVersion lua.version);
17 luaVersionDir = if isLuaJIT then "jit" else lib.concatStringsSep "." luaMajorMinor;
18 luaFeature = if isLuaJIT then "luajit" else "lua${lib.concatStringsSep "" luaMajorMinor}";
19in
20rustPlatform.buildRustPackage rec {
21 pname = "lux-lua";
22
23 version = "0.1.5";
24
25 src = fetchFromGitHub {
26 owner = "nvim-neorocks";
27 repo = "lux";
28 # NOTE: Lux's tags represent the lux-cli version, which may differ from the lux-lua version
29 tag = "v0.5.0";
30 hash = "sha256-maVnRaEuB8q7wUukDGwB4d+go+oerkoWsnb5swPagMY=";
31 };
32
33 buildAndTestSubdir = "lux-lua";
34 buildNoDefaultFeatures = true;
35 buildFeatures = [ luaFeature ];
36
37 useFetchCargoVendor = true;
38 cargoHash = "sha256-CWPHE+j6RDtVrnYzakKecIM5dXuHuWaWK+T9xFEdmz8=";
39
40 nativeBuildInputs = [
41 pkg-config
42 ];
43
44 buildInputs = [
45 gnupg
46 gpgme
47 libgit2
48 libgpg-error
49 lua
50 openssl
51 ];
52
53 doCheck = false; # lux-lua tests are broken in nixpkgs
54 useNextest = true;
55 nativeCheckInputs = [
56 lua
57 nix
58 ];
59
60 env = {
61 LIBGIT2_NO_VENDOR = 1;
62 LIBSSH2_SYS_USE_PKG_CONFIG = 1;
63 LUX_SKIP_IMPURE_TESTS = 1; # Disable impure unit tests
64 };
65
66 postBuild = ''
67 cargo xtask-${luaFeature} dist
68 '';
69
70 installPhase = ''
71 runHook preInstall
72 install -D -v target/dist/${luaVersionDir}/* -t $out/${luaVersionDir}
73 install -D -v target/dist/lib/pkgconfig/* -t $out/lib/pkgconfig
74 runHook postInstall
75 '';
76
77 cargoTestFlags = "--lib"; # Disable impure integration tests
78
79 meta = {
80 description = "Lua API for the Lux package manager";
81 homepage = "https://nvim-neorocks.github.io/";
82 changelog = "https://github.com/nvim-neorocks/lux/blob/${src.tag}/CHANGELOG.md";
83 license = lib.licenses.mit;
84 maintainers = with lib.maintainers; [
85 mrcjkb
86 ];
87 platforms = lib.platforms.all;
88 };
89}