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](8616af08d9/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 986047 additions and 513621 deletions

View File

@@ -1,160 +1,188 @@
{ lib
, stdenv
, buildPackages
, fetchurl
, updateAutotoolsGnuConfigScriptsHook
, bison
, util-linux
{
lib,
stdenv,
buildPackages,
fetchurl,
updateAutotoolsGnuConfigScriptsHook,
bison,
util-linux,
, interactive ? true
, readline
, withDocs ? null
, forFHSEnv ? false
interactive ? true,
readline,
withDocs ? null,
forFHSEnv ? false,
, pkgsStatic
pkgsStatic,
}:
let
upstreamPatches = import ./bash-5.2-patches.nix (nr: sha256: fetchurl {
url = "mirror://gnu/bash/bash-5.2-patches/bash52-${nr}";
inherit sha256;
});
upstreamPatches = import ./bash-5.2-patches.nix (
nr: sha256:
fetchurl {
url = "mirror://gnu/bash/bash-5.2-patches/bash52-${nr}";
inherit sha256;
}
);
in
lib.warnIf (withDocs != null) ''
bash: `.override { withDocs = true; }` is deprecated, the docs are always included.
''
stdenv.mkDerivation rec {
pname = "bash${lib.optionalString interactive "-interactive"}";
version = "5.2${patch_suffix}";
patch_suffix = "p${toString (builtins.length upstreamPatches)}";
lib.warnIf (withDocs != null)
''
bash: `.override { withDocs = true; }` is deprecated, the docs are always included.
''
stdenv.mkDerivation
rec {
pname = "bash${lib.optionalString interactive "-interactive"}";
version = "5.2${patch_suffix}";
patch_suffix = "p${toString (builtins.length upstreamPatches)}";
src = fetchurl {
url = "mirror://gnu/bash/bash-${lib.removeSuffix patch_suffix version}.tar.gz";
sha256 = "sha256-oTnBZt9/9EccXgczBRZC7lVWwcyKSnjxRVg8XIGrMvs=";
};
src = fetchurl {
url = "mirror://gnu/bash/bash-${lib.removeSuffix patch_suffix version}.tar.gz";
sha256 = "sha256-oTnBZt9/9EccXgczBRZC7lVWwcyKSnjxRVg8XIGrMvs=";
};
hardeningDisable = [ "format" ]
# bionic libc is super weird and has issues with fortify outside of its own libc, check this comment:
# https://github.com/NixOS/nixpkgs/pull/192630#discussion_r978985593
# or you can check libc/include/sys/cdefs.h in bionic source code
++ lib.optional (stdenv.hostPlatform.libc == "bionic") "fortify";
hardeningDisable =
[ "format" ]
# bionic libc is super weird and has issues with fortify outside of its own libc, check this comment:
# https://github.com/NixOS/nixpkgs/pull/192630#discussion_r978985593
# or you can check libc/include/sys/cdefs.h in bionic source code
++ lib.optional (stdenv.hostPlatform.libc == "bionic") "fortify";
outputs = [ "out" "dev" "man" "doc" "info" ];
outputs = [
"out"
"dev"
"man"
"doc"
"info"
];
separateDebugInfo = true;
separateDebugInfo = true;
env.NIX_CFLAGS_COMPILE = ''
-DSYS_BASHRC="/etc/bashrc"
-DSYS_BASH_LOGOUT="/etc/bash_logout"
'' + lib.optionalString (!forFHSEnv) ''
-DDEFAULT_PATH_VALUE="/no-such-path"
-DSTANDARD_UTILS_PATH="/no-such-path"
-DDEFAULT_LOADABLE_BUILTINS_PATH="${placeholder "out"}/lib/bash:."
'' + ''
-DNON_INTERACTIVE_LOGIN_SHELLS
-DSSH_SOURCE_BASHRC
'';
env.NIX_CFLAGS_COMPILE =
''
-DSYS_BASHRC="/etc/bashrc"
-DSYS_BASH_LOGOUT="/etc/bash_logout"
''
+ lib.optionalString (!forFHSEnv) ''
-DDEFAULT_PATH_VALUE="/no-such-path"
-DSTANDARD_UTILS_PATH="/no-such-path"
-DDEFAULT_LOADABLE_BUILTINS_PATH="${placeholder "out"}/lib/bash:."
''
+ ''
-DNON_INTERACTIVE_LOGIN_SHELLS
-DSSH_SOURCE_BASHRC
'';
patchFlags = [ "-p0" ];
patchFlags = [ "-p0" ];
patches = upstreamPatches ++ [
./pgrp-pipe-5.patch
# Apply parallel build fix pending upstream inclusion:
# https://savannah.gnu.org/patch/index.php?10373
# Had to fetch manually to workaround -p0 default.
./parallel.patch
# Fix `pop_var_context: head of shell_variables not a function context`.
./fix-pop-var-context-error.patch
];
patches = upstreamPatches ++ [
./pgrp-pipe-5.patch
# Apply parallel build fix pending upstream inclusion:
# https://savannah.gnu.org/patch/index.php?10373
# Had to fetch manually to workaround -p0 default.
./parallel.patch
# Fix `pop_var_context: head of shell_variables not a function context`.
./fix-pop-var-context-error.patch
];
configureFlags = [
# At least on Linux bash memory allocator has pathological performance
# in scenarios involving use of larger memory:
# https://lists.gnu.org/archive/html/bug-bash/2023-08/msg00052.html
# Various distributions default to system allocator. Let's nixpkgs
# do the same.
"--without-bash-malloc"
(if interactive then "--with-installed-readline" else "--disable-readline")
] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
"bash_cv_job_control_missing=nomissing"
"bash_cv_sys_named_pipes=nomissing"
"bash_cv_getcwd_malloc=yes"
# This check cannot be performed when cross compiling. The "yes"
# default is fine for static linking on Linux (weak symbols?) but
# not with BSDs, when it does clash with the regular `getenv`.
"bash_cv_getenv_redef=${if !(with stdenv.hostPlatform; isStatic && (isOpenBSD || isFreeBSD)) then "yes" else "no"}"
] ++ lib.optionals stdenv.hostPlatform.isCygwin [
"--without-libintl-prefix"
"--without-libiconv-prefix"
"--with-installed-readline"
"bash_cv_dev_stdin=present"
"bash_cv_dev_fd=standard"
"bash_cv_termcap_lib=libncurses"
] ++ lib.optionals (stdenv.hostPlatform.libc == "musl") [
"--disable-nls"
] ++ lib.optionals stdenv.hostPlatform.isFreeBSD [
# /dev/fd is optional on FreeBSD. we need it to work when built on a system
# with it and transferred to a system without it! This includes linux cross.
"bash_cv_dev_fd=absent"
];
configureFlags =
[
# At least on Linux bash memory allocator has pathological performance
# in scenarios involving use of larger memory:
# https://lists.gnu.org/archive/html/bug-bash/2023-08/msg00052.html
# Various distributions default to system allocator. Let's nixpkgs
# do the same.
"--without-bash-malloc"
(if interactive then "--with-installed-readline" else "--disable-readline")
]
++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
"bash_cv_job_control_missing=nomissing"
"bash_cv_sys_named_pipes=nomissing"
"bash_cv_getcwd_malloc=yes"
# This check cannot be performed when cross compiling. The "yes"
# default is fine for static linking on Linux (weak symbols?) but
# not with BSDs, when it does clash with the regular `getenv`.
"bash_cv_getenv_redef=${
if !(with stdenv.hostPlatform; isStatic && (isOpenBSD || isFreeBSD)) then "yes" else "no"
}"
]
++ lib.optionals stdenv.hostPlatform.isCygwin [
"--without-libintl-prefix"
"--without-libiconv-prefix"
"--with-installed-readline"
"bash_cv_dev_stdin=present"
"bash_cv_dev_fd=standard"
"bash_cv_termcap_lib=libncurses"
]
++ lib.optionals (stdenv.hostPlatform.libc == "musl") [
"--disable-nls"
]
++ lib.optionals stdenv.hostPlatform.isFreeBSD [
# /dev/fd is optional on FreeBSD. we need it to work when built on a system
# with it and transferred to a system without it! This includes linux cross.
"bash_cv_dev_fd=absent"
];
strictDeps = true;
# Note: Bison is needed because the patches above modify parse.y.
depsBuildBuild = [ buildPackages.stdenv.cc ];
nativeBuildInputs = [ updateAutotoolsGnuConfigScriptsHook bison ]
++ lib.optional stdenv.hostPlatform.isDarwin stdenv.cc.bintools;
strictDeps = true;
# Note: Bison is needed because the patches above modify parse.y.
depsBuildBuild = [ buildPackages.stdenv.cc ];
nativeBuildInputs = [
updateAutotoolsGnuConfigScriptsHook
bison
] ++ lib.optional stdenv.hostPlatform.isDarwin stdenv.cc.bintools;
buildInputs = lib.optional interactive readline;
buildInputs = lib.optional interactive readline;
enableParallelBuilding = true;
enableParallelBuilding = true;
makeFlags = lib.optionals stdenv.hostPlatform.isCygwin [
"LOCAL_LDFLAGS=-Wl,--export-all,--out-implib,libbash.dll.a"
"SHOBJ_LIBS=-lbash"
];
makeFlags = lib.optionals stdenv.hostPlatform.isCygwin [
"LOCAL_LDFLAGS=-Wl,--export-all,--out-implib,libbash.dll.a"
"SHOBJ_LIBS=-lbash"
];
nativeCheckInputs = [ util-linux ];
doCheck = false; # dependency cycle, needs to be interactive
nativeCheckInputs = [ util-linux ];
doCheck = false; # dependency cycle, needs to be interactive
postInstall = ''
ln -s bash "$out/bin/sh"
rm -f $out/lib/bash/Makefile.inc
'';
postFixup =
if interactive
then ''
substituteInPlace "$out/bin/bashbug" \
--replace '#!/bin/sh' "#!$out/bin/bash"
''
# most space is taken by locale data
else ''
rm -rf "$out/share" "$out/bin/bashbug"
postInstall = ''
ln -s bash "$out/bin/sh"
rm -f $out/lib/bash/Makefile.inc
'';
passthru = {
shellPath = "/bin/bash";
tests.static = pkgsStatic.bash;
};
postFixup =
if interactive then
''
substituteInPlace "$out/bin/bashbug" \
--replace '#!/bin/sh' "#!$out/bin/bash"
''
# most space is taken by locale data
else
''
rm -rf "$out/share" "$out/bin/bashbug"
'';
meta = with lib; {
homepage = "https://www.gnu.org/software/bash/";
description = "GNU Bourne-Again Shell, the de facto standard shell on Linux" + lib.optionalString interactive " (for interactive use)";
longDescription = ''
Bash is the shell, or command language interpreter, that will
appear in the GNU operating system. Bash is an sh-compatible
shell that incorporates useful features from the Korn shell
(ksh) and C shell (csh). It is intended to conform to the IEEE
POSIX P1003.2/ISO 9945.2 Shell and Tools standard. It offers
functional improvements over sh for both programming and
interactive use. In addition, most sh scripts can be run by
Bash without modification.
'';
license = licenses.gpl3Plus;
platforms = platforms.all;
# https://github.com/NixOS/nixpkgs/issues/333338
badPlatforms = [ lib.systems.inspect.patterns.isMinGW ];
maintainers = [ ];
mainProgram = "bash";
};
}
passthru = {
shellPath = "/bin/bash";
tests.static = pkgsStatic.bash;
};
meta = with lib; {
homepage = "https://www.gnu.org/software/bash/";
description =
"GNU Bourne-Again Shell, the de facto standard shell on Linux"
+ lib.optionalString interactive " (for interactive use)";
longDescription = ''
Bash is the shell, or command language interpreter, that will
appear in the GNU operating system. Bash is an sh-compatible
shell that incorporates useful features from the Korn shell
(ksh) and C shell (csh). It is intended to conform to the IEEE
POSIX P1003.2/ISO 9945.2 Shell and Tools standard. It offers
functional improvements over sh for both programming and
interactive use. In addition, most sh scripts can be run by
Bash without modification.
'';
license = licenses.gpl3Plus;
platforms = platforms.all;
# https://github.com/NixOS/nixpkgs/issues/333338
badPlatforms = [ lib.systems.inspect.patterns.isMinGW ];
maintainers = [ ];
mainProgram = "bash";
};
}

