1{
2 gnupg,
3 gpgme,
4 isLuaJIT,
5 lib,
6 libgit2,
7 libgpg-error,
8 lua,
9 lux-cli,
10 nix,
11 openssl,
12 perl,
13 pkg-config,
14 rustPlatform,
15}:
16let
17 luaMajorMinor = lib.take 2 (lib.splitVersion lua.version);
18 luaVersionDir = if isLuaJIT then "jit" else lib.concatStringsSep "." luaMajorMinor;
19 luaFeature = if isLuaJIT then "luajit" else "lua${lib.concatStringsSep "" luaMajorMinor}";
20in
21rustPlatform.buildRustPackage rec {
22 pname = "lux-lua";
23
24 version = lux-cli.version;
25
26 src = lux-cli.src;
27
28 buildAndTestSubdir = "lux-lua";
29 buildNoDefaultFeatures = true;
30 buildFeatures = [ luaFeature ];
31
32 cargoHash = lux-cli.cargoHash;
33
34 nativeBuildInputs = [
35 perl
36 pkg-config
37 ];
38
39 buildInputs = [
40 gnupg
41 gpgme
42 libgit2
43 libgpg-error
44 openssl
45 ];
46
47 propagatedBuildInputs = [
48 lua
49 ];
50
51 doCheck = false; # lux-lua tests are broken in nixpkgs
52 useNextest = true;
53 nativeCheckInputs = [
54 lua
55 nix
56 ];
57
58 env = {
59 LIBGIT2_NO_VENDOR = 1;
60 LIBSSH2_SYS_USE_PKG_CONFIG = 1;
61 LUX_SKIP_IMPURE_TESTS = 1; # Disable impure unit tests
62 };
63
64 buildPhase = ''
65 runHook preBuild
66 cargo xtask-${luaFeature} dist
67 mkdir -p $out
68 runHook postBuild
69 '';
70
71 installPhase = ''
72 runHook preInstall
73 cp -r target/dist/share $out
74 cp -r target/dist/lib $out
75 mkdir -p $out/lib/lua
76 ln -s $out/share/lux-lua/${luaVersionDir} $out/lib/lua/${luaVersionDir}
77 runHook postInstall
78 '';
79
80 cargoTestFlags = "--lib"; # Disable impure integration tests
81
82 meta = {
83 description = "Lua API for the Lux package manager";
84 homepage = "https://lux.lumen-labs.org/";
85 changelog = "https://github.com/lumen-oss/lux/blob/${src.tag}/CHANGELOG.md";
86 license = lib.licenses.lgpl3Plus;
87 maintainers = with lib.maintainers; [
88 mrcjkb
89 ];
90 platforms = lib.platforms.all;
91 };
92}