mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-12 13:18:57 +03:00
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:
parent
2140bf39e4
commit
374e6bcc40
1523 changed files with 986047 additions and 513621 deletions
|
@ -1,35 +1,55 @@
|
|||
# generate the script used to activate the configuration.
|
||||
{ config, lib, pkgs, ... }:
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
addAttributeName = mapAttrs (a: v: v // {
|
||||
text = ''
|
||||
#### Activation script snippet ${a}:
|
||||
_localstatus=0
|
||||
${v.text}
|
||||
addAttributeName = mapAttrs (
|
||||
a: v:
|
||||
v
|
||||
// {
|
||||
text = ''
|
||||
#### Activation script snippet ${a}:
|
||||
_localstatus=0
|
||||
${v.text}
|
||||
|
||||
if (( _localstatus > 0 )); then
|
||||
printf "Activation script snippet '%s' failed (%s)\n" "${a}" "$_localstatus"
|
||||
fi
|
||||
'';
|
||||
});
|
||||
if (( _localstatus > 0 )); then
|
||||
printf "Activation script snippet '%s' failed (%s)\n" "${a}" "$_localstatus"
|
||||
fi
|
||||
'';
|
||||
}
|
||||
);
|
||||
|
||||
systemActivationScript = set: onlyDry: let
|
||||
set' = mapAttrs (_: v: if isString v then (noDepEntry v) // { supportsDryActivation = false; } else v) set;
|
||||
withHeadlines = addAttributeName set';
|
||||
# When building a dry activation script, this replaces all activation scripts
|
||||
# that do not support dry mode with a comment that does nothing. Filtering these
|
||||
# activation scripts out so they don't get generated into the dry activation script
|
||||
# does not work because when an activation script that supports dry mode depends on
|
||||
# an activation script that does not, the dependency cannot be resolved and the eval
|
||||
# fails.
|
||||
withDrySnippets = mapAttrs (a: v: if onlyDry && !v.supportsDryActivation then v // {
|
||||
text = "#### Activation script snippet ${a} does not support dry activation.";
|
||||
} else v) withHeadlines;
|
||||
in
|
||||
systemActivationScript =
|
||||
set: onlyDry:
|
||||
let
|
||||
set' = mapAttrs (
|
||||
_: v: if isString v then (noDepEntry v) // { supportsDryActivation = false; } else v
|
||||
) set;
|
||||
withHeadlines = addAttributeName set';
|
||||
# When building a dry activation script, this replaces all activation scripts
|
||||
# that do not support dry mode with a comment that does nothing. Filtering these
|
||||
# activation scripts out so they don't get generated into the dry activation script
|
||||
# does not work because when an activation script that supports dry mode depends on
|
||||
# an activation script that does not, the dependency cannot be resolved and the eval
|
||||
# fails.
|
||||
withDrySnippets = mapAttrs (
|
||||
a: v:
|
||||
if onlyDry && !v.supportsDryActivation then
|
||||
v
|
||||
// {
|
||||
text = "#### Activation script snippet ${a} does not support dry activation.";
|
||||
}
|
||||
else
|
||||
v
|
||||
) withHeadlines;
|
||||
in
|
||||
''
|
||||
#!${pkgs.runtimeShell}
|
||||
|
||||
|
@ -50,7 +70,8 @@ let
|
|||
|
||||
${textClosureMap id (withDrySnippets) (attrNames withDrySnippets)}
|
||||
|
||||
'' + optionalString (!onlyDry) ''
|
||||
''
|
||||
+ optionalString (!onlyDry) ''
|
||||
# Make this configuration the current configuration.
|
||||
# The readlink is there to ensure that when $systemConfig = /system
|
||||
# (which is a symlink to the store), /run/current-system is still
|
||||
|
@ -60,8 +81,10 @@ let
|
|||
exit $_status
|
||||
'';
|
||||
|
||||
path = with pkgs; map getBin
|
||||
[ coreutils
|
||||
path =
|
||||
with pkgs;
|
||||
map getBin [
|
||||
coreutils
|
||||
gnugrep
|
||||
findutils
|
||||
getent
|
||||
|
@ -71,20 +94,25 @@ let
|
|||
util-linux # needed for mount and mountpoint
|
||||
];
|
||||
|
||||
scriptType = withDry: with types;
|
||||
let scriptOptions =
|
||||
{ deps = mkOption
|
||||
{ type = types.listOf types.str;
|
||||
scriptType =
|
||||
withDry:
|
||||
with types;
|
||||
let
|
||||
scriptOptions =
|
||||
{
|
||||
deps = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [ ];
|
||||
description = "List of dependencies. The script will run after these.";
|
||||
};
|
||||
text = mkOption
|
||||
{ type = types.lines;
|
||||
text = mkOption {
|
||||
type = types.lines;
|
||||
description = "The content of the script.";
|
||||
};
|
||||
} // optionalAttrs withDry {
|
||||
supportsDryActivation = mkOption
|
||||
{ type = types.bool;
|
||||
}
|
||||
// optionalAttrs withDry {
|
||||
supportsDryActivation = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = ''
|
||||
Whether this activation script supports being dry-activated.
|
||||
|
@ -95,8 +123,11 @@ let
|
|||
modify anything about the system when the variable is set.
|
||||
'';
|
||||
};
|
||||
};
|
||||
in either str (submodule { options = scriptOptions; });
|
||||
};
|
||||
in
|
||||
either str (submodule {
|
||||
options = scriptOptions;
|
||||
});
|
||||
|
||||
in
|
||||
|
||||
|
@ -107,7 +138,7 @@ in
|
|||
options = {
|
||||
|
||||
system.activationScripts = mkOption {
|
||||
default = {};
|
||||
default = { };
|
||||
|
||||
example = literalExpression ''
|
||||
{
|
||||
|
@ -136,9 +167,12 @@ in
|
|||
'';
|
||||
|
||||
type = types.attrsOf (scriptType true);
|
||||
apply = set: set // {
|
||||
script = systemActivationScript set false;
|
||||
};
|
||||
apply =
|
||||
set:
|
||||
set
|
||||
// {
|
||||
script = systemActivationScript set false;
|
||||
};
|
||||
};
|
||||
|
||||
system.dryActivationScript = mkOption {
|
||||
|
@ -150,7 +184,7 @@ in
|
|||
};
|
||||
|
||||
system.userActivationScripts = mkOption {
|
||||
default = {};
|
||||
default = { };
|
||||
|
||||
example = literalExpression ''
|
||||
{ plasmaSetup = {
|
||||
|
@ -187,7 +221,8 @@ in
|
|||
let
|
||||
set' = mapAttrs (n: v: if isString v then noDepEntry v else v) set;
|
||||
withHeadlines = addAttributeName set';
|
||||
in textClosureMap id (withHeadlines) (attrNames withHeadlines)
|
||||
in
|
||||
textClosureMap id (withHeadlines) (attrNames withHeadlines)
|
||||
}
|
||||
|
||||
exit $_status
|
||||
|
@ -234,7 +269,6 @@ in
|
|||
|
||||
};
|
||||
|
||||
|
||||
###### implementation
|
||||
|
||||
config = {
|
||||
|
@ -242,46 +276,49 @@ in
|
|||
system.activationScripts.stdio = ""; # obsolete
|
||||
system.activationScripts.var = ""; # obsolete
|
||||
|
||||
systemd.tmpfiles.rules = [
|
||||
"D /var/empty 0555 root root -"
|
||||
"h /var/empty - - - - +i"
|
||||
] ++ lib.optionals config.nix.enable [
|
||||
# Prevent the current configuration from being garbage-collected.
|
||||
"d /nix/var/nix/gcroots -"
|
||||
"L+ /nix/var/nix/gcroots/current-system - - - - /run/current-system"
|
||||
];
|
||||
systemd.tmpfiles.rules =
|
||||
[
|
||||
"D /var/empty 0555 root root -"
|
||||
"h /var/empty - - - - +i"
|
||||
]
|
||||
++ lib.optionals config.nix.enable [
|
||||
# Prevent the current configuration from being garbage-collected.
|
||||
"d /nix/var/nix/gcroots -"
|
||||
"L+ /nix/var/nix/gcroots/current-system - - - - /run/current-system"
|
||||
];
|
||||
|
||||
system.activationScripts.usrbinenv = if config.environment.usrbinenv != null
|
||||
then ''
|
||||
mkdir -p /usr/bin
|
||||
chmod 0755 /usr/bin
|
||||
ln -sfn ${config.environment.usrbinenv} /usr/bin/.env.tmp
|
||||
mv /usr/bin/.env.tmp /usr/bin/env # atomically replace /usr/bin/env
|
||||
''
|
||||
else ''
|
||||
rm -f /usr/bin/env
|
||||
if test -d /usr/bin; then rmdir --ignore-fail-on-non-empty /usr/bin; fi
|
||||
if test -d /usr; then rmdir --ignore-fail-on-non-empty /usr; fi
|
||||
'';
|
||||
system.activationScripts.usrbinenv =
|
||||
if config.environment.usrbinenv != null then
|
||||
''
|
||||
mkdir -p /usr/bin
|
||||
chmod 0755 /usr/bin
|
||||
ln -sfn ${config.environment.usrbinenv} /usr/bin/.env.tmp
|
||||
mv /usr/bin/.env.tmp /usr/bin/env # atomically replace /usr/bin/env
|
||||
''
|
||||
else
|
||||
''
|
||||
rm -f /usr/bin/env
|
||||
if test -d /usr/bin; then rmdir --ignore-fail-on-non-empty /usr/bin; fi
|
||||
if test -d /usr; then rmdir --ignore-fail-on-non-empty /usr; fi
|
||||
'';
|
||||
|
||||
system.activationScripts.specialfs =
|
||||
''
|
||||
specialMount() {
|
||||
local device="$1"
|
||||
local mountPoint="$2"
|
||||
local options="$3"
|
||||
local fsType="$4"
|
||||
system.activationScripts.specialfs = ''
|
||||
specialMount() {
|
||||
local device="$1"
|
||||
local mountPoint="$2"
|
||||
local options="$3"
|
||||
local fsType="$4"
|
||||
|
||||
if mountpoint -q "$mountPoint"; then
|
||||
local options="remount,$options"
|
||||
else
|
||||
mkdir -p "$mountPoint"
|
||||
chmod 0755 "$mountPoint"
|
||||
fi
|
||||
mount -t "$fsType" -o "$options" "$device" "$mountPoint"
|
||||
}
|
||||
source ${config.system.build.earlyMountScript}
|
||||
'';
|
||||
if mountpoint -q "$mountPoint"; then
|
||||
local options="remount,$options"
|
||||
else
|
||||
mkdir -p "$mountPoint"
|
||||
chmod 0755 "$mountPoint"
|
||||
fi
|
||||
mount -t "$fsType" -o "$options" "$device" "$mountPoint"
|
||||
}
|
||||
source ${config.system.build.earlyMountScript}
|
||||
'';
|
||||
|
||||
systemd.user = {
|
||||
services.nixos-activation = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue