0
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-07-14 14:10: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:
Silvan Mosberger 2024-12-10 20:26:33 +01:00
parent b32a094368
commit 4f0dadbf38
21293 changed files with 701351 additions and 428307 deletions

View file

@ -1,156 +1,162 @@
import ../make-test-python.nix ({ lib, pkgs, ... }:
import ../make-test-python.nix (
{ lib, pkgs, ... }:
# Based on https://quickwit.io/docs/log-management/send-logs/using-vector
# Based on https://quickwit.io/docs/log-management/send-logs/using-vector
{
name = "vector-syslog-quickwit";
meta.maintainers = [ pkgs.lib.maintainers.happysalada ];
{
name = "vector-syslog-quickwit";
meta.maintainers = [ pkgs.lib.maintainers.happysalada ];
nodes = {
quickwit = { config, pkgs, ... }: {
environment.systemPackages = [ pkgs.jq ];
nodes = {
quickwit =
{ config, pkgs, ... }:
{
environment.systemPackages = [ pkgs.jq ];
networking.firewall.allowedTCPPorts = [ 7280 ];
networking.firewall.allowedTCPPorts = [ 7280 ];
services.quickwit = {
enable = true;
settings = {
listen_address = "::";
};
};
};
syslog = { config, pkgs, ... }: {
services.vector = {
enable = true;
settings = {
sources = {
generate_syslog = {
type = "demo_logs";
format = "syslog";
interval = 0.5;
};
};
transforms = {
remap_syslog = {
inputs = ["generate_syslog"];
type = "remap";
source = ''
structured = parse_syslog!(.message)
.timestamp_nanos = to_unix_timestamp!(structured.timestamp, unit: "nanoseconds")
.body = structured
.service_name = structured.appname
.resource_attributes.source_type = .source_type
.resource_attributes.host.hostname = structured.hostname
.resource_attributes.service.name = structured.appname
.attributes.syslog.procid = structured.procid
.attributes.syslog.facility = structured.facility
.attributes.syslog.version = structured.version
.severity_text = if includes(["emerg", "err", "crit", "alert"], structured.severity) {
"ERROR"
} else if structured.severity == "warning" {
"WARN"
} else if structured.severity == "debug" {
"DEBUG"
} else if includes(["info", "notice"], structured.severity) {
"INFO"
} else {
structured.severity
}
.scope_name = structured.msgid
del(.message)
del(.host)
del(.timestamp)
del(.service)
del(.source_type)
'';
};
};
sinks = {
#emit_syslog = {
# inputs = ["remap_syslog"];
# type = "console";
# encoding.codec = "json";
#};
quickwit_logs = {
type = "http";
method = "post";
inputs = [ "remap_syslog" ];
encoding.codec = "json";
framing.method = "newline_delimited";
uri = "http://quickwit:7280/api/v1/otel-logs-v0_7/ingest";
services.quickwit = {
enable = true;
settings = {
listen_address = "::";
};
};
};
};
};
};
testScript =
let
aggregationQuery = pkgs.writeText "aggregation-query.json" ''
{
"query": "*",
"max_hits": 0,
"aggs": {
"count_per_minute": {
"histogram": {
"field": "timestamp_nanos",
"interval": 60000000
},
syslog =
{ config, pkgs, ... }:
{
services.vector = {
enable = true;
settings = {
sources = {
generate_syslog = {
type = "demo_logs";
format = "syslog";
interval = 0.5;
};
};
transforms = {
remap_syslog = {
inputs = [ "generate_syslog" ];
type = "remap";
source = ''
structured = parse_syslog!(.message)
.timestamp_nanos = to_unix_timestamp!(structured.timestamp, unit: "nanoseconds")
.body = structured
.service_name = structured.appname
.resource_attributes.source_type = .source_type
.resource_attributes.host.hostname = structured.hostname
.resource_attributes.service.name = structured.appname
.attributes.syslog.procid = structured.procid
.attributes.syslog.facility = structured.facility
.attributes.syslog.version = structured.version
.severity_text = if includes(["emerg", "err", "crit", "alert"], structured.severity) {
"ERROR"
} else if structured.severity == "warning" {
"WARN"
} else if structured.severity == "debug" {
"DEBUG"
} else if includes(["info", "notice"], structured.severity) {
"INFO"
} else {
structured.severity
}
.scope_name = structured.msgid
del(.message)
del(.host)
del(.timestamp)
del(.service)
del(.source_type)
'';
};
};
sinks = {
#emit_syslog = {
# inputs = ["remap_syslog"];
# type = "console";
# encoding.codec = "json";
#};
quickwit_logs = {
type = "http";
method = "post";
inputs = [ "remap_syslog" ];
encoding.codec = "json";
framing.method = "newline_delimited";
uri = "http://quickwit:7280/api/v1/otel-logs-v0_7/ingest";
};
};
};
};
};
};
testScript =
let
aggregationQuery = pkgs.writeText "aggregation-query.json" ''
{
"query": "*",
"max_hits": 0,
"aggs": {
"severity_text_count": {
"terms": {
"field": "severity_text"
"count_per_minute": {
"histogram": {
"field": "timestamp_nanos",
"interval": 60000000
},
"aggs": {
"severity_text_count": {
"terms": {
"field": "severity_text"
}
}
}
}
}
}
}
}
'';
in
''
quickwit.wait_for_unit("quickwit")
quickwit.wait_for_open_port(7280)
quickwit.wait_for_open_port(7281)
'';
in
''
quickwit.wait_for_unit("quickwit")
quickwit.wait_for_open_port(7280)
quickwit.wait_for_open_port(7281)
quickwit.wait_until_succeeds(
"journalctl -o cat -u quickwit.service | grep 'transitioned to ready state'"
)
quickwit.wait_until_succeeds(
"journalctl -o cat -u quickwit.service | grep 'transitioned to ready state'"
)
syslog.wait_for_unit("vector")
syslog.wait_until_succeeds(
"journalctl -o cat -u vector.service | grep 'Vector has started'"
)
syslog.wait_for_unit("vector")
syslog.wait_until_succeeds(
"journalctl -o cat -u vector.service | grep 'Vector has started'"
)
quickwit.wait_until_succeeds(
"journalctl -o cat -u quickwit.service | grep 'publish-new-splits'"
)
quickwit.wait_until_succeeds(
"journalctl -o cat -u quickwit.service | grep 'publish-new-splits'"
)
# Wait for logs to be generated
# Test below aggregates by the minute
syslog.sleep(60 * 2)
# Wait for logs to be generated
# Test below aggregates by the minute
syslog.sleep(60 * 2)
quickwit.wait_until_succeeds(
"curl -sSf -XGET http://127.0.0.1:7280/api/v1/otel-logs-v0_7/search?query=severity_text:ERROR |"
+ " jq '.num_hits' | grep -v '0'"
)
quickwit.wait_until_succeeds(
"curl -sSf -XGET http://127.0.0.1:7280/api/v1/otel-logs-v0_7/search?query=severity_text:ERROR |"
+ " jq '.num_hits' | grep -v '0'"
)
quickwit.wait_until_succeeds(
"journalctl -o cat -u quickwit.service | grep 'SearchRequest'"
)
quickwit.wait_until_succeeds(
"journalctl -o cat -u quickwit.service | grep 'SearchRequest'"
)
quickwit.wait_until_succeeds(
"curl -sSf -XPOST -H 'Content-Type: application/json' http://127.0.0.1:7280/api/v1/otel-logs-v0_7/search --data @${aggregationQuery} |"
+ " jq '.num_hits' | grep -v '0'"
)
quickwit.wait_until_succeeds(
"curl -sSf -XPOST -H 'Content-Type: application/json' http://127.0.0.1:7280/api/v1/otel-logs-v0_7/search --data @${aggregationQuery} |"
+ " jq '.num_hits' | grep -v '0'"
)
quickwit.wait_until_succeeds(
"journalctl -o cat -u quickwit.service | grep 'count_per_minute'"
)
'';
})
quickwit.wait_until_succeeds(
"journalctl -o cat -u quickwit.service | grep 'count_per_minute'"
)
'';
}
)