View File

@@ -1,86 +1,95 @@
{ lib, newScope, config }:
{
lib,
newScope,
config,
}:
lib.makeScope newScope (self: with self; {
async-prompt = callPackage ./async-prompt.nix { };
lib.makeScope newScope (
self:
with self;
{
async-prompt = callPackage ./async-prompt.nix { };
autopair = callPackage ./autopair.nix { };
autopair = callPackage ./autopair.nix { };
bang-bang = callPackage ./bang-bang.nix { };
bang-bang = callPackage ./bang-bang.nix { };
bobthefish = callPackage ./bobthefish.nix { };
bobthefish = callPackage ./bobthefish.nix { };
bobthefisher = callPackage ./bobthefisher.nix { };
bobthefisher = callPackage ./bobthefisher.nix { };
buildFishPlugin = callPackage ./build-fish-plugin.nix { };
buildFishPlugin = callPackage ./build-fish-plugin.nix { };
colored-man-pages = callPackage ./colored-man-pages.nix { };
colored-man-pages = callPackage ./colored-man-pages.nix { };
clownfish = callPackage ./clownfish.nix { };
clownfish = callPackage ./clownfish.nix { };
bass = callPackage ./bass.nix { };
bass = callPackage ./bass.nix { };
done = callPackage ./done.nix { };
done = callPackage ./done.nix { };
exercism-cli-fish-wrapper = callPackage ./exercism-cli-fish-wrapper.nix { };
exercism-cli-fish-wrapper = callPackage ./exercism-cli-fish-wrapper.nix { };
fifc = callPackage ./fifc.nix { };
fifc = callPackage ./fifc.nix { };
fish-bd = callPackage ./fish-bd.nix { };
fish-bd = callPackage ./fish-bd.nix { };
# Fishtape 2.x and 3.x aren't compatible,
# but both versions are used in the tests of different other plugins.
fishtape = callPackage ./fishtape.nix { };
fishtape_3 = callPackage ./fishtape_3.nix { };
# Fishtape 2.x and 3.x aren't compatible,
# but both versions are used in the tests of different other plugins.
fishtape = callPackage ./fishtape.nix { };
fishtape_3 = callPackage ./fishtape_3.nix { };
fish-you-should-use = callPackage ./fish-you-should-use.nix { };
fish-you-should-use = callPackage ./fish-you-should-use.nix { };
foreign-env = callPackage ./foreign-env { };
foreign-env = callPackage ./foreign-env { };
forgit = callPackage ./forgit.nix { };
forgit = callPackage ./forgit.nix { };
fzf = callPackage ./fzf.nix { };
fzf = callPackage ./fzf.nix { };
fzf-fish = callPackage ./fzf-fish.nix { };
fzf-fish = callPackage ./fzf-fish.nix { };
github-copilot-cli-fish = callPackage ./github-copilot-cli-fish.nix { };
github-copilot-cli-fish = callPackage ./github-copilot-cli-fish.nix { };
git-abbr = callPackage ./git-abbr.nix { };
git-abbr = callPackage ./git-abbr.nix { };
grc = callPackage ./grc.nix { };
grc = callPackage ./grc.nix { };
gruvbox = callPackage ./gruvbox.nix { };
gruvbox = callPackage ./gruvbox.nix { };
humantime-fish = callPackage ./humantime-fish.nix { };
humantime-fish = callPackage ./humantime-fish.nix { };
hydro = callPackage ./hydro.nix { };
hydro = callPackage ./hydro.nix { };
macos = callPackage ./macos.nix { };
macos = callPackage ./macos.nix { };
nvm = callPackage ./nvm.nix { };
nvm = callPackage ./nvm.nix { };
pisces = callPackage ./pisces.nix { };
pisces = callPackage ./pisces.nix { };
plugin-git = callPackage ./plugin-git.nix { };
plugin-git = callPackage ./plugin-git.nix { };
plugin-sudope = callPackage ./plugin-sudope.nix { };
plugin-sudope = callPackage ./plugin-sudope.nix { };
puffer = callPackage ./puffer.nix { };
puffer = callPackage ./puffer.nix { };
pure = callPackage ./pure.nix { };
pure = callPackage ./pure.nix { };
sdkman-for-fish = callPackage ./sdkman-for-fish.nix { };
sdkman-for-fish = callPackage ./sdkman-for-fish.nix { };
spark = callPackage ./spark.nix { };
spark = callPackage ./spark.nix { };
sponge = callPackage ./sponge.nix { };
sponge = callPackage ./sponge.nix { };
tide = callPackage ./tide.nix { };
tide = callPackage ./tide.nix { };
transient-fish = callPackage ./transient-fish.nix { };
transient-fish = callPackage ./transient-fish.nix { };
wakatime-fish = callPackage ./wakatime-fish.nix { };
wakatime-fish = callPackage ./wakatime-fish.nix { };
z = callPackage ./z.nix { };
} // lib.optionalAttrs config.allowAliases {
autopair-fish = self.autopair; # Added 2023-03-10
})
z = callPackage ./z.nix { };
}
// lib.optionalAttrs config.allowAliases {
autopair-fish = self.autopair; # Added 2023-03-10
}
)

