Unverified Commit f15e58cb authored by Matthieu Coudron's avatar Matthieu Coudron Committed by GitHub
Browse files

luarocks-packages-update: init (#262156)

* luarocks-packages-updater: init

Goal is to make it possible to maintain out-of-tree luarocks packages
without needing to clone nixpkgs.

maintainers/scripts/update-luarocks-packages gets renamed to
pkgs/development/lua-modules/updater/updater.py

Once merged you can run for instance
nix run nixpkgs#luarocks-packages-updater -- -i contrib/luarocks-packages.csv -o contrib/generated-packages.nix

I also set the parallelism (--proc) to 1 by default else luarocks fails
because of https://github.com/luarocks/luarocks/issues/1540



* Update maintainers/scripts/pluginupdate.py

Co-authored-by: default avatarMarc Jakobi <mrcjkb89@outlook.com>

---------

Co-authored-by: default avatarMarc Jakobi <mrcjkb89@outlook.com>
parent 24df0476
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -134,11 +134,11 @@ The site proposes two types of packages, the `rockspec` and the `src.rock`

Luarocks-based packages are generated in [pkgs/development/lua-modules/generated-packages.nix](https://github.com/NixOS/nixpkgs/tree/master/pkgs/development/lua-modules/generated-packages.nix) from
the whitelist maintainers/scripts/luarocks-packages.csv and updated by running
the script
[maintainers/scripts/update-luarocks-packages](https://github.com/NixOS/nixpkgs/tree/master/maintainers/scripts/update-luarocks-packages):
the package `luarocks-packages-updater`:

```sh
./maintainers/scripts/update-luarocks-packages update

nix-shell -p luarocks-packages-updater --run luarocks-packages-updater
```

[luarocks2nix](https://github.com/nix-community/luarocks) is a tool capable of generating nix derivations from both rockspec and src.rock (and favors the src.rock).
+12 −3
Original line number Diff line number Diff line
@@ -468,6 +468,7 @@ class Editor:
            "--input-names",
            "-i",
            dest="input_file",
            type=Path,
            default=self.default_in,
            help="A list of plugins in the form owner/repo",
        )
@@ -476,6 +477,7 @@ class Editor:
            "-o",
            dest="outfile",
            default=self.default_out,
            type=Path,
            help="Filename to save generated nix code",
        )
        common.add_argument(
@@ -787,10 +789,17 @@ def update_plugins(editor: Editor, args):

    if autocommit:
        from datetime import date
        editor.nixpkgs_repo = git.Repo(editor.root, search_parent_directories=True)
        updated = date.today().strftime('%m-%d-%Y')

        commit(editor.nixpkgs_repo, f"{editor.attr_path}: updated the {updated}", [args.outfile])
        try:
            repo = git.Repo(os.getcwd())
            updated = date.today().strftime('%m-%d-%Y')
            print(args.outfile)
            commit(repo,
                   f"{editor.attr_path}: updated the {updated}", [args.outfile]
                   )
        except git.InvalidGitRepositoryError as e:
            print(f"Not in a git repository: {e}", file=sys.stderr)
            sys.exit(1)

    if redirects:
        update()
+0 −13
Original line number Diff line number Diff line
{ nixpkgs ? import ../.. { }
}:
with nixpkgs;
let
  pyEnv = python3.withPackages(ps: [ ps.gitpython ]);
in
mkShell {
  packages = [
    pyEnv
    luarocks-nix
    nix-prefetch-scripts
  ];
}
+4 −0
Original line number Diff line number Diff line
@@ -162,6 +162,10 @@

- `getent` has been moved from `glibc`'s `bin` output to its own dedicated output, reducing closure size for many dependents. Dependents using the `getent` alias should not be affected; others should move from using `glibc.bin` or `getBin glibc` to `getent` (which also improves compatibility with non-glibc platforms).

- `maintainers/scripts/update-luarocks-packages` is now a proper package
  `luarocks-packages-updater` that can be run to maintain out-of-tree luarocks
  packages

- The `users.users.<name>.passwordFile` has been renamed to `users.users.<name>.hashedPasswordFile` to avoid possible confusions. The option is in fact the file-based version of `hashedPassword`, not `password`, and expects a file containing the {manpage}`crypt(3)` hash of the user password.

- The `services.ananicy.extraRules` option now has the type of `listOf attrs` instead of `string`.
+49 −0
Original line number Diff line number Diff line
{ buildPythonApplication
, nix
, makeWrapper
, python3Packages
, lib
# , nix-prefetch-git
, nix-prefetch-scripts
, luarocks-nix
}:
let

    path = lib.makeBinPath [ nix nix-prefetch-scripts luarocks-nix ];
in
buildPythonApplication {
  pname = "luarocks-packages-updater";
  version = "0.1";

  format = "other";

  nativeBuildInputs = [
    makeWrapper
    python3Packages.wrapPython
  ];
  propagatedBuildInputs = [
    python3Packages.gitpython
  ];

  dontUnpack = true;

  installPhase =
    ''
    mkdir -p $out/bin $out/lib
    cp ${./updater.py} $out/bin/luarocks-packages-updater
    cp ${../../../../maintainers/scripts/pluginupdate.py} $out/lib/pluginupdate.py

    # wrap python scripts
    makeWrapperArgs+=( --prefix PATH : "${path}" --prefix PYTHONPATH : "$out/lib" )
    wrapPythonProgramsIn "$out"
  '';

  shellHook = ''
    export PYTHONPATH="maintainers/scripts:$PYTHONPATH"
    export PATH="${path}:$PATH"
  '';

  meta.mainProgram = "luarocks-packages-updater";
}

Loading