1{
2 gnupg,
3 gpgme,
4 isLuaJIT,
5 lib,
6 libgit2,
7 libgpg-error,
8 lua,
9 lux-cli,
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 = lux-cli.version;
24
25 src = lux-cli.src;
26
27 buildAndTestSubdir = "lux-lua";
28 buildNoDefaultFeatures = true;
29 buildFeatures = [ luaFeature ];
30
31 cargoHash = lux-cli.cargoHash;
32
33 nativeBuildInputs = [
34 pkg-config
35 ];
36
37 buildInputs = [
38 gnupg
39 gpgme
40 libgit2
41 libgpg-error
42 lua
43 openssl
44 ];
45
46 doCheck = false; # lux-lua tests are broken in nixpkgs
47 useNextest = true;
48 nativeCheckInputs = [
49 lua
50 nix
51 ];
52
53 env = {
54 LIBGIT2_NO_VENDOR = 1;
55 LIBSSH2_SYS_USE_PKG_CONFIG = 1;
56 LUX_SKIP_IMPURE_TESTS = 1; # Disable impure unit tests
57 };
58
59 postBuild = ''
60 cargo xtask-${luaFeature} dist
61 '';
62
63 installPhase = ''
64 runHook preInstall
65 install -D -v target/dist/${luaVersionDir}/* -t $out/${luaVersionDir}
66 install -D -v target/dist/lib/pkgconfig/* -t $out/lib/pkgconfig
67 runHook postInstall
68 '';
69
70 cargoTestFlags = "--lib"; # Disable impure integration tests
71
72 meta = {
73 description = "Lua API for the Lux package manager";
74 homepage = "https://nvim-neorocks.github.io/";
75 changelog = "https://github.com/nvim-neorocks/lux/blob/${src.tag}/CHANGELOG.md";
76 license = lib.licenses.mit;
77 maintainers = with lib.maintainers; [
78 mrcjkb
79 ];
80 platforms = lib.platforms.all;
81 };
82}