Skip to content

Commit

Permalink
NOW WORKS WITH ROCKSPEC
Browse files Browse the repository at this point in the history
  • Loading branch information
teto committed Jan 21, 2019
1 parent 3c4b3d2 commit 93f2f69
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 11 deletions.
23 changes: 18 additions & 5 deletions pkgs/development/interpreters/lua-5/build-lua-package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ name ? "${attrs.pname}-${attrs.version}"
# relative to srcRoot, path to the rockspec to use when using j
, rockspecFilename ? "../*.rockspec"

, rockspecBased ? srcs != null
, knownRockspec ? null
# , rockspecBased ? srcs != null

, ... } @ attrs:

Expand Down Expand Up @@ -91,8 +92,10 @@ let
'';

#
rockspecs = lib.filter (a: lib.hasSuffix ".rockspec" ) srcs;
rockspecFilename = if rockspecs == [] then null else builtins.head rockspecs;
# rockspecs = lib.filter (a: lib.hasSuffix ".rockspec" ) srcs;
# == []
# fetchedRockspec = if rockspecBased then builtins.head srcs else null;
# builtins.head rockspecs;

in
toLuaModule ( lua.stdenv.mkDerivation (
Expand All @@ -112,11 +115,14 @@ builtins.removeAttrs attrs ["disabled" "checkInputs"] // {
# that works only for src.rock
setSourceRoot= let
name_only=(builtins.parseDrvName name).name;
in ''
in
# TODO define it differently depending if src.rock or rockspec based
lib.optionalString (knownRockspec == null)
''
# format is rockspec_basename/source_basename
# rockspec can set it via spec.source.dir
folder=$(find . -mindepth 2 -maxdepth 2 -type d -path '*${name_only}*/*'|head -n1)
sourceRoot=$folder
sourceRoot="$folder"
'';

configurePhase = ''
Expand All @@ -126,7 +132,13 @@ builtins.removeAttrs attrs ["disabled" "checkInputs"] // {
${luarocks_content}
EOF
export LUAROCKS_CONFIG=$PWD/${luarocks_config};
''
+ lib.optionalString (knownRockspec != null) ''
# prevent the following error
# Inconsistency between rockspec filename (42fm1b3d7iv6fcbhgm9674as3jh6y2sh-luv-1.22.0-1.rockspec) and its contents (luv-1.22.0-1.rockspec)
rockspecFilename="$TMP/$(stripHash ''${knownRockspec})"
cp ''${knownRockspec} $rockspecFilename
runHook postConfigure
'';

Expand Down Expand Up @@ -166,6 +178,7 @@ builtins.removeAttrs attrs ["disabled" "checkInputs"] // {
# we force the use of the upper level since it is
# the sole rockspec in that folder
# maybe we could reestablish dependency checking via passing --rock-trees
echo "ROCKSPEC $rockspecFilename"
nix_warn "cwd: $PWD"
$LUAROCKS make --deps-mode=none --tree $out ''${rockspecFilename}
Expand Down
25 changes: 20 additions & 5 deletions pkgs/development/lua-modules/generated-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -834,16 +834,31 @@ luv = buildLuarocksPackage {
pname = "luv";
version = "1.22.0-1";

srcs = [
(fetchurl {
# setSourceRoot = "cd
sourceRoot = "luv-1.22.0-1";
setSourceRoot = "";

knownRockspec = (fetchurl {
url = https://luarocks.org/luv-1.22.0-1.rockspec;
sha256 = "0yxjy9wj4aqbv1my8fkciy2xar5si6bcsszipgyls24rl6lnmga3";
})
}).outPath;

# srcs = [
# (fetchurl {
# url = https://luarocks.org/luv-1.22.0-1.rockspec;
# sha256 = "0yxjy9wj4aqbv1my8fkciy2xar5si6bcsszipgyls24rl6lnmga3";
# })
# (fetchurl {
# url = https://github.com/luvit/luv/releases/download/1.22.0-1/luv-1.22.0-1.tar.gz;
# sha256 = "1xvz4a0r6kd1xqxwm55g9n6imprxb79600x7dhyillrz7p5nm217";
# })
# ];
src =
(fetchurl {
url = https://github.com/luvit/luv/releases/download/1.22.0-1/luv-1.22.0-1.tar.gz;
sha256 = "1xvz4a0r6kd1xqxwm55g9n6imprxb79600x7dhyillrz7p5nm217";
})
];
});

disabled = ( luaOlder "5.1");

propagatedBuildInputs = [lua pkgs.libuv ];
Expand Down
2 changes: 1 addition & 1 deletion pkgs/development/lua-modules/overrides.nix
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ with self; with pkgs;
luv = super.luv.overrideAttrs(oa: {
propagatedBuildInputs = oa.propagatedBuildInputs ++ [pkgs.libuv ];
# deps/lua-compat-5.3/rockspecs/compat53-0.5-1.rockspec
rockspecFilename = "deps/lua-compat-5.3/rockspecs/compat53-scm-0.rockspec";
# rockspecFilename = "deps/lua-compat-5.3/rockspecs/compat53-scm-0.rockspec";
});

busted = super.busted.overrideAttrs(oa: {
Expand Down

0 comments on commit 93f2f69

Please sign in to comment.