summaryrefslogtreecommitdiff
path: root/pkgs/development/lua-modules/lua-https/default.nix
blob: 4bcd27849cc8a3bd9b62b3a078e3dd915b2e3b6b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
{
  lib,
  buildLuaPackage,
  writeScript,
  fetchFromGitHub,
  cmake,
  lua,
  curl,
}:

buildLuaPackage rec {
  pname = "lua-https";
  version = "0-unstable-2025-02-28";

  src = fetchFromGitHub {
    owner = "love2d";
    repo = "lua-https";
    rev = "e1b77046dd3cf1a9f61ddeb63cb39d47c844c089";
    hash = "sha256-NQVB5ncw2bYJEHPQtBXqCdwp6FdQ4SJ/x97fasE5z0A=";
  };

  strictDeps = true;
  __structuredAttrs = true;

  nativeBuildInputs = [ cmake ];

  buildInputs = [
    lua
    curl
  ];

  cmakeFlags = [
    (lib.cmakeFeature "CMAKE_INSTALL_PREFIX" "${placeholder "out"}/lib/lua/${lua.luaversion}")
    (lib.cmakeFeature "LIBRARY_LOADER" "linktime")
    (lib.cmakeBool "USE_CURL_BACKEND" true) # off by default on darwin
    (lib.cmakeBool "USE_OPENSSL_BACKEND" false) # on by default on linux, but incompatible with linktime library loader
    (lib.cmakeBool "USE_NSURL_BACKEND" false) # on by default on darwin
  ];

  passthru.updateScript = writeScript "update.sh" ''
    #!/usr/bin/env nix-shell
    #!nix-shell -i bash -p curl jq common-updater-scripts

    set -euo pipefail

    response=$(curl ''${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} -sL "https://api.github.com/repos/${src.owner}/${src.repo}/commits?per_page=1")
    rev=$(echo "$response" | jq -r '.[0].sha')
    date=$(echo "$response" | jq -r '.[0].commit.committer.date' | cut -c1-10)
    update-source-version luaPackages.lua-https 0-unstable-$date --rev=$rev
  '';

  meta = {
    homepage = "https://love2d.org/wiki/lua-https";
    description = "Simple Lua HTTPS module using native platform backends specifically written for LÖVE 12.0";
    license = lib.licenses.zlib;
    maintainers = with lib.maintainers; [ ulysseszhan ];
  };
}