treewide: Format all Nix files

Format all Nix files using the officially approved formatter,
making the CI check introduced in the previous commit succeed:

  nix-build ci -A fmt.check

This is the next step of the of the [implementation](https://github.com/NixOS/nixfmt/issues/153)
of the accepted [RFC 166](https://github.com/NixOS/rfcs/pull/166).

This commit will lead to merge conflicts for a number of PRs,
up to an estimated ~1100 (~33%) among the PRs with activity in the past 2
months, but that should be lower than what it would be without the previous
[partial treewide format](https://github.com/NixOS/nixpkgs/pull/322537).

Merge conflicts caused by this commit can now automatically be resolved while rebasing using the
[auto-rebase script](https://github.com/NixOS/nixpkgs/tree/8616af08d915377bd930395f3b700a0e93d08728/maintainers/scripts/auto-rebase).

If you run into any problems regarding any of this, please reach out to the
[formatting team](https://nixos.org/community/teams/formatting/) by
pinging @NixOS/nix-formatting.
This commit is contained in:
Silvan Mosberger
2025-04-01 20:10:43 +02:00
parent 2140bf39e4
commit 374e6bcc40
1523 changed files with 986039 additions and 513613 deletions
@@ -1,83 +1,96 @@
{ lib, stdenv, fetchFromGitHub, fetchpatch
, bzip2
, expat
, libffi
, gdbm
, db
, ncurses
, openssl
, readline
, sqlite
, tcl ? null, tk ? null, tclPackages, libX11 ? null, x11Support ? false
, zlib
, self
, coreutils
, autoreconfHook
, python-setup-hook
# Some proprietary libs assume UCS2 unicode, especially on darwin :(
, ucsEncoding ? 4
# For the Python package set
, packageOverrides ? (self: super: {})
, pkgsBuildBuild
, pkgsBuildHost
, pkgsBuildTarget
, pkgsHostHost
, pkgsTargetTarget
, sourceVersion
, hash
, passthruFun
, static ? stdenv.hostPlatform.isStatic
, stripBytecode ? reproducibleBuild
, rebuildBytecode ? true
, reproducibleBuild ? false
, enableOptimizations ? false
, strip2to3 ? false
, stripConfig ? false
, stripIdlelib ? false
, stripTests ? false
, pythonAttr ? "python${sourceVersion.major}${sourceVersion.minor}"
{
lib,
stdenv,
fetchFromGitHub,
fetchpatch,
bzip2,
expat,
libffi,
gdbm,
db,
ncurses,
openssl,
readline,
sqlite,
tcl ? null,
tk ? null,
tclPackages,
libX11 ? null,
x11Support ? false,
zlib,
self,
coreutils,
autoreconfHook,
python-setup-hook,
# Some proprietary libs assume UCS2 unicode, especially on darwin :(
ucsEncoding ? 4,
# For the Python package set
packageOverrides ? (self: super: { }),
pkgsBuildBuild,
pkgsBuildHost,
pkgsBuildTarget,
pkgsHostHost,
pkgsTargetTarget,
sourceVersion,
hash,
passthruFun,
static ? stdenv.hostPlatform.isStatic,
stripBytecode ? reproducibleBuild,
rebuildBytecode ? true,
reproducibleBuild ? false,
enableOptimizations ? false,
strip2to3 ? false,
stripConfig ? false,
stripIdlelib ? false,
stripTests ? false,
pythonAttr ? "python${sourceVersion.major}${sourceVersion.minor}",
}:
assert x11Support -> tcl != null
&& tk != null
&& libX11 != null;
assert x11Support -> tcl != null && tk != null && libX11 != null;
assert lib.assertMsg (enableOptimizations -> (!stdenv.cc.isClang))
"Optimizations with clang are not supported. configure: error: llvm-profdata is required for a --enable-optimizations build but could not be found.";
assert lib.assertMsg (reproducibleBuild -> stripBytecode)
"Deterministic builds require stripping bytecode.";
assert lib.assertMsg (
reproducibleBuild -> stripBytecode
) "Deterministic builds require stripping bytecode.";
assert lib.assertMsg (reproducibleBuild -> (!enableOptimizations))
"Deterministic builds are not achieved when optimizations are enabled.";
assert lib.assertMsg (
reproducibleBuild -> (!enableOptimizations)
) "Deterministic builds are not achieved when optimizations are enabled.";
assert lib.assertMsg (reproducibleBuild -> (!rebuildBytecode))
"Deterministic builds are not achieved when (default unoptimized) bytecode is created.";
assert lib.assertMsg (
reproducibleBuild -> (!rebuildBytecode)
) "Deterministic builds are not achieved when (default unoptimized) bytecode is created.";
let
buildPackages = pkgsBuildHost;
inherit (passthru) pythonOnBuildForHost;
pythonOnBuildForHostInterpreter = if stdenv.hostPlatform == stdenv.buildPlatform then
"$out/bin/python"
else pythonOnBuildForHost.interpreter;
pythonOnBuildForHostInterpreter =
if stdenv.hostPlatform == stdenv.buildPlatform then
"$out/bin/python"
else
pythonOnBuildForHost.interpreter;
passthru = passthruFun rec {
inherit self sourceVersion packageOverrides;
implementation = "cpython";
libPrefix = "python${pythonVersion}";
executable = libPrefix;
pythonVersion = with sourceVersion; "${major}.${minor}";
sitePackages = "lib/${libPrefix}/site-packages";
inherit hasDistutilsCxxPatch pythonAttr;
pythonOnBuildForBuild = pkgsBuildBuild.${pythonAttr};
pythonOnBuildForHost = pkgsBuildHost.${pythonAttr};
pythonOnBuildForTarget = pkgsBuildTarget.${pythonAttr};
pythonOnHostForHost = pkgsHostHost.${pythonAttr};
pythonOnTargetForTarget = pkgsTargetTarget.${pythonAttr} or {};
} // {
inherit ucsEncoding;
};
passthru =
passthruFun rec {
inherit self sourceVersion packageOverrides;
implementation = "cpython";
libPrefix = "python${pythonVersion}";
executable = libPrefix;
pythonVersion = with sourceVersion; "${major}.${minor}";
sitePackages = "lib/${libPrefix}/site-packages";
inherit hasDistutilsCxxPatch pythonAttr;
pythonOnBuildForBuild = pkgsBuildBuild.${pythonAttr};
pythonOnBuildForHost = pkgsBuildHost.${pythonAttr};
pythonOnBuildForTarget = pkgsBuildTarget.${pythonAttr};
pythonOnHostForHost = pkgsHostHost.${pythonAttr};
pythonOnTargetForTarget = pkgsTargetTarget.${pythonAttr} or { };
}
// {
inherit ucsEncoding;
};
version = with sourceVersion; "${major}.${minor}.${patch}${suffix}";
@@ -92,7 +105,8 @@ let
hasDistutilsCxxPatch = !(stdenv.cc.isGNU or false);
patches =
[ # Look in C_INCLUDE_PATH and LIBRARY_PATH for stuff.
[
# Look in C_INCLUDE_PATH and LIBRARY_PATH for stuff.
./search-path.patch
# Python recompiles a Python if the mtime stored *in* the
@@ -137,10 +151,12 @@ let
revert = true;
hash = "sha256-Lp5fGlcfJJ6p6vKmcLckJiAA2AZz4prjFE0aMEJxotw=";
})
] ++ lib.optionals (x11Support && stdenv.hostPlatform.isDarwin) [
]
++ lib.optionals (x11Support && stdenv.hostPlatform.isDarwin) [
./use-correct-tcl-tk-on-darwin.patch
] ++ lib.optionals stdenv.hostPlatform.isLinux [
]
++ lib.optionals stdenv.hostPlatform.isLinux [
# Disable the use of ldconfig in ctypes.util.find_library (since
# ldconfig doesn't work on NixOS), and don't use
@@ -152,7 +168,8 @@ let
# Fix ctypes.util.find_library with gcc10.
./find_library-gcc10.patch
] ++ lib.optionals stdenv.hostPlatform.isCygwin [
]
++ lib.optionals stdenv.hostPlatform.isCygwin [
./2.5.2-ctypes-util-find_library.patch
./2.5.2-tkinter-x11.patch
./2.6.2-ssl-threads.patch
@@ -163,7 +180,8 @@ let
./2.7.3-dylib.patch
./2.7.3-getpath-exe-extension.patch
./2.7.3-no-libm.patch
] ++ lib.optionals hasDistutilsCxxPatch [
]
++ lib.optionals hasDistutilsCxxPatch [
# Patch from http://bugs.python.org/issue1222585 adapted to work with
# `patch -p1' and with a last hunk removed
@@ -171,75 +189,102 @@ let
# only works for GCC and Apple Clang. This makes distutils to call C++
# compiler when needed.
./python-2.7-distutils-C++.patch
] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
]
++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
./cross-compile.patch
];
preConfigure = ''
preConfigure =
''
# Purity.
for i in /usr /sw /opt /pkg; do
substituteInPlace ./setup.py --replace $i /no-such-path
done
'' + lib.optionalString (stdenv ? cc && stdenv.cc.libc != null) ''
''
+ lib.optionalString (stdenv ? cc && stdenv.cc.libc != null) ''
for i in Lib/plat-*/regen; do
substituteInPlace $i --replace /usr/include/ ${stdenv.cc.libc}/include/
done
'' + lib.optionalString stdenv.hostPlatform.isDarwin ''
''
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
substituteInPlace configure --replace '`/usr/bin/arch`' '"i386"'
substituteInPlace Lib/multiprocessing/__init__.py \
--replace 'os.popen(comm)' 'os.popen("${coreutils}/bin/nproc")'
'';
configureFlags = lib.optionals enableOptimizations [
"--enable-optimizations"
] ++ lib.optionals (!static) [
"--enable-shared"
] ++ [
"--with-threads"
"--with-system-ffi"
"--with-system-expat"
"--enable-unicode=ucs${toString ucsEncoding}"
] ++ lib.optionals stdenv.hostPlatform.isCygwin [
"ac_cv_func_bind_textdomain_codeset=yes"
] ++ lib.optionals stdenv.hostPlatform.isDarwin [
"--disable-toolbox-glue"
] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
"PYTHON_FOR_BUILD=${lib.getBin buildPackages.python27}/bin/python"
"ac_cv_buggy_getaddrinfo=no"
# Assume little-endian IEEE 754 floating point when cross compiling
"ac_cv_little_endian_double=yes"
"ac_cv_big_endian_double=no"
"ac_cv_mixed_endian_double=no"
"ac_cv_x87_double_rounding=yes"
"ac_cv_tanh_preserves_zero_sign=yes"
# Generally assume that things are present and work
"ac_cv_posix_semaphores_enabled=yes"
"ac_cv_broken_sem_getvalue=no"
"ac_cv_wchar_t_signed=yes"
"ac_cv_rshift_extends_sign=yes"
"ac_cv_broken_nice=no"
"ac_cv_broken_poll=no"
"ac_cv_working_tzset=yes"
"ac_cv_have_long_long_format=yes"
"ac_cv_have_size_t_format=yes"
"ac_cv_computed_gotos=yes"
"ac_cv_file__dev_ptmx=yes"
"ac_cv_file__dev_ptc=yes"
]
configureFlags =
lib.optionals enableOptimizations [
"--enable-optimizations"
]
++ lib.optionals (!static) [
"--enable-shared"
]
++ [
"--with-threads"
"--with-system-ffi"
"--with-system-expat"
"--enable-unicode=ucs${toString ucsEncoding}"
]
++ lib.optionals stdenv.hostPlatform.isCygwin [
"ac_cv_func_bind_textdomain_codeset=yes"
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
"--disable-toolbox-glue"
]
++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
"PYTHON_FOR_BUILD=${lib.getBin buildPackages.python27}/bin/python"
"ac_cv_buggy_getaddrinfo=no"
# Assume little-endian IEEE 754 floating point when cross compiling
"ac_cv_little_endian_double=yes"
"ac_cv_big_endian_double=no"
"ac_cv_mixed_endian_double=no"
"ac_cv_x87_double_rounding=yes"
"ac_cv_tanh_preserves_zero_sign=yes"
# Generally assume that things are present and work
"ac_cv_posix_semaphores_enabled=yes"
"ac_cv_broken_sem_getvalue=no"
"ac_cv_wchar_t_signed=yes"
"ac_cv_rshift_extends_sign=yes"
"ac_cv_broken_nice=no"
"ac_cv_broken_poll=no"
"ac_cv_working_tzset=yes"
"ac_cv_have_long_long_format=yes"
"ac_cv_have_size_t_format=yes"
"ac_cv_computed_gotos=yes"
"ac_cv_file__dev_ptmx=yes"
"ac_cv_file__dev_ptc=yes"
]
# Never even try to use lchmod on linux,
# don't rely on detecting glibc-isms.
++ lib.optional stdenv.hostPlatform.isLinux "ac_cv_func_lchmod=no"
++ lib.optional static "LDFLAGS=-static";
++ lib.optional stdenv.hostPlatform.isLinux "ac_cv_func_lchmod=no"
++ lib.optional static "LDFLAGS=-static";
strictDeps = true;
buildInputs =
lib.optional (stdenv ? cc && stdenv.cc.libc != null) stdenv.cc.libc ++
[ bzip2 openssl zlib libffi expat db gdbm ncurses sqlite readline ]
++ lib.optionals x11Support [ tcl tk libX11 ];
lib.optional (stdenv ? cc && stdenv.cc.libc != null) stdenv.cc.libc
++ [
bzip2
openssl
zlib
libffi
expat
db
gdbm
ncurses
sqlite
readline
]
++ lib.optionals x11Support [
tcl
tk
libX11
];
nativeBuildInputs =
[ autoreconfHook ]
++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform)
[ buildPackages.stdenv.cc buildPackages.python27 ];
++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
buildPackages.stdenv.cc
buildPackages.python27
];
mkPaths = paths: {
C_INCLUDE_PATH = lib.makeSearchPathOutput "dev" "include" paths;
@@ -247,29 +292,41 @@ let
};
# Python 2.7 needs this
crossCompileEnv = lib.optionalAttrs (stdenv.hostPlatform != stdenv.buildPlatform)
{ _PYTHON_HOST_PLATFORM = stdenv.hostPlatform.config; };
crossCompileEnv = lib.optionalAttrs (stdenv.hostPlatform != stdenv.buildPlatform) {
_PYTHON_HOST_PLATFORM = stdenv.hostPlatform.config;
};
# Build the basic Python interpreter without modules that have
# external dependencies.
in with passthru; stdenv.mkDerivation ({
in
with passthru;
stdenv.mkDerivation (
{
pname = "python";
inherit version;
inherit src patches buildInputs nativeBuildInputs preConfigure configureFlags;
inherit
src
patches
buildInputs
nativeBuildInputs
preConfigure
configureFlags
;
LDFLAGS = lib.optionalString (!stdenv.hostPlatform.isDarwin) "-lgcc_s";
inherit (mkPaths buildInputs) C_INCLUDE_PATH LIBRARY_PATH;
env.NIX_CFLAGS_COMPILE = lib.optionalString (stdenv.targetPlatform.system == "x86_64-darwin") "-msse2"
env.NIX_CFLAGS_COMPILE =
lib.optionalString (stdenv.targetPlatform.system == "x86_64-darwin") "-msse2"
+ lib.optionalString stdenv.hostPlatform.isMusl " -DTHREAD_STACK_SIZE=0x100000";
DETERMINISTIC_BUILD = 1;
setupHook = python-setup-hook sitePackages;
postPatch = lib.optionalString (x11Support && ((tclPackages.tix or null) != null)) ''
substituteInPlace "Lib/lib-tk/Tix.py" --replace "os.environ.get('TIX_LIBRARY')" "os.environ.get('TIX_LIBRARY') or '${tclPackages.tix}/lib'"
substituteInPlace "Lib/lib-tk/Tix.py" --replace "os.environ.get('TIX_LIBRARY')" "os.environ.get('TIX_LIBRARY') or '${tclPackages.tix}/lib'"
'';
postInstall =
@@ -295,37 +352,45 @@ in with passthru; stdenv.mkDerivation ({
# Determinism: Windows installers were not deterministic.
# We're also not interested in building Windows installers.
find "$out" -name 'wininst*.exe' | xargs -r rm -f
'' + lib.optionalString stripBytecode ''
''
+ lib.optionalString stripBytecode ''
# Determinism: deterministic bytecode
# First we delete all old bytecode.
find $out -name "*.pyc" -delete
'' + lib.optionalString rebuildBytecode ''
''
+ lib.optionalString rebuildBytecode ''
# We build 3 levels of optimized bytecode. Note the default level, without optimizations,
# is not reproducible yet. https://bugs.python.org/issue29708
# Not creating bytecode will result in a large performance loss however, so we do build it.
find $out -name "*.py" | ${pythonOnBuildForHostInterpreter} -m compileall -q -f -x "lib2to3" -i -
find $out -name "*.py" | ${pythonOnBuildForHostInterpreter} -O -m compileall -q -f -x "lib2to3" -i -
find $out -name "*.py" | ${pythonOnBuildForHostInterpreter} -OO -m compileall -q -f -x "lib2to3" -i -
'' + lib.optionalString stdenv.hostPlatform.isCygwin ''
''
+ lib.optionalString stdenv.hostPlatform.isCygwin ''
cp libpython2.7.dll.a $out/lib
'';
inherit passthru;
postFixup = ''
# Include a sitecustomize.py file. Note it causes an error when it's in postInstall with 2.7.
cp ${../../sitecustomize.py} $out/${sitePackages}/sitecustomize.py
'' + lib.optionalString strip2to3 ''
rm -R $out/bin/2to3 $out/lib/python*/lib2to3
'' + lib.optionalString stripConfig ''
rm -R $out/bin/python*-config $out/lib/python*/config*
'' + lib.optionalString stripIdlelib ''
# Strip IDLE
rm -R $out/bin/idle* $out/lib/python*/idlelib
'' + lib.optionalString stripTests ''
# Strip tests
rm -R $out/lib/python*/test $out/lib/python*/**/test{,s}
'';
postFixup =
''
# Include a sitecustomize.py file. Note it causes an error when it's in postInstall with 2.7.
cp ${../../sitecustomize.py} $out/${sitePackages}/sitecustomize.py
''
+ lib.optionalString strip2to3 ''
rm -R $out/bin/2to3 $out/lib/python*/lib2to3
''
+ lib.optionalString stripConfig ''
rm -R $out/bin/python*-config $out/lib/python*/config*
''
+ lib.optionalString stripIdlelib ''
# Strip IDLE
rm -R $out/bin/idle* $out/lib/python*/idlelib
''
+ lib.optionalString stripTests ''
# Strip tests
rm -R $out/lib/python*/test $out/lib/python*/**/test{,s}
'';
enableParallelBuilding = true;
@@ -355,4 +420,6 @@ in with passthru; stdenv.mkDerivation ({
# sunset till 2020.
];
};
} // crossCompileEnv)
}
// crossCompileEnv
)
File diff suppressed because it is too large Load Diff
@@ -1,6 +1,10 @@
# This file was generated and will be overwritten by ./generate.sh
{ stdenv, lib, fetchurl }:
{
stdenv,
lib,
fetchurl,
}:
stdenv.mkDerivation {
pname = "python27-docs-html";
@@ -1,6 +1,10 @@
# This file was generated and will be overwritten by ./generate.sh
{ stdenv, lib, fetchurl }:
{
stdenv,
lib,
fetchurl,
}:
stdenv.mkDerivation {
pname = "python27-docs-pdf-a4";
@@ -1,6 +1,10 @@
# This file was generated and will be overwritten by ./generate.sh
{ stdenv, lib, fetchurl }:
{
stdenv,
lib,
fetchurl,
}:
stdenv.mkDerivation {
pname = "python27-docs-pdf-letter";
@@ -1,6 +1,10 @@
# This file was generated and will be overwritten by ./generate.sh
{ stdenv, lib, fetchurl }:
{
stdenv,
lib,
fetchurl,
}:
stdenv.mkDerivation {
pname = "python27-docs-text";
@@ -1,6 +1,10 @@
# This file was generated and will be overwritten by ./generate.sh
{ stdenv, lib, fetchurl }:
{
stdenv,
lib,
fetchurl,
}:
stdenv.mkDerivation {
pname = "python310-docs-html";
@@ -1,6 +1,10 @@
# This file was generated and will be overwritten by ./generate.sh
{ stdenv, lib, fetchurl }:
{
stdenv,
lib,
fetchurl,
}:
stdenv.mkDerivation {
pname = "python310-docs-pdf-a4";
@@ -1,6 +1,10 @@
# This file was generated and will be overwritten by ./generate.sh
{ stdenv, lib, fetchurl }:
{
stdenv,
lib,
fetchurl,
}:
stdenv.mkDerivation {
pname = "python310-docs-pdf-letter";
@@ -1,6 +1,10 @@
# This file was generated and will be overwritten by ./generate.sh
{ stdenv, lib, fetchurl }:
{
stdenv,
lib,
fetchurl,
}:
stdenv.mkDerivation {
pname = "python310-docs-text";
@@ -1,47 +1,53 @@
{ stdenv, fetchurl, lib }:
{
stdenv,
fetchurl,
lib,
}:
let
pythonDocs = {
html = {
recurseForDerivations = true;
python27 = import ./2.7-html.nix {
inherit stdenv fetchurl lib;
pythonDocs = {
html = {
recurseForDerivations = true;
python27 = import ./2.7-html.nix {
inherit stdenv fetchurl lib;
};
python310 = import ./3.10-html.nix {
inherit stdenv fetchurl lib;
};
};
python310 = import ./3.10-html.nix {
inherit stdenv fetchurl lib;
pdf_a4 = {
recurseForDerivations = true;
python27 = import ./2.7-pdf-a4.nix {
inherit stdenv fetchurl lib;
};
python310 = import ./3.10-pdf-a4.nix {
inherit stdenv fetchurl lib;
};
};
pdf_letter = {
recurseForDerivations = true;
python27 = import ./2.7-pdf-letter.nix {
inherit stdenv fetchurl lib;
};
python310 = import ./3.10-pdf-letter.nix {
inherit stdenv fetchurl lib;
};
};
text = {
recurseForDerivations = true;
python27 = import ./2.7-text.nix {
inherit stdenv fetchurl lib;
};
python310 = import ./3.10-text.nix {
inherit stdenv fetchurl lib;
};
};
texinfo = {
recurseForDerivations = true;
python310 = import ./3.10-texinfo.nix {
inherit stdenv fetchurl lib;
};
};
};
pdf_a4 = {
recurseForDerivations = true;
python27 = import ./2.7-pdf-a4.nix {
inherit stdenv fetchurl lib;
};
python310 = import ./3.10-pdf-a4.nix {
inherit stdenv fetchurl lib;
};
};
pdf_letter = {
recurseForDerivations = true;
python27 = import ./2.7-pdf-letter.nix {
inherit stdenv fetchurl lib;
};
python310 = import ./3.10-pdf-letter.nix {
inherit stdenv fetchurl lib;
};
};
text = {
recurseForDerivations = true;
python27 = import ./2.7-text.nix {
inherit stdenv fetchurl lib;
};
python310 = import ./3.10-text.nix {
inherit stdenv fetchurl lib;
};
};
texinfo = {
recurseForDerivations = true;
python310 = import ./3.10-texinfo.nix {
inherit stdenv fetchurl lib;
};
};
}; in pythonDocs
in
pythonDocs