treewide: format all inactive Nix files

After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.

Only "inactive" files are reformatted, meaning only files that
aren't being touched by any PR with activity in the past 2 months.
This is to avoid conflicts for PRs that might soon be merged.
Later we can do a full treewide reformat to get the rest,
which should not cause as many conflicts.

A CI check has already been running for some time to ensure that new and
already-formatted files are formatted, so the files being reformatted here
should also stay formatted.

This commit was automatically created and can be verified using

    nix-build https://github.com/infinisil/treewide-nixpkgs-reformat-script/archive/a08b3a4d199c6124ac5b36a889d9099b4383463f.tar.gz \
      --argstr baseRev b32a094368
    result/bin/apply-formatting $NIXPKGS_PATH
This commit is contained in:
Silvan Mosberger
2024-12-10 20:26:33 +01:00
parent b32a094368
commit 4f0dadbf38
21293 changed files with 701276 additions and 428232 deletions
@@ -1,22 +1,28 @@
{ lua
, hello
, wrapLua
, lib
, pkgs
{
lua,
hello,
wrapLua,
lib,
pkgs,
}:
let
runTest = lua: { name, command }:
pkgs.runCommandLocal "test-${lua.name}-${name}" ({
nativeBuildInputs = [lua];
meta.platforms = lua.meta.platforms;
}) (''
source ${./assert.sh}
''
+ command
+ "touch $out"
);
runTest =
lua:
{ name, command }:
pkgs.runCommandLocal "test-${lua.name}-${name}"
({
nativeBuildInputs = [ lua ];
meta.platforms = lua.meta.platforms;
})
(
''
source ${./assert.sh}
''
+ command
+ "touch $out"
);
wrappedHello = hello.overrideAttrs(oa: {
wrappedHello = hello.overrideAttrs (oa: {
propagatedBuildInputs = [
wrapLua
lua.pkgs.cjson
@@ -26,7 +32,7 @@ let
'';
});
luaWithModule = lua.withPackages(ps: [
luaWithModule = lua.withPackages (ps: [
ps.lua-cjson
]);
@@ -35,36 +41,46 @@ let
# Looking at lua interpreter 'setpath' code
# for instance https://github.com/lua/lua/blob/69ea087dff1daba25a2000dfb8f1883c17545b7a/loadlib.c#L599
# replace ";;" by ";LUA_PATH_DEFAULT;"
"5.1" = ";./?.lua;${lua}/share/lua/5.1/?.lua;${lua}/share/lua/5.1/?/init.lua;${lua}/lib/lua/5.1/?.lua;${lua}/lib/lua/5.1/?/init.lua;";
"5.2" = ";${lua}/share/lua/5.2/?.lua;${lua}/share/lua/5.2/?/init.lua;${lua}/lib/lua/5.2/?.lua;${lua}/lib/lua/5.2/?/init.lua;./?.lua;";
"5.3" = ";${lua}/share/lua/5.3/?.lua;${lua}/share/lua/5.3/?/init.lua;${lua}/lib/lua/5.3/?.lua;${lua}/lib/lua/5.3/?/init.lua;./?.lua;./?/init.lua;";
"5.1" =
";./?.lua;${lua}/share/lua/5.1/?.lua;${lua}/share/lua/5.1/?/init.lua;${lua}/lib/lua/5.1/?.lua;${lua}/lib/lua/5.1/?/init.lua;";
"5.2" =
";${lua}/share/lua/5.2/?.lua;${lua}/share/lua/5.2/?/init.lua;${lua}/lib/lua/5.2/?.lua;${lua}/lib/lua/5.2/?/init.lua;./?.lua;";
"5.3" =
";${lua}/share/lua/5.3/?.lua;${lua}/share/lua/5.3/?/init.lua;${lua}/lib/lua/5.3/?.lua;${lua}/lib/lua/5.3/?/init.lua;./?.lua;./?/init.lua;";
# lua5.4 seems to be smarter about it and dont add the lua separators when nothing left or right
"5.4" = "${lua}/share/lua/5.4/?.lua;${lua}/share/lua/5.4/?/init.lua;${lua}/lib/lua/5.4/?.lua;${lua}/lib/lua/5.4/?/init.lua;./?.lua;./?/init.lua";
"5.4" =
"${lua}/share/lua/5.4/?.lua;${lua}/share/lua/5.4/?/init.lua;${lua}/lib/lua/5.4/?.lua;${lua}/lib/lua/5.4/?/init.lua;./?.lua;./?/init.lua";
# luajit versions
"2.0" = ";./?.lua;${lua}/share/luajit-2.0/?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/?/init.lua;${lua}/share/lua/5.1/?.lua;${lua}/share/lua/5.1/?/init.lua;";
"2.1" = ";./?.lua;${lua}/share/luajit-2.1/?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/?/init.lua;${lua}/share/lua/5.1/?.lua;${lua}/share/lua/5.1/?/init.lua;";
"2.0" =
";./?.lua;${lua}/share/luajit-2.0/?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/?/init.lua;${lua}/share/lua/5.1/?.lua;${lua}/share/lua/5.1/?/init.lua;";
"2.1" =
";./?.lua;${lua}/share/luajit-2.1/?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/?/init.lua;${lua}/share/lua/5.1/?.lua;${lua}/share/lua/5.1/?/init.lua;";
};
in
pkgs.recurseIntoAttrs ({
pkgs.recurseIntoAttrs ({
checkInterpreterPatch = let
golden_LUA_PATH = golden_LUA_PATHS.${lib.versions.majorMinor lua.version};
in
checkInterpreterPatch =
let
golden_LUA_PATH = golden_LUA_PATHS.${lib.versions.majorMinor lua.version};
in
runTest lua {
name = "check-default-lua-path";
command = ''
export LUA_PATH=";;"
generated=$(lua -e 'print(package.path)')
assertStringEqual "$generated" "${golden_LUA_PATH}"
name = "check-default-lua-path";
command = ''
export LUA_PATH=";;"
generated=$(lua -e 'print(package.path)')
assertStringEqual "$generated" "${golden_LUA_PATH}"
'';
};
};
checkWrapping = pkgs.runCommandLocal "test-${lua.name}-wrapping" ({
}) (''
grep -- 'LUA_PATH=' ${wrappedHello}/bin/hello
touch $out
'');
checkWrapping =
pkgs.runCommandLocal "test-${lua.name}-wrapping"
({
})
(''
grep -- 'LUA_PATH=' ${wrappedHello}/bin/hello
touch $out
'');
# checks that lua's setup-hook adds dependencies to LUA_PATH
# Prevents the following regressions
@@ -72,41 +88,47 @@ in
# nix-shell$ luajit
# > require('http.request')
# stdin:1: module 'http.request' not found:
checkSetupHook = pkgs.runCommandLocal "test-${lua.name}-setup-hook" ({
nativeBuildInputs = [lua];
buildInputs = [ lua.pkgs.http ];
meta.platforms = lua.meta.platforms;
}) (''
${lua}/bin/lua -e "require'http.request'"
touch $out
'');
checkSetupHook =
pkgs.runCommandLocal "test-${lua.name}-setup-hook"
({
nativeBuildInputs = [ lua ];
buildInputs = [ lua.pkgs.http ];
meta.platforms = lua.meta.platforms;
})
(''
${lua}/bin/lua -e "require'http.request'"
touch $out
'');
checkRelativeImports = pkgs.runCommandLocal "test-${lua.name}-relative-imports" ({
}) (''
source ${./assert.sh}
checkRelativeImports =
pkgs.runCommandLocal "test-${lua.name}-relative-imports"
({
})
(''
source ${./assert.sh}
lua_vanilla_package_path="$(${lua}/bin/lua -e "print(package.path)")"
lua_with_module_package_path="$(${luaWithModule}/bin/lua -e "print(package.path)")"
lua_vanilla_package_path="$(${lua}/bin/lua -e "print(package.path)")"
lua_with_module_package_path="$(${luaWithModule}/bin/lua -e "print(package.path)")"
assertStringContains "$lua_vanilla_package_path" "./?.lua"
assertStringContains "$lua_vanilla_package_path" "./?/init.lua"
assertStringContains "$lua_vanilla_package_path" "./?.lua"
assertStringContains "$lua_vanilla_package_path" "./?/init.lua"
assertStringContains "$lua_with_module_package_path" "./?.lua"
assertStringContains "$lua_with_module_package_path" "./?/init.lua"
assertStringContains "$lua_with_module_package_path" "./?.lua"
assertStringContains "$lua_with_module_package_path" "./?/init.lua"
touch $out
'');
touch $out
'');
/*
Check that a lua package's propagatedBuildInputs end up in LUA_PATH
*/
checkPropagatedBuildInputs = pkgs.runCommandLocal "test-${lua.name}-setup-hook" ({
# lua-curl is a propagatedBuildInput of rest-nvim has
buildInputs = [ lua.pkgs.rest-nvim ];
}) (''
${lua}/bin/lua -e "require'cURL'"
touch $out
'');
# Check that a lua package's propagatedBuildInputs end up in LUA_PATH
checkPropagatedBuildInputs =
pkgs.runCommandLocal "test-${lua.name}-setup-hook"
({
# lua-curl is a propagatedBuildInput of rest-nvim has
buildInputs = [ lua.pkgs.rest-nvim ];
})
(''
${lua}/bin/lua -e "require'cURL'"
touch $out
'');
})