0
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-07-14 06:00: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 57b193d8dd
    result/bin/apply-formatting $NIXPKGS_PATH
This commit is contained in:
Silvan Mosberger 2024-12-10 20:27:17 +01:00
parent 57b193d8dd
commit 667d42c00d
21287 changed files with 701385 additions and 428458 deletions

View file

@ -1,4 +1,10 @@
{ options, config, pkgs, lib, ... }:
{
options,
config,
pkgs,
lib,
...
}:
let
inherit (lib) mkOption types mkIf;
@ -15,120 +21,132 @@ in
See <http://wiki.ucis.nl/QuickTun> for more information about available options.
'';
type = types.attrsOf (types.submodule ({ name, ... }: let
qtcfg = cfg.${name};
in {
options = {
tunMode = mkOption {
type = with types; coercedTo bool (b: if b then 1 else 0) (ints.between 0 1);
default = false;
example = true;
description = "Whether to operate in tun (IP) or tap (Ethernet) mode.";
};
type = types.attrsOf (
types.submodule (
{ name, ... }:
let
qtcfg = cfg.${name};
in
{
options = {
tunMode = mkOption {
type = with types; coercedTo bool (b: if b then 1 else 0) (ints.between 0 1);
default = false;
example = true;
description = "Whether to operate in tun (IP) or tap (Ethernet) mode.";
};
remoteAddress = mkOption {
type = types.str;
default = "0.0.0.0";
example = "tunnel.example.com";
description = ''
IP address or hostname of the remote end (use `0.0.0.0` for a floating/dynamic remote endpoint).
'';
};
remoteAddress = mkOption {
type = types.str;
default = "0.0.0.0";
example = "tunnel.example.com";
description = ''
IP address or hostname of the remote end (use `0.0.0.0` for a floating/dynamic remote endpoint).
'';
};
localAddress = mkOption {
type = with types; nullOr str;
default = null;
example = "0.0.0.0";
description = "IP address or hostname of the local end.";
};
localAddress = mkOption {
type = with types; nullOr str;
default = null;
example = "0.0.0.0";
description = "IP address or hostname of the local end.";
};
localPort = mkOption {
type = types.port;
default = 2998;
description = "Local UDP port.";
};
localPort = mkOption {
type = types.port;
default = 2998;
description = "Local UDP port.";
};
remotePort = mkOption {
type = types.port;
default = qtcfg.localPort;
defaultText = lib.literalExpression "config.services.quicktun.<name>.localPort";
description = " remote UDP port";
};
remotePort = mkOption {
type = types.port;
default = qtcfg.localPort;
defaultText = lib.literalExpression "config.services.quicktun.<name>.localPort";
description = " remote UDP port";
};
remoteFloat = mkOption {
type = with types; coercedTo bool (b: if b then 1 else 0) (ints.between 0 1);
default = false;
example = true;
description = ''
Whether to allow the remote address and port to change when properly encrypted packets are received.
'';
};
remoteFloat = mkOption {
type = with types; coercedTo bool (b: if b then 1 else 0) (ints.between 0 1);
default = false;
example = true;
description = ''
Whether to allow the remote address and port to change when properly encrypted packets are received.
'';
};
protocol = mkOption {
type = types.enum [ "raw" "nacl0" "nacltai" "salty" ];
default = "nacltai";
description = "Which protocol to use.";
};
protocol = mkOption {
type = types.enum [
"raw"
"nacl0"
"nacltai"
"salty"
];
default = "nacltai";
description = "Which protocol to use.";
};
privateKey = mkOption {
type = with types; nullOr str;
default = null;
description = ''
Local secret key in hexadecimal form.
privateKey = mkOption {
type = with types; nullOr str;
default = null;
description = ''
Local secret key in hexadecimal form.
::: {.warning}
This option is deprecated. Please use {var}`services.quicktun.<name>.privateKeyFile` instead.
:::
::: {.warning}
This option is deprecated. Please use {var}`services.quicktun.<name>.privateKeyFile` instead.
:::
::: {.note}
Not needed when {var}`services.quicktun.<name>.protocol` is set to `raw`.
:::
'';
};
::: {.note}
Not needed when {var}`services.quicktun.<name>.protocol` is set to `raw`.
:::
'';
};
privateKeyFile = mkOption {
type = with types; nullOr path;
# This is a hack to deprecate `privateKey` without using `mkChangedModuleOption`
default = if qtcfg.privateKey == null then null else pkgs.writeText "quickttun-key-${name}" qtcfg.privateKey;
defaultText = "null";
description = ''
Path to file containing local secret key in binary or hexadecimal form.
privateKeyFile = mkOption {
type = with types; nullOr path;
# This is a hack to deprecate `privateKey` without using `mkChangedModuleOption`
default =
if qtcfg.privateKey == null then null else pkgs.writeText "quickttun-key-${name}" qtcfg.privateKey;
defaultText = "null";
description = ''
Path to file containing local secret key in binary or hexadecimal form.
::: {.note}
Not needed when {var}`services.quicktun.<name>.protocol` is set to `raw`.
:::
'';
};
::: {.note}
Not needed when {var}`services.quicktun.<name>.protocol` is set to `raw`.
:::
'';
};
publicKey = mkOption {
type = with types; nullOr str;
default = null;
description = ''
Remote public key in hexadecimal form.
publicKey = mkOption {
type = with types; nullOr str;
default = null;
description = ''
Remote public key in hexadecimal form.
::: {.note}
Not needed when {var}`services.quicktun.<name>.protocol` is set to `raw`.
:::
'';
};
::: {.note}
Not needed when {var}`services.quicktun.<name>.protocol` is set to `raw`.
:::
'';
};
timeWindow = mkOption {
type = types.ints.unsigned;
default = 5;
description = ''
Allowed time window for first received packet in seconds (positive number allows packets from history)
'';
};
timeWindow = mkOption {
type = types.ints.unsigned;
default = 5;
description = ''
Allowed time window for first received packet in seconds (positive number allows packets from history)
'';
};
upScript = mkOption {
type = with types; nullOr lines;
default = null;
description = ''
Run specified command or script after the tunnel device has been opened.
'';
};
};
}));
upScript = mkOption {
type = with types; nullOr lines;
default = null;
description = ''
Run specified command or script after the tunnel device has been opened.
'';
};
};
}
)
);
};
};
@ -137,13 +155,16 @@ in
(lib.mapAttrsToList (name: value: if value.privateKey != null then name else null))
(builtins.filter (n: n != null))
(map (n: " - services.quicktun.${n}.privateKey"))
(services: lib.optional (services != [ ]) ''
`services.quicktun.<name>.privateKey` is deprecated.
Please use `services.quicktun.<name>.privateKeyFile` instead.
(
services:
lib.optional (services != [ ]) ''
`services.quicktun.<name>.privateKey` is deprecated.
Please use `services.quicktun.<name>.privateKeyFile` instead.
Offending options:
${lib.concatStringsSep "\n" services}
'')
Offending options:
${lib.concatStringsSep "\n" services}
''
)
];
systemd.services = lib.mkMerge (
@ -162,7 +183,9 @@ in
PRIVATE_KEY_FILE = mkIf (qtcfg.privateKeyFile != null) qtcfg.privateKeyFile;
PUBLIC_KEY = mkIf (qtcfg.publicKey != null) qtcfg.publicKey;
TIME_WINDOW = toString qtcfg.timeWindow;
TUN_UP_SCRIPT = mkIf (qtcfg.upScript != null) (pkgs.writeScript "quicktun-${name}-up.sh" qtcfg.upScript);
TUN_UP_SCRIPT = mkIf (qtcfg.upScript != null) (
pkgs.writeScript "quicktun-${name}-up.sh" qtcfg.upScript
);
SUID = "nobody";
};
serviceConfig = {