Unverified Commit d1769e35 authored by Austin Horstman's avatar Austin Horstman
Browse files

luarocks-packages-updater: nixfmt-rfc-style output formatting

parent 3654cda7
Loading
Loading
Loading
Loading
+17 −9
Original line number Diff line number Diff line
@@ -50,7 +50,8 @@ PKG_LIST = "maintainers/scripts/luarocks-packages.csv"
TMP_FILE = "$(mktemp)"
GENERATED_NIXFILE = "pkgs/development/lua-modules/generated-packages.nix"

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: nix run nixpkgs#luarocks-packages-updater
  You can customize the generated packages in pkgs/development/lua-modules/overrides.nix
*/
@@ -58,7 +59,7 @@ You can customize the generated packages in pkgs/development/lua-modules/overrid

FOOTER = """
}
/* GENERATED - do not edit this file */
# GENERATED - do not edit this file
"""


@@ -119,9 +120,15 @@ class LuaEditor(pluginupdate.Editor):
            f.write(HEADER)
            header2 = textwrap.dedent(
            """
                { stdenv, lib, fetchurl, fetchgit, callPackage, ... }:
                final: prev:
            {
              stdenv,
              lib,
              fetchurl,
              fetchgit,
              callPackage,
              ...
            }:
            final: prev: {
            """
            )
            f.write(header2)
@@ -231,7 +238,8 @@ 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"
        ## FIXME: luarocks nix command output isn't formatted properly
        output = "callPackage(\n" + output.strip() + ") {};\n\n"
        return (plug, output, None)
    except subprocess.CalledProcessError as e:
        log.error("Failed to generate nix expression for %s: %s", plug.name, e)