mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-13 21:50:33 +03:00
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:
parent
b32a094368
commit
4f0dadbf38
21293 changed files with 701351 additions and 428307 deletions
|
@ -87,36 +87,41 @@
|
|||
}
|
||||
```
|
||||
*/
|
||||
{ pkgs
|
||||
, lib
|
||||
, options
|
||||
, transformOptions ? lib.id # function for additional transformations of the options
|
||||
, documentType ? "appendix" # TODO deprecate "appendix" in favor of "none"
|
||||
# and/or rename function to moduleOptionDoc for clean slate
|
||||
{
|
||||
pkgs,
|
||||
lib,
|
||||
options,
|
||||
transformOptions ? lib.id, # function for additional transformations of the options
|
||||
documentType ? "appendix",
|
||||
# TODO deprecate "appendix" in favor of "none"
|
||||
# and/or rename function to moduleOptionDoc for clean slate
|
||||
|
||||
# If you include more than one option list into a document, you need to
|
||||
# provide different ids.
|
||||
, variablelistId ? "configuration-variable-list"
|
||||
variablelistId ? "configuration-variable-list",
|
||||
# String to prefix to the option XML/HTML id attributes.
|
||||
, optionIdPrefix ? "opt-"
|
||||
, revision ? "" # Specify revision for the options
|
||||
# a set of options the docs we are generating will be merged into, as if by recursiveUpdate.
|
||||
# used to split the options doc build into a static part (nixos/modules) and a dynamic part
|
||||
# (non-nixos modules imported via configuration.nix, other module sources).
|
||||
, baseOptionsJSON ? null
|
||||
# instead of printing warnings for eg options with missing descriptions (which may be lost
|
||||
# by nix build unless -L is given), emit errors instead and fail the build
|
||||
, warningsAreErrors ? true
|
||||
optionIdPrefix ? "opt-",
|
||||
revision ? "", # Specify revision for the options
|
||||
# a set of options the docs we are generating will be merged into, as if by recursiveUpdate.
|
||||
# used to split the options doc build into a static part (nixos/modules) and a dynamic part
|
||||
# (non-nixos modules imported via configuration.nix, other module sources).
|
||||
baseOptionsJSON ? null,
|
||||
# instead of printing warnings for eg options with missing descriptions (which may be lost
|
||||
# by nix build unless -L is given), emit errors instead and fail the build
|
||||
warningsAreErrors ? true,
|
||||
}:
|
||||
|
||||
let
|
||||
rawOpts = lib.optionAttrSetToDocList options;
|
||||
transformedOpts = map transformOptions rawOpts;
|
||||
filteredOpts = lib.filter (opt: opt.visible && !opt.internal) transformedOpts;
|
||||
optionsList = lib.flip map filteredOpts
|
||||
(opt: opt
|
||||
// lib.optionalAttrs (opt ? relatedPackages && opt.relatedPackages != []) { relatedPackages = genRelatedPackages opt.relatedPackages opt.name; }
|
||||
);
|
||||
optionsList = lib.flip map filteredOpts (
|
||||
opt:
|
||||
opt
|
||||
// lib.optionalAttrs (opt ? relatedPackages && opt.relatedPackages != [ ]) {
|
||||
relatedPackages = genRelatedPackages opt.relatedPackages opt.name;
|
||||
}
|
||||
);
|
||||
|
||||
# Generate DocBook documentation for a list of packages. This is
|
||||
# what `relatedPackages` option of `mkOption` from
|
||||
|
@ -132,87 +137,110 @@ let
|
|||
#
|
||||
# NOTE: No checks against `pkgs` are made to ensure that the referenced package actually exists.
|
||||
# Such checks are not compatible with option docs caching.
|
||||
genRelatedPackages = packages: optName:
|
||||
genRelatedPackages =
|
||||
packages: optName:
|
||||
let
|
||||
unpack = p: if lib.isString p then { name = p; }
|
||||
else if lib.isList p then { path = p; }
|
||||
else p;
|
||||
describe = args:
|
||||
unpack =
|
||||
p:
|
||||
if lib.isString p then
|
||||
{ name = p; }
|
||||
else if lib.isList p then
|
||||
{ path = p; }
|
||||
else
|
||||
p;
|
||||
describe =
|
||||
args:
|
||||
let
|
||||
title = args.title or null;
|
||||
name = args.name or (lib.concatStringsSep "." args.path);
|
||||
in ''
|
||||
in
|
||||
''
|
||||
- [${lib.optionalString (title != null) "${title} aka "}`pkgs.${name}`](
|
||||
https://search.nixos.org/packages?show=${name}&sort=relevance&query=${name}
|
||||
)${
|
||||
lib.optionalString (args ? comment) "\n\n ${args.comment}"
|
||||
}
|
||||
)${lib.optionalString (args ? comment) "\n\n ${args.comment}"}
|
||||
'';
|
||||
in lib.concatMapStrings (p: describe (unpack p)) packages;
|
||||
in
|
||||
lib.concatMapStrings (p: describe (unpack p)) packages;
|
||||
|
||||
optionsNix = builtins.listToAttrs (map (o: { name = o.name; value = removeAttrs o ["name" "visible" "internal"]; }) optionsList);
|
||||
optionsNix = builtins.listToAttrs (
|
||||
map (o: {
|
||||
name = o.name;
|
||||
value = removeAttrs o [
|
||||
"name"
|
||||
"visible"
|
||||
"internal"
|
||||
];
|
||||
}) optionsList
|
||||
);
|
||||
|
||||
in rec {
|
||||
in
|
||||
rec {
|
||||
inherit optionsNix;
|
||||
|
||||
optionsAsciiDoc = pkgs.runCommand "options.adoc" {
|
||||
nativeBuildInputs = [ pkgs.nixos-render-docs ];
|
||||
} ''
|
||||
nixos-render-docs -j $NIX_BUILD_CORES options asciidoc \
|
||||
--manpage-urls ${pkgs.path + "/doc/manpage-urls.json"} \
|
||||
--revision ${lib.escapeShellArg revision} \
|
||||
${optionsJSON}/share/doc/nixos/options.json \
|
||||
$out
|
||||
'';
|
||||
optionsAsciiDoc =
|
||||
pkgs.runCommand "options.adoc"
|
||||
{
|
||||
nativeBuildInputs = [ pkgs.nixos-render-docs ];
|
||||
}
|
||||
''
|
||||
nixos-render-docs -j $NIX_BUILD_CORES options asciidoc \
|
||||
--manpage-urls ${pkgs.path + "/doc/manpage-urls.json"} \
|
||||
--revision ${lib.escapeShellArg revision} \
|
||||
${optionsJSON}/share/doc/nixos/options.json \
|
||||
$out
|
||||
'';
|
||||
|
||||
optionsCommonMark = pkgs.runCommand "options.md" {
|
||||
nativeBuildInputs = [ pkgs.nixos-render-docs ];
|
||||
} ''
|
||||
nixos-render-docs -j $NIX_BUILD_CORES options commonmark \
|
||||
--manpage-urls ${pkgs.path + "/doc/manpage-urls.json"} \
|
||||
--revision ${lib.escapeShellArg revision} \
|
||||
${optionsJSON}/share/doc/nixos/options.json \
|
||||
$out
|
||||
'';
|
||||
optionsCommonMark =
|
||||
pkgs.runCommand "options.md"
|
||||
{
|
||||
nativeBuildInputs = [ pkgs.nixos-render-docs ];
|
||||
}
|
||||
''
|
||||
nixos-render-docs -j $NIX_BUILD_CORES options commonmark \
|
||||
--manpage-urls ${pkgs.path + "/doc/manpage-urls.json"} \
|
||||
--revision ${lib.escapeShellArg revision} \
|
||||
${optionsJSON}/share/doc/nixos/options.json \
|
||||
$out
|
||||
'';
|
||||
|
||||
optionsJSON = pkgs.runCommand "options.json"
|
||||
{ meta.description = "List of NixOS options in JSON format";
|
||||
nativeBuildInputs = [
|
||||
pkgs.brotli
|
||||
pkgs.python3
|
||||
];
|
||||
options = builtins.toFile "options.json"
|
||||
(builtins.unsafeDiscardStringContext (builtins.toJSON optionsNix));
|
||||
# merge with an empty set if baseOptionsJSON is null to run markdown
|
||||
# processing on the input options
|
||||
baseJSON =
|
||||
if baseOptionsJSON == null
|
||||
then builtins.toFile "base.json" "{}"
|
||||
else baseOptionsJSON;
|
||||
}
|
||||
''
|
||||
# Export list of options in different format.
|
||||
dst=$out/share/doc/nixos
|
||||
mkdir -p $dst
|
||||
optionsJSON =
|
||||
pkgs.runCommand "options.json"
|
||||
{
|
||||
meta.description = "List of NixOS options in JSON format";
|
||||
nativeBuildInputs = [
|
||||
pkgs.brotli
|
||||
pkgs.python3
|
||||
];
|
||||
options = builtins.toFile "options.json" (
|
||||
builtins.unsafeDiscardStringContext (builtins.toJSON optionsNix)
|
||||
);
|
||||
# merge with an empty set if baseOptionsJSON is null to run markdown
|
||||
# processing on the input options
|
||||
baseJSON = if baseOptionsJSON == null then builtins.toFile "base.json" "{}" else baseOptionsJSON;
|
||||
}
|
||||
''
|
||||
# Export list of options in different format.
|
||||
dst=$out/share/doc/nixos
|
||||
mkdir -p $dst
|
||||
|
||||
TOUCH_IF_DB=$dst/.used-docbook \
|
||||
python ${./mergeJSON.py} \
|
||||
${lib.optionalString warningsAreErrors "--warnings-are-errors"} \
|
||||
$baseJSON $options \
|
||||
> $dst/options.json
|
||||
TOUCH_IF_DB=$dst/.used-docbook \
|
||||
python ${./mergeJSON.py} \
|
||||
${lib.optionalString warningsAreErrors "--warnings-are-errors"} \
|
||||
$baseJSON $options \
|
||||
> $dst/options.json
|
||||
|
||||
if grep /nixpkgs/nixos/modules $dst/options.json; then
|
||||
echo "The manual appears to depend on the location of Nixpkgs, which is bad"
|
||||
echo "since this prevents sharing via the NixOS channel. This is typically"
|
||||
echo "caused by an option default that refers to a relative path (see above"
|
||||
echo "for hints about the offending path)."
|
||||
exit 1
|
||||
fi
|
||||
if grep /nixpkgs/nixos/modules $dst/options.json; then
|
||||
echo "The manual appears to depend on the location of Nixpkgs, which is bad"
|
||||
echo "since this prevents sharing via the NixOS channel. This is typically"
|
||||
echo "caused by an option default that refers to a relative path (see above"
|
||||
echo "for hints about the offending path)."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
brotli -9 < $dst/options.json > $dst/options.json.br
|
||||
brotli -9 < $dst/options.json > $dst/options.json.br
|
||||
|
||||
mkdir -p $out/nix-support
|
||||
echo "file json $dst/options.json" >> $out/nix-support/hydra-build-products
|
||||
echo "file json-br $dst/options.json.br" >> $out/nix-support/hydra-build-products
|
||||
'';
|
||||
mkdir -p $out/nix-support
|
||||
echo "file json $dst/options.json" >> $out/nix-support/hydra-build-products
|
||||
echo "file json-br $dst/options.json.br" >> $out/nix-support/hydra-build-products
|
||||
'';
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue