Build Lua package in nix-shell `shell.nix`

311 Views Asked by At

I'm trying to build for a nix-shell that aren't in the current nixpkgs repository. Specifically: raylua

I've managed to get Raylib itself built as part of a nix-shell using Nim. I'm trying to now modify this to use Lua Raylib and the Lua libraries and am unsure how to procede.

I see people use nix-shell ... commands to bypass a lot of this pain, but I want something I can commit to a repo.

Files I have are:

shell.nix

{ pkgs ? import <nixpkgs> {} }:

let
    unstable = import <unstable> {};
    raylib = pkgs.callPackage ./nix/raylib/default.nix { };
    # toLuaModule
    #raylib-lua = pkgs.callPackage ./nix/raylib-lua/default.nix { raylib };
in
pkgs.mkShell {
    buildInputs = [
        pkgs.bashInteractive
        pkgs.glfw
        pkgs.luajit
        raylib
        #raylua
    ];
}

nix/raylib/default.nix

Same as in https://github.com/adamlwgriffiths/nix-nim/

nix/raylua/default.nix

{ stdenv, lib, fetchFromGitHub, make, luaPackages }: #, raylib }:

with luaPackages;

let
    libs = [];
in
stdenv.mkDerivation rec {
  pname = "raylua";
  version = "3.5.0";

  src = fetchFromGitHub {
    owner = "Rabios";
    repo = pname;
    rev = version;
    sha256 = "0syvd5js1lbx3g4cddwwncqg95l6hb3fdz5nsh5pqy7fr6v84kwj";
  };

  lualibs = [ luaPackages.lua ];
  buildInputs = [ make ] ++ lualibs;

  LUA_PATH = stdenv.lib.concatStringsSep ";" (map luaPackages.getLuaPath lualibs);
  LUA_CPATH = stdenv.lib.concatStringsSep ";" (map luaPackages.getLuaCPath lualibs);

  configureFlags = ''
    LUA_PATH="${LUA_PATH}"
    LUA_CPATH="${LUA_CPATH}"
    INST_LIBDIR="$out/lib/lua/${luaPackages.lua.luaversion}"
    INST_LUADIR="$out/share/lua/${luaPackages.lua.luaversion}"
    LUA_BINDIR="${luaPackages.lua}/bin"
    LUA_INCDIR="-I${luaPackages.lua}/include"
    LUA_LIBDIR="-L${luaPackages.lua}/lib"
  '';

  meta = with stdenv.lib; {
    description = "Lua bindings for raylib, a simple and easy-to-use library to enjoy videogames programming";
    homepage = "https://github.com/Rabios/raylua";
    license = licenses.isc;
    maintainers = with maintainers; [ adamlwgriffiths ];
    platforms = platforms.linux;
  };
}

0

There are 0 best solutions below