Commit 253af915 authored by Matthieu Coudron's avatar Matthieu Coudron Committed by Matthieu Coudron
Browse files

luaPackages: update

- luarocks-nix: bumped to pass args too, `package_X = callPackage ...`.
  It allows to remove the annoying `with self`.
  This new version disables tests (because broken) and now emits derivation
  with a callPackage in front.
- replaced X.override with lib.overrideLuarocks, it should be used
whenever buildInputs/extraVariables is changed since it impacts the
generated luarocks config.
Once structured attributes are in, it will be easier to have the
luarocks config generated by a hook and we probably will be able to
replace all overrideLuarocks by overrideAttrs.
parent ecd018bb
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -33,8 +33,7 @@ TMP_FILE="$(mktemp)"
GENERATED_NIXFILE="pkgs/development/lua-modules/generated-packages.nix"
LUAROCKS_CONFIG="$NIXPKGS_PATH/maintainers/scripts/luarocks-config.lua"

HEADER = """
/* {GENERATED_NIXFILE} is an auto-generated file -- DO NOT EDIT!
HEADER = """/* {GENERATED_NIXFILE} is an auto-generated file -- DO NOT EDIT!
Regenerate it with:
nixpkgs$ ./maintainers/scripts/update-luarocks-packages

@@ -99,9 +98,8 @@ class LuaEditor(Editor):
            header2 = textwrap.dedent(
            # header2 = inspect.cleandoc(
            """
                { self, stdenv, lib, fetchurl, fetchgit, ... } @ args:
                self: super:
                with self;
                { self, stdenv, lib, fetchurl, fetchgit, callPackage, ... } @ args:
                final: prev:
                {
            """)
            f.write(header2)
@@ -199,6 +197,7 @@ def generate_pkg_nix(plug: LuaPlugin):

    log.debug("running %s", ' '.join(cmd))
    output = subprocess.check_output(cmd, text=True)
    output = "callPackage(" + output.strip() + ") {};\n\n"
    return (plug, output)

def main():
+11 −10
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@ pname
# propagate build dependencies so in case we have A -> B -> C,
# C can import package A propagated by B
, propagatedBuildInputs ? []
, propagatedNativeBuildInputs ? []

# used to disable derivation, useful for specific lua versions
# TODO move from this setting meta.broken to a 'disabled' attribute on the
@@ -50,7 +49,7 @@ pname
# The latter is used to work-around luarocks having a problem with
# multiple-output derivations as external deps:
# https://github.com/luarocks/luarocks/issues/766<Paste>
, externalDeps ? lib.unique (lib.filter (drv: !drv ? luaModule) (propagatedBuildInputs ++ buildInputs))
, externalDeps ? []

# Appended to the generated luarocks config
, extraConfig ? ""
@@ -74,7 +73,6 @@ pname
let
  generatedRockspecFilename = "${rockspecDir}/${pname}-${version}.rockspec";


  # TODO fix warnings "Couldn't load rockspec for ..." during manifest
  # construction -- from initial investigation, appears it will require
  # upstream luarocks changes to fix cleanly (during manifest construction,
@@ -83,7 +81,7 @@ let
  luarocks_config = "luarocks-config.lua";
  luarocks_content = let
    generatedConfig = lua.pkgs.lib.generateLuarocksConfig {
      inherit externalDeps;
      externalDeps = externalDeps ++ externalDepsGenerated;
      inherit extraVariables;
      inherit rocksSubdir;
      inherit requiredLuaRocks;
@@ -99,12 +97,13 @@ let
  # Filter out the lua derivation itself from the Lua module dependency
  # closure, as it doesn't have a rock tree :)
  requiredLuaRocks = lib.filter (d: d ? luaModule)
    (lua.pkgs.requiredLuaModules propagatedBuildInputs);
    (lua.pkgs.requiredLuaModules luarocksDrv.propagatedBuildInputs);

  # example externalDeps': [ { name = "CRYPTO"; dep = pkgs.openssl; } ]
  externalDepsGenerated = lib.unique (lib.filter (drv: !drv ? luaModule) (luarocksDrv.propagatedBuildInputs ++ luarocksDrv.buildInputs));
  externalDeps' = lib.filter (dep: !lib.isDerivation dep) externalDeps;
in
toLuaModule ( lua.stdenv.mkDerivation (

  luarocksDrv = toLuaModule ( lua.stdenv.mkDerivation (
builtins.removeAttrs attrs ["disabled" "checkInputs" "externalDeps" "extraVariables"] // {

  name = namePrefix + pname + "-" + version;
@@ -146,13 +145,12 @@ builtins.removeAttrs attrs ["disabled" "checkInputs" "externalDeps" "extraVariab
    runHook postConfigure
  '';

  # TODO could be moved to configurePhase
  buildPhase = ''
    runHook preBuild

    nix_debug "Using LUAROCKS_CONFIG=$LUAROCKS_CONFIG"

    LUAROCKS=luarocks
    LUAROCKS=${lua.pkgs.luarocks}/bin/luarocks
    if (( ''${NIX_DEBUG:-0} >= 1 )); then
        LUAROCKS="$LUAROCKS --verbose"
    fi
@@ -195,6 +193,7 @@ builtins.removeAttrs attrs ["disabled" "checkInputs" "externalDeps" "extraVariab
  passthru = {
    inherit lua; # The lua interpreter
    inherit externalDeps;
    inherit luarocks_content;
  } // passthru;

  meta = {
@@ -203,4 +202,6 @@ builtins.removeAttrs attrs ["disabled" "checkInputs" "externalDeps" "extraVariab
    maintainers = (meta.maintainers or []) ++ [ ];
    broken = disabled;
  } // meta;
}))
}));
in
  luarocksDrv
+1 −1
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@ let
  overridenPackages = import ./overrides.nix { inherit pkgs; };

  generatedPackages = if (builtins.pathExists ./generated-packages.nix) then
        pkgs.callPackage ./generated-packages.nix { } else (final: prev: {});
    (final: prev: pkgs.callPackage ./generated-packages.nix { inherit (final) callPackage; } final prev) else (final: prev: {});

  extensible-self = lib.makeExtensible
    (extends overrides
+540 −293

File changed.

Preview size limit exceeded, changes collapsed.

+12 −0
Original line number Diff line number Diff line
@@ -5,8 +5,20 @@ let
  in unique ([lua] ++ modules ++ concatLists (catAttrs "requiredLuaModules" modules));
  # Check whether a derivation provides a lua module.
  hasLuaModule = drv: drv ? luaModule;


  /*
  Use this to override the arguments passed to buildLuarocksPackage
  */
  overrideLuarocks = drv: f: (drv.override (args: args // {
    buildLuarocksPackage = drv: (args.buildLuarocksPackage drv).override f;
  })) // {
    overrideScope = scope: overrideLuarocks (drv.overrideScope scope) f;
  };

in
rec {
  inherit overrideLuarocks;
  inherit hasLuaModule requiredLuaModules;

  luaPathList = [
Loading