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