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: Marc Jakobi <mrcjkb89@outlook.com> --------- Co-authored-by: Marc Jakobi <mrcjkb89@outlook.com>
This commit is contained in:
parent
24df047637
commit
f15e58cbeb
|
@ -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
|
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 whitelist maintainers/scripts/luarocks-packages.csv and updated by running
|
||||||
the script
|
the package `luarocks-packages-updater`:
|
||||||
[maintainers/scripts/update-luarocks-packages](https://github.com/NixOS/nixpkgs/tree/master/maintainers/scripts/update-luarocks-packages):
|
|
||||||
|
|
||||||
```sh
|
```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).
|
[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).
|
||||||
|
|
|
@ -468,6 +468,7 @@ class Editor:
|
||||||
"--input-names",
|
"--input-names",
|
||||||
"-i",
|
"-i",
|
||||||
dest="input_file",
|
dest="input_file",
|
||||||
|
type=Path,
|
||||||
default=self.default_in,
|
default=self.default_in,
|
||||||
help="A list of plugins in the form owner/repo",
|
help="A list of plugins in the form owner/repo",
|
||||||
)
|
)
|
||||||
|
@ -476,6 +477,7 @@ class Editor:
|
||||||
"-o",
|
"-o",
|
||||||
dest="outfile",
|
dest="outfile",
|
||||||
default=self.default_out,
|
default=self.default_out,
|
||||||
|
type=Path,
|
||||||
help="Filename to save generated nix code",
|
help="Filename to save generated nix code",
|
||||||
)
|
)
|
||||||
common.add_argument(
|
common.add_argument(
|
||||||
|
@ -787,10 +789,17 @@ def update_plugins(editor: Editor, args):
|
||||||
|
|
||||||
if autocommit:
|
if autocommit:
|
||||||
from datetime import date
|
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:
|
if redirects:
|
||||||
update()
|
update()
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
{ nixpkgs ? import ../.. { }
|
|
||||||
}:
|
|
||||||
with nixpkgs;
|
|
||||||
let
|
|
||||||
pyEnv = python3.withPackages(ps: [ ps.gitpython ]);
|
|
||||||
in
|
|
||||||
mkShell {
|
|
||||||
packages = [
|
|
||||||
pyEnv
|
|
||||||
luarocks-nix
|
|
||||||
nix-prefetch-scripts
|
|
||||||
];
|
|
||||||
}
|
|
|
@ -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).
|
- `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 `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`.
|
- The `services.ananicy.extraRules` option now has the type of `listOf attrs` instead of `string`.
|
||||||
|
|
49
pkgs/development/lua-modules/updater/default.nix
Normal file
49
pkgs/development/lua-modules/updater/default.nix
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
{ 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";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
#!/usr/bin/env nix-shell
|
#!/usr/bin/env python
|
||||||
#!nix-shell update-luarocks-shell.nix -i python3
|
|
||||||
|
|
||||||
# format:
|
# format:
|
||||||
# $ nix run nixpkgs#python3Packages.black -- update.py
|
# $ nix run nixpkgs#python3Packages.black -- update.py
|
||||||
# type-check:
|
# type-check:
|
||||||
|
@ -32,12 +30,9 @@ from pluginupdate import update_plugins, FetchConfig, CleanEnvironment
|
||||||
PKG_LIST = "maintainers/scripts/luarocks-packages.csv"
|
PKG_LIST = "maintainers/scripts/luarocks-packages.csv"
|
||||||
TMP_FILE = "$(mktemp)"
|
TMP_FILE = "$(mktemp)"
|
||||||
GENERATED_NIXFILE = "pkgs/development/lua-modules/generated-packages.nix"
|
GENERATED_NIXFILE = "pkgs/development/lua-modules/generated-packages.nix"
|
||||||
LUAROCKS_CONFIG = "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:
|
Regenerate it with: nix run nixpkgs#update-luarocks-packages
|
||||||
nixpkgs$ ./maintainers/scripts/update-luarocks-packages
|
|
||||||
|
|
||||||
You can customize the generated packages in pkgs/development/lua-modules/overrides.nix
|
You can customize the generated packages in pkgs/development/lua-modules/overrides.nix
|
||||||
*/
|
*/
|
||||||
""".format(
|
""".format(
|
||||||
|
@ -76,6 +71,12 @@ class LuaPlugin:
|
||||||
|
|
||||||
# rename Editor to LangUpdate/ EcosystemUpdater
|
# rename Editor to LangUpdate/ EcosystemUpdater
|
||||||
class LuaEditor(pluginupdate.Editor):
|
class LuaEditor(pluginupdate.Editor):
|
||||||
|
|
||||||
|
def create_parser(self):
|
||||||
|
parser = super().create_parser()
|
||||||
|
parser.set_defaults(proc=1)
|
||||||
|
return parser
|
||||||
|
|
||||||
def get_current_plugins(self):
|
def get_current_plugins(self):
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
@ -101,9 +102,8 @@ class LuaEditor(pluginupdate.Editor):
|
||||||
with tempfile.NamedTemporaryFile("w+") as f:
|
with tempfile.NamedTemporaryFile("w+") as f:
|
||||||
f.write(HEADER)
|
f.write(HEADER)
|
||||||
header2 = textwrap.dedent(
|
header2 = textwrap.dedent(
|
||||||
# header2 = inspect.cleandoc(
|
|
||||||
"""
|
"""
|
||||||
{ self, stdenv, lib, fetchurl, fetchgit, callPackage, ... } @ args:
|
{ stdenv, lib, fetchurl, fetchgit, callPackage, ... } @ args:
|
||||||
final: prev:
|
final: prev:
|
||||||
{
|
{
|
||||||
"""
|
"""
|
||||||
|
@ -165,12 +165,7 @@ def generate_pkg_nix(plug: LuaPlugin):
|
||||||
Our cache key associates "p.name-p.version" to its rockspec
|
Our cache key associates "p.name-p.version" to its rockspec
|
||||||
"""
|
"""
|
||||||
log.debug("Generating nix expression for %s", plug.name)
|
log.debug("Generating nix expression for %s", plug.name)
|
||||||
custom_env = os.environ.copy()
|
|
||||||
custom_env["LUAROCKS_CONFIG"] = LUAROCKS_CONFIG
|
|
||||||
|
|
||||||
# we add --dev else luarocks wont find all the "scm" (=dev) versions of the
|
|
||||||
# packages
|
|
||||||
# , "--dev"
|
|
||||||
cmd = ["luarocks", "nix"]
|
cmd = ["luarocks", "nix"]
|
||||||
|
|
||||||
if plug.maintainers:
|
if plug.maintainers:
|
||||||
|
@ -201,7 +196,7 @@ def generate_pkg_nix(plug: LuaPlugin):
|
||||||
|
|
||||||
log.debug("running %s", " ".join(cmd))
|
log.debug("running %s", " ".join(cmd))
|
||||||
|
|
||||||
output = subprocess.check_output(cmd, env=custom_env, text=True)
|
output = subprocess.check_output(cmd, text=True)
|
||||||
output = "callPackage(" + output.strip() + ") {};\n\n"
|
output = "callPackage(" + output.strip() + ") {};\n\n"
|
||||||
return (plug, output)
|
return (plug, output)
|
||||||
|
|
||||||
|
@ -211,8 +206,8 @@ def main():
|
||||||
"lua",
|
"lua",
|
||||||
ROOT,
|
ROOT,
|
||||||
"",
|
"",
|
||||||
default_in=ROOT.joinpath(PKG_LIST),
|
default_in=PKG_LIST,
|
||||||
default_out=ROOT.joinpath(GENERATED_NIXFILE),
|
default_out=GENERATED_NIXFILE,
|
||||||
)
|
)
|
||||||
|
|
||||||
editor.run()
|
editor.run()
|
||||||
|
@ -220,5 +215,3 @@ def main():
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
||||||
# vim: set ft=python noet fdm=manual fenc=utf-8 ff=unix sts=0 sw=4 ts=4 :
|
|
|
@ -17766,6 +17766,11 @@ with pkgs;
|
||||||
luarocks = luaPackages.luarocks;
|
luarocks = luaPackages.luarocks;
|
||||||
luarocks-nix = luaPackages.luarocks-nix;
|
luarocks-nix = luaPackages.luarocks-nix;
|
||||||
|
|
||||||
|
luarocks-packages-updater = callPackage ../development/lua-modules/updater {
|
||||||
|
inherit (python3Packages) buildPythonApplication ;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
luau = callPackage ../development/interpreters/luau { };
|
luau = callPackage ../development/interpreters/luau { };
|
||||||
|
|
||||||
lune = callPackage ../development/interpreters/lune { };
|
lune = callPackage ../development/interpreters/lune { };
|
||||||
|
|
Loading…
Reference in New Issue
Block a user