Skip to content

Commit

Permalink
Merge pull request #2186 from alerque/nix-sync
Browse files Browse the repository at this point in the history
Sync Flake with nix derivation changes for easier extension of available Lua modules
  • Loading branch information
alerque authored Dec 2, 2024
2 parents 5bfd6fc + 18f707b commit 154f441
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 57 deletions.
2 changes: 1 addition & 1 deletion build-aux/ax_lua_require.m4
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ AC_DEFUN([AX_LUA_REQUIRE],[
ACTION_IF_FOUND
], [
AC_MSG_RESULT([unable to load])
m4_ifset([ACTION_IF_NOT_FOUND][ACTION_IF_NOT_FOUND],
m4_ifset([ACTION_IF_NOT_FOUND],[ACTION_IF_NOT_FOUND],
[AC_MSG_FAILURE([cannot find Lua module MODULE])])
])
Expand Down
90 changes: 40 additions & 50 deletions build-aux/pkg.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
cargo,
rustc,
rustPlatform,
luarocks,

# buildInputs
cargo-edit,
Expand All @@ -28,7 +29,6 @@
stylua,
taplo,
typos,
darwin,
# FONTCONFIG_FILE
makeFontsConf,
gentium,
Expand All @@ -41,49 +41,6 @@
libtexpdf-src,
}:

let
luaEnv = lua.withPackages (
ps:
with ps;
[
# used for module detection, also recommended at runtime for 3rd party module installation
luarocks

# modules used at runtime
cassowary
cldr
fluent
linenoise
loadkit
lpeg
lua-zlib
lua_cliargs
luaepnf
luaexpat
luafilesystem
luarepl
luasec
luasocket
luautf8
penlight
vstruct

# lua packages needed for testing
busted
luacheck

# packages needed for building api docs
ldoc
]
++ lib.optionals (lib.versionOlder lua.luaversion "5.2") [
bit32
]
++ lib.optionals (lib.versionOlder lua.luaversion "5.3") [
compat53
]
);

in
stdenv.mkDerivation (finalAttrs: {
pname = "sile";
inherit version src;
Expand All @@ -104,7 +61,10 @@ stdenv.mkDerivation (finalAttrs: {
cargo
rustc
rustPlatform.cargoSetupHook
luarocks
];
# luarocks propagates cmake, but it shouldn't be used as a build system.
dontUseCmakeConfigure = true;

preAutoreconf = ''
# Add the libtexpdf src instead of the git submodule. (From some reason
Expand All @@ -120,8 +80,8 @@ stdenv.mkDerivation (finalAttrs: {

buildInputs =
[
finalAttrs.finalPackage.passthru.luaEnv
cargo-edit
luaEnv
harfbuzz
icu
fontconfig
Expand All @@ -130,9 +90,6 @@ stdenv.mkDerivation (finalAttrs: {
stylua
taplo
typos
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
darwin.apple_sdk.frameworks.AppKit
];

configureFlags =
Expand Down Expand Up @@ -175,8 +132,41 @@ stdenv.mkDerivation (finalAttrs: {
'';

passthru = {
# So it will be easier to inspect this environment, in comparison to others
inherit luaEnv;

luaPackages =
[
# modules used at runtime
"cassowary"
"cldr"
"fluent"
"linenoise"
"loadkit"
"lpeg"
"lua-zlib"
"lua_cliargs"
"luaepnf"
"luaexpat"
"luafilesystem"
"luarepl"
"luasec"
"luasocket"
"luautf8"
"penlight"
"vstruct"
# lua packages needed for testing
"busted"
"luacheck"
# packages needed for building api docs
"ldoc"
]
++ lib.optionals (lib.versionOlder lua.luaversion "5.2") [
"bit32"
]
++ lib.optionals (lib.versionOlder lua.luaversion "5.3") [
"compat53"
];
luaEnv = lua.withPackages (ps: lib.attrVals finalAttrs.finalPackage.passthru.luaPackages ps);

# Copied from Makefile.am
tests.test = lib.optionalAttrs (!(stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64)) (
runCommand "${finalAttrs.pname}-test"
Expand Down
12 changes: 6 additions & 6 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 154f441

Please sign in to comment.