View File

@@ -1,52 +1,65 @@
{ lib, writeShellApplication, fish, writeTextFile }:
lib.makeOverridable ({
completionDirs ? [],
functionDirs ? [],
confDirs ? [],
pluginPkgs ? [],
localConfig ? "",
shellAliases ? {},
runtimeInputs ? []
{
lib,
writeShellApplication,
fish,
writeTextFile,
}:
let
aliasesStr = builtins.concatStringsSep "\n"
(lib.mapAttrsToList (k: v: "alias ${k} ${lib.escapeShellArg v}") shellAliases);
lib.makeOverridable (
{
completionDirs ? [ ],
functionDirs ? [ ],
confDirs ? [ ],
pluginPkgs ? [ ],
localConfig ? "",
shellAliases ? { },
runtimeInputs ? [ ],
}:
shellAliasesFishConfig = writeTextFile {
name = "wrapfish.aliases.fish";
destination = "/share/fish/vendor_conf.d/aliases.fish";
let
aliasesStr = builtins.concatStringsSep "\n" (
lib.mapAttrsToList (k: v: "alias ${k} ${lib.escapeShellArg v}") shellAliases
);
shellAliasesFishConfig = writeTextFile {
name = "wrapfish.aliases.fish";
destination = "/share/fish/vendor_conf.d/aliases.fish";
text = ''
status is-interactive; and begin
# Aliases
${aliasesStr}
end
'';
};
localFishConfig = writeTextFile {
name = "wrapfish.local.fish";
destination = "/share/fish/vendor_conf.d/config.local.fish";
text = localConfig;
};
vendorDir = kind: plugin: "${plugin}/share/fish/vendor_${kind}.d";
complPath = completionDirs ++ map (vendorDir "completions") pluginPkgs;
funcPath = functionDirs ++ map (vendorDir "functions") pluginPkgs;
confPath =
confDirs
++ (map (vendorDir "conf") pluginPkgs)
++ (map (vendorDir "conf") [
localFishConfig
shellAliasesFishConfig
]);
in
writeShellApplication {
inherit runtimeInputs;
name = "fish";
text = ''
status is-interactive; and begin
# Aliases
${aliasesStr}
end
${fish}/bin/fish --init-command "
set --prepend fish_complete_path ${lib.escapeShellArgs complPath}
set --prepend fish_function_path ${lib.escapeShellArgs funcPath}
set --local fish_conf_source_path ${lib.escapeShellArgs confPath}
for c in \$fish_conf_source_path/*; source \$c; end
" "$@"
'';
};
localFishConfig = writeTextFile {
name = "wrapfish.local.fish";
destination = "/share/fish/vendor_conf.d/config.local.fish";
text = localConfig;
};
vendorDir = kind: plugin: "${plugin}/share/fish/vendor_${kind}.d";
complPath = completionDirs ++ map (vendorDir "completions") pluginPkgs;
funcPath = functionDirs ++ map (vendorDir "functions") pluginPkgs;
confPath = confDirs
++ (map (vendorDir "conf") pluginPkgs)
++ (map (vendorDir "conf") [ localFishConfig shellAliasesFishConfig ]);
in writeShellApplication {
inherit runtimeInputs;
name = "fish";
text = ''
${fish}/bin/fish --init-command "
set --prepend fish_complete_path ${lib.escapeShellArgs complPath}
set --prepend fish_function_path ${lib.escapeShellArgs funcPath}
set --local fish_conf_source_path ${lib.escapeShellArgs confPath}
for c in \$fish_conf_source_path/*; source \$c; end
" "$@"
'';
})
}
)

View File

@@ -1,15 +1,32 @@
{ lib, config, newScope, dbus, IOKit, CoreFoundation, Foundation, Security }:
{
lib,
config,
newScope,
dbus,
IOKit,
CoreFoundation,
Foundation,
Security,
}:
lib.makeScope newScope (self: with self; {
gstat = callPackage ./gstat.nix { inherit Security; };
formats = callPackage ./formats.nix { inherit IOKit Foundation; };
polars = callPackage ./polars.nix { inherit IOKit Foundation; };
query = callPackage ./query.nix { inherit IOKit CoreFoundation; };
net = callPackage ./net.nix { inherit IOKit CoreFoundation; };
units = callPackage ./units.nix { inherit IOKit Foundation; };
highlight = callPackage ./highlight.nix { inherit IOKit Foundation; };
dbus = callPackage ./dbus.nix { inherit dbus; nushell_plugin_dbus = self.dbus; };
skim = callPackage ./skim.nix { inherit IOKit CoreFoundation; };
} // lib.optionalAttrs config.allowAliases {
regex = throw "`nu_plugin_regex` is no longer compatible with the current Nushell release.";
})
lib.makeScope newScope (
self:
with self;
{
gstat = callPackage ./gstat.nix { inherit Security; };
formats = callPackage ./formats.nix { inherit IOKit Foundation; };
polars = callPackage ./polars.nix { inherit IOKit Foundation; };
query = callPackage ./query.nix { inherit IOKit CoreFoundation; };
net = callPackage ./net.nix { inherit IOKit CoreFoundation; };
units = callPackage ./units.nix { inherit IOKit Foundation; };
highlight = callPackage ./highlight.nix { inherit IOKit Foundation; };
dbus = callPackage ./dbus.nix {
inherit dbus;
nushell_plugin_dbus = self.dbus;
};
skim = callPackage ./skim.nix { inherit IOKit CoreFoundation; };
}
// lib.optionalAttrs config.allowAliases {
regex = throw "`nu_plugin_regex` is no longer compatible with the current Nushell release.";
}
)