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
|
@ -1,4 +1,9 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.services.watchdogd;
|
||||
|
||||
|
@ -33,54 +38,59 @@ let
|
|||
'';
|
||||
};
|
||||
};
|
||||
in {
|
||||
in
|
||||
{
|
||||
options.services.watchdogd = {
|
||||
enable = lib.mkEnableOption "watchdogd, an advanced system & process supervisor";
|
||||
package = lib.mkPackageOption pkgs "watchdogd" { };
|
||||
|
||||
settings = lib.mkOption {
|
||||
type = with lib.types; submodule {
|
||||
freeformType = let
|
||||
valueType = oneOf [
|
||||
bool
|
||||
int
|
||||
float
|
||||
str
|
||||
];
|
||||
in attrsOf (either valueType (attrsOf valueType));
|
||||
type =
|
||||
with lib.types;
|
||||
submodule {
|
||||
freeformType =
|
||||
let
|
||||
valueType = oneOf [
|
||||
bool
|
||||
int
|
||||
float
|
||||
str
|
||||
];
|
||||
in
|
||||
attrsOf (either valueType (attrsOf valueType));
|
||||
|
||||
options = {
|
||||
timeout = lib.mkOption {
|
||||
type = types.ints.unsigned;
|
||||
default = 15;
|
||||
description = ''
|
||||
The WDT timeout before reset.
|
||||
'';
|
||||
options = {
|
||||
timeout = lib.mkOption {
|
||||
type = types.ints.unsigned;
|
||||
default = 15;
|
||||
description = ''
|
||||
The WDT timeout before reset.
|
||||
'';
|
||||
};
|
||||
interval = lib.mkOption {
|
||||
type = types.ints.unsigned;
|
||||
default = 5;
|
||||
description = ''
|
||||
The kick interval, i.e. how often {manpage}`watchdogd(8)` should reset the WDT timer.
|
||||
'';
|
||||
};
|
||||
|
||||
safe-exit = lib.mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = ''
|
||||
With {var}`safeExit` enabled, the daemon will ask the driver to disable the WDT before exiting.
|
||||
However, some WDT drivers (or hardware) may not support this.
|
||||
'';
|
||||
};
|
||||
|
||||
filenr = mkPluginOpts "filenr" 0.9 1.0;
|
||||
|
||||
loadavg = mkPluginOpts "loadavg" 1.0 2.0;
|
||||
|
||||
meminfo = mkPluginOpts "meminfo" 0.9 0.95;
|
||||
};
|
||||
interval = lib.mkOption {
|
||||
type = types.ints.unsigned;
|
||||
default = 5;
|
||||
description = ''
|
||||
The kick interval, i.e. how often {manpage}`watchdogd(8)` should reset the WDT timer.
|
||||
'';
|
||||
};
|
||||
|
||||
safe-exit = lib.mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = ''
|
||||
With {var}`safeExit` enabled, the daemon will ask the driver to disable the WDT before exiting.
|
||||
However, some WDT drivers (or hardware) may not support this.
|
||||
'';
|
||||
};
|
||||
|
||||
filenr = mkPluginOpts "filenr" 0.9 1.0;
|
||||
|
||||
loadavg = mkPluginOpts "loadavg" 1.0 2.0;
|
||||
|
||||
meminfo = mkPluginOpts "meminfo" 0.9 0.95;
|
||||
};
|
||||
};
|
||||
default = { };
|
||||
description = ''
|
||||
Configuration to put in {file}`watchdogd.conf`.
|
||||
|
@ -89,42 +99,52 @@ in {
|
|||
};
|
||||
};
|
||||
|
||||
config = let
|
||||
toConfig = attrs: lib.concatStringsSep "\n" (lib.mapAttrsToList toValue attrs);
|
||||
config =
|
||||
let
|
||||
toConfig = attrs: lib.concatStringsSep "\n" (lib.mapAttrsToList toValue attrs);
|
||||
|
||||
toValue = name: value:
|
||||
if lib.isAttrs value
|
||||
then lib.pipe value [
|
||||
(lib.mapAttrsToList toValue)
|
||||
(map (s: " ${s}"))
|
||||
(lib.concatStringsSep "\n")
|
||||
(s: "${name} {\n${s}\n}")
|
||||
]
|
||||
else if lib.isBool value
|
||||
then "${name} = ${lib.boolToString value}"
|
||||
else if lib.any (f: f value) [lib.isString lib.isInt lib.isFloat]
|
||||
then "${name} = ${toString value}"
|
||||
else throw ''
|
||||
Found invalid type in `services.watchdogd.settings`: '${lib.typeOf value}'
|
||||
'';
|
||||
toValue =
|
||||
name: value:
|
||||
if lib.isAttrs value then
|
||||
lib.pipe value [
|
||||
(lib.mapAttrsToList toValue)
|
||||
(map (s: " ${s}"))
|
||||
(lib.concatStringsSep "\n")
|
||||
(s: "${name} {\n${s}\n}")
|
||||
]
|
||||
else if lib.isBool value then
|
||||
"${name} = ${lib.boolToString value}"
|
||||
else if
|
||||
lib.any (f: f value) [
|
||||
lib.isString
|
||||
lib.isInt
|
||||
lib.isFloat
|
||||
]
|
||||
then
|
||||
"${name} = ${toString value}"
|
||||
else
|
||||
throw ''
|
||||
Found invalid type in `services.watchdogd.settings`: '${lib.typeOf value}'
|
||||
'';
|
||||
|
||||
watchdogdConf = pkgs.writeText "watchdogd.conf" (toConfig cfg.settings);
|
||||
in lib.mkIf cfg.enable {
|
||||
environment.systemPackages = [ cfg.package ];
|
||||
watchdogdConf = pkgs.writeText "watchdogd.conf" (toConfig cfg.settings);
|
||||
in
|
||||
lib.mkIf cfg.enable {
|
||||
environment.systemPackages = [ cfg.package ];
|
||||
|
||||
systemd.services.watchdogd = {
|
||||
documentation = [
|
||||
"man:watchdogd(8)"
|
||||
"man:watchdogd.conf(5)"
|
||||
];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
description = "Advanced system & process supervisor";
|
||||
serviceConfig = {
|
||||
Type = "simple";
|
||||
ExecStart = "${cfg.package}/bin/watchdogd -n -f ${watchdogdConf}";
|
||||
systemd.services.watchdogd = {
|
||||
documentation = [
|
||||
"man:watchdogd(8)"
|
||||
"man:watchdogd.conf(5)"
|
||||
];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
description = "Advanced system & process supervisor";
|
||||
serviceConfig = {
|
||||
Type = "simple";
|
||||
ExecStart = "${cfg.package}/bin/watchdogd -n -f ${watchdogdConf}";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
meta.maintainers = with lib.maintainers; [ vifino ];
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue