summaryrefslogtreecommitdiffstats
path: root/nixos
diff options
context:
space:
mode:
Diffstat (limited to 'nixos')
-rw-r--r--nixos/doc/manual/development/writing-nixos-tests.xml11
-rw-r--r--nixos/doc/manual/release-notes/rl-2105.xml15
-rw-r--r--nixos/modules/module-list.nix1
-rw-r--r--nixos/modules/services/backup/borgmatic.nix57
-rw-r--r--nixos/modules/services/misc/apache-kafka.nix23
-rw-r--r--nixos/modules/services/monitoring/prometheus/exporters.nix26
-rw-r--r--nixos/modules/services/monitoring/prometheus/exporters/artifactory.nix59
-rw-r--r--nixos/modules/services/monitoring/prometheus/exporters/knot.nix50
-rw-r--r--nixos/modules/services/monitoring/prometheus/exporters/systemd.nix18
-rw-r--r--nixos/modules/services/networking/privoxy.nix5
-rw-r--r--nixos/modules/services/web-apps/nextcloud.nix14
-rw-r--r--nixos/tests/kafka.nix6
-rw-r--r--nixos/tests/nextcloud/basic.nix22
-rw-r--r--nixos/tests/prometheus-exporters.nix49
14 files changed, 322 insertions, 34 deletions
diff --git a/nixos/doc/manual/development/writing-nixos-tests.xml b/nixos/doc/manual/development/writing-nixos-tests.xml
index cab4c067e0d3..5f70f74d5d90 100644
--- a/nixos/doc/manual/development/writing-nixos-tests.xml
+++ b/nixos/doc/manual/development/writing-nixos-tests.xml
@@ -449,5 +449,16 @@ import ./make-test-python.nix {
'';
}
</programlisting>
+ This will produce a Nix warning at evaluation time. To fully disable the
+ linter, wrap the test script in comment directives to disable the Black linter
+ directly (again, don't commit this within the Nixpkgs repository):
+<programlisting>
+ testScript =
+ ''
+ # fmt: off
+ <replaceable>Python codeā€¦</replaceable>
+ # fmt: on
+ '';
+</programlisting>
</para>
</section>
diff --git a/nixos/doc/manual/release-notes/rl-2105.xml b/nixos/doc/manual/release-notes/rl-2105.xml
index 9a1e6b6618df..e052632ecafd 100644
--- a/nixos/doc/manual/release-notes/rl-2105.xml
+++ b/nixos/doc/manual/release-notes/rl-2105.xml
@@ -562,6 +562,21 @@ self: super:
<xref linkend="opt-services.xserver.videoDrivers" /> no longer uses the deprecated <literal>cirrus</literal> and <literal>vesa</literal> device dependent X drivers by default. It also enables both <literal>amdgpu</literal> and <literal>nouveau</literal> drivers by default now.
</para>
</listitem>
+ <listitem>
+ <para>
+ The <package>apacheKafka</package> packages are now built with
+ version-matched JREs. Versions 2.6 and above, the ones that recommend it,
+ use jdk11, while versions below remain on jdk8. The NixOS service has
+ been adjusted to start the service using the same version as the package,
+ adjustable with the new
+ <link linkend="opt-services.apache-kafka.jre">services.apache-kafka.jre</link>
+ option. Furthermore, the default list of
+ <link linkend="opt-services.apache-kafka.jvmOptions">services.apache-kafka.jvmOptions</link>
+ have been removed. You should set your own according to the
+ <link xlink:href="https://kafka.apache.org/documentation/#java">upstream documentation</link>
+ for your Kafka version.
+ </para>
+ </listitem>
</itemizedlist>
</section>
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix
index 9bb81d085c95..f226194efd56 100644
--- a/nixos/modules/module-list.nix
+++ b/nixos/modules/module-list.nix
@@ -242,6 +242,7 @@
./services/backup/automysqlbackup.nix
./services/backup/bacula.nix
./services/backup/borgbackup.nix
+ ./services/backup/borgmatic.nix
./services/backup/duplicati.nix
./services/backup/duplicity.nix
./services/backup/mysql-backup.nix
diff --git a/nixos/modules/services/backup/borgmatic.nix b/nixos/modules/services/backup/borgmatic.nix
new file mode 100644
index 000000000000..5e5c0bbeccca
--- /dev/null
+++ b/nixos/modules/services/backup/borgmatic.nix
@@ -0,0 +1,57 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+ cfg = config.services.borgmatic;
+ cfgfile = pkgs.writeText "config.yaml" (builtins.toJSON cfg.settings);
+in {
+ options.services.borgmatic = {
+ enable = mkEnableOption "borgmatic";
+
+ settings = mkOption {
+ description = ''
+ See https://torsion.org/borgmatic/docs/reference/configuration/
+ '';
+ type = types.submodule {
+ freeformType = with lib.types; attrsOf anything;
+ options.location = {
+ source_directories = mkOption {
+ type = types.listOf types.str;
+ description = ''
+ List of source directories to backup (required). Globs and
+ tildes are expanded.
+ '';
+ example = [ "/home" "/etc" "/var/log/syslog*" ];
+ };
+ repositories = mkOption {
+ type = types.listOf types.str;
+ description = ''
+ Paths to local or remote repositories (required). Tildes are
+ expanded. Multiple repositories are backed up to in
+ sequence. Borg placeholders can be used. See the output of
+ "borg help placeholders" for details. See ssh_command for
+ SSH options like identity file or port. If systemd service
+ is used, then add local repository paths in the systemd
+ service file to the ReadWritePaths list.
+ '';
+ example = [
+ "user@backupserver:sourcehostname.borg"
+ "user@backupserver:{fqdn}"
+ ];
+ };
+ };
+ };
+ };
+ };
+
+ config = mkIf cfg.enable {
+
+ environment.systemPackages = [ pkgs.borgmatic ];
+
+ environment.etc."borgmatic/config.yaml".source = cfgfile;
+
+ systemd.packages = [ pkgs.borgmatic ];
+
+ };
+}
diff --git a/nixos/modules/services/misc/apache-kafka.nix b/nixos/modules/services/misc/apache-kafka.nix
index f3a650a260f1..69dfadfe54e0 100644
--- a/nixos/modules/services/misc/apache-kafka.nix
+++ b/nixos/modules/services/misc/apache-kafka.nix
@@ -90,19 +90,7 @@ in {
jvmOptions = mkOption {
description = "Extra command line options for the JVM running Kafka.";
- default = [
- "-server"
- "-Xmx1G"
- "-Xms1G"
- "-XX:+UseCompressedOops"
- "-XX:+UseParNewGC"
- "-XX:+UseConcMarkSweepGC"
- "-XX:+CMSClassUnloadingEnabled"
- "-XX:+CMSScavengeBeforeRemark"
- "-XX:+DisableExplicitGC"
- "-Djava.awt.headless=true"
- "-Djava.net.preferIPv4Stack=true"
- ];
+ default = [];
type = types.listOf types.str;
example = [
"-Djava.net.preferIPv4Stack=true"
@@ -118,6 +106,13 @@ in {
type = types.package;
};
+ jre = mkOption {
+ description = "The JRE with which to run Kafka";
+ default = cfg.package.passthru.jre;
+ defaultText = "pkgs.apacheKafka.passthru.jre";
+ type = types.package;
+ };
+
};
config = mkIf cfg.enable {
@@ -138,7 +133,7 @@ in {
after = [ "network.target" ];
serviceConfig = {
ExecStart = ''
- ${pkgs.jre}/bin/java \
+ ${cfg.jre}/bin/java \
-cp "${cfg.package}/libs/*" \
-Dlog4j.configuration=file:${logConfig} \
${toString cfg.jvmOptions} \
diff --git a/nixos/modules/services/monitoring/prometheus/exporters.nix b/nixos/modules/services/monitoring/prometheus/exporters.nix
index 940f28189371..115ecbf12b5e 100644
--- a/nixos/modules/services/monitoring/prometheus/exporters.nix
+++ b/nixos/modules/services/monitoring/prometheus/exporters.nix
@@ -3,7 +3,7 @@
let
inherit (lib) concatStrings foldl foldl' genAttrs literalExample maintainers
mapAttrsToList mkDefault mkEnableOption mkIf mkMerge mkOption
- optional types;
+ optional types mkOptionDefault flip attrNames;
cfg = config.services.prometheus.exporters;
@@ -22,6 +22,7 @@ let
exporterOpts = genAttrs [
"apcupsd"
+ "artifactory"
"bind"
"bird"
"blackbox"
@@ -31,6 +32,7 @@ let
"fritzbox"
"json"
"keylight"
+ "knot"
"lnd"
"mail"
"mikrotik"
@@ -51,6 +53,7 @@ let
"smokeping"
"sql"
"surfboard"
+ "systemd"
"tor"
"unifi"
"unifi-poller"
@@ -64,7 +67,7 @@ let
mkExporterOpts = ({ name, port }: {
enable = mkEnableOption "the prometheus ${name} exporter";
port = mkOption {
- type = types.int;
+ type = types.port;
default = port;
description = ''
Port to listen on.
@@ -92,9 +95,8 @@ let
'';
};
firewallFilter = mkOption {
- type = types.str;
- default = "-p tcp -m tcp --dport ${toString cfg.${name}.port}";
- defaultText = "-p tcp -m tcp --dport ${toString port}";
+ type = types.nullOr types.str;
+ default = null;
example = literalExample ''
"-i eth0 -p tcp -m tcp --dport ${toString port}"
'';
@@ -122,12 +124,14 @@ let
mkSubModule = { name, port, extraOpts, imports }: {
${name} = mkOption {
- type = types.submodule {
+ type = types.submodule [{
inherit imports;
options = (mkExporterOpts {
inherit name port;
} // extraOpts);
- };
+ } ({ config, ... }: mkIf config.openFirewall {
+ firewallFilter = mkOptionDefault "-p tcp -m tcp --dport ${toString config.port}";
+ })];
internal = true;
default = {};
};
@@ -232,7 +236,13 @@ in
Please specify either 'services.prometheus.exporters.sql.configuration' or
'services.prometheus.exporters.sql.configFile'
'';
- } ];
+ } ] ++ (flip map (attrNames cfg) (exporter: {
+ assertion = cfg.${exporter}.firewallFilter != null -> cfg.${exporter}.openFirewall;
+ message = ''
+ The `firewallFilter'-option of exporter ${exporter} doesn't have any effect unless
+ `openFirewall' is set to `true'!
+ '';
+ }));
}] ++ [(mkIf config.services.minio.enable {
services.prometheus.exporters.minio.minioAddress = mkDefault "http://localhost:9000";
services.prometheus.exporters.minio.minioAccessKey = mkDefault config.services.minio.accessKey;
diff --git a/nixos/modules/services/monitoring/prometheus/exporters/artifactory.nix b/nixos/modules/services/monitoring/prometheus/exporters/artifactory.nix
new file mode 100644
index 000000000000..2adcecc728bd
--- /dev/null
+++ b/nixos/modules/services/monitoring/prometheus/exporters/artifactory.nix
@@ -0,0 +1,59 @@
+{ config, lib, pkgs, options }:
+
+with lib;
+
+let
+ cfg = config.services.prometheus.exporters.artifactory;
+in
+{
+ port = 9531;
+ extraOpts = {
+ scrapeUri = mkOption {
+ type = types.str;
+ default = "http://localhost:8081/artifactory";
+ description = ''
+ URI on which to scrape JFrog Artifactory.
+ '';
+ };
+
+ artiUsername = mkOption {
+ type = types.str;
+ description = ''
+ Username for authentication against JFrog Artifactory API.
+ '';
+ };
+
+ artiPassword = mkOption {
+ type = types.str;
+ default = "";
+ description = ''
+ Password for authentication against JFrog Artifactory API.
+ One of the password or access token needs to be set.
+ '';
+ };
+
+ artiAccessToken = mkOption {
+ type = types.str;
+ default = "";
+ description = ''
+ Access token for authentication against JFrog Artifactory API.
+ One of the password or access token needs to be set.
+ '';
+ };
+ };
+ serviceOpts = {
+ serviceConfig = {
+ ExecStart = ''
+ ${pkgs.prometheus-artifactory-exporter}/bin/artifactory_exporter \
+ --web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
+ --artifactory.scrape-uri ${cfg.scrapeUri} \
+ ${concatStringsSep " \\\n " cfg.extraFlags}
+ '';
+ Environment = [
+ "ARTI_USERNAME=${cfg.artiUsername}"
+ "ARTI_PASSWORD=${cfg.artiPassword}"
+ "ARTI_ACCESS_TOKEN=${cfg.artiAccessToken}"
+ ];
+ };
+ };
+}
diff --git a/nixos/modules/services/monitoring/prometheus/exporters/knot.nix b/nixos/modules/services/monitoring/prometheus/exporters/knot.nix
new file mode 100644
index 000000000000..46c28fe0a578
--- /dev/null
+++ b/nixos/modules/services/monitoring/prometheus/exporters/knot.nix
@@ -0,0 +1,50 @@
+{ config, lib, pkgs, options }:
+
+with lib;
+
+let
+ cfg = config.services.prometheus.exporters.knot;
+in {
+ port = 9433;
+ extraOpts = {
+ knotLibraryPath = mkOption {
+ type = types.str;
+ default = "${pkgs.knot-dns.out}/lib/libknot.so";
+ defaultText = "\${pkgs.knot-dns}/lib/libknot.so";
+ description = ''
+ Path to the library of <package>knot-dns</package>.
+ '';
+ };
+
+ knotSocketPath = mkOption {
+ type = types.str;
+ default = "/run/knot/knot.sock";
+ description = ''
+ Socket path of <citerefentry><refentrytitle>knotd</refentrytitle>
+ <manvolnum>8</manvolnum></citerefentry>.
+ '';
+ };
+
+ knotSocketTimeout = mkOption {
+ type = types.int;
+ default = 2000;
+ description = ''
+ Timeout in seconds.
+ '';
+ };
+ };
+ serviceOpts = {
+ serviceConfig = {
+ ExecStart = ''
+ ${pkgs.prometheus-knot-exporter}/bin/knot_exporter \
+ --web-listen-addr ${cfg.listenAddress} \
+ --web-listen-port ${toString cfg.port} \
+ --knot-library-path ${cfg.knotLibraryPath} \
+ --knot-socket-path ${cfg.knotSocketPath} \
+ --knot-socket-timeout ${toString cfg.knotSocketTimeout} \
+ ${concatStringsSep " \\\n " cfg.extraFlags}
+ '';
+ SupplementaryGroups = [ "knot" ];
+ };
+ };
+}
diff --git a/nixos/modules/services/monitoring/prometheus/exporters/systemd.nix b/nixos/modules/services/monitoring/prometheus/exporters/systemd.nix
new file mode 100644
index 000000000000..0514469b8a61
--- /dev/null
+++ b/nixos/modules/services/monitoring/prometheus/exporters/systemd.nix
@@ -0,0 +1,18 @@
+{ config, pkgs, lib, ... }:
+
+with lib;
+
+let cfg = config.services.prometheus.exporters.systemd;
+
+in {
+ port = 9558;
+
+ serviceOpts = {
+ serviceConfig = {
+ ExecStart = ''
+ ${pkgs.prometheus-systemd-exporter}/bin/systemd_exporter \
+ --web.listen-address ${cfg.listenAddress}:${toString cfg.port}
+ '';
+ };
+ };
+}
diff --git a/nixos/modules/services/networking/privoxy.nix b/nixos/modules/services/networking/privoxy.nix
index f1a9c6029cb0..7c22b7d09b9b 100644
--- a/nixos/modules/services/networking/privoxy.nix
+++ b/nixos/modules/services/networking/privoxy.nix
@@ -205,9 +205,8 @@ in
users.groups.privoxy = {};
- systemd.tmpfiles.rules = with cfg.settings; [
- "d ${certificate-directory} 0770 privoxy privoxy ${cfg.certsLifetime}"
- ];
+ systemd.tmpfiles.rules = optional cfg.inspectHttps
+ "d ${cfg.settings.certificate-directory} 0770 privoxy privoxy ${cfg.certsLifetime}";
systemd.services.privoxy = {
description = "Filtering web proxy";
diff --git a/nixos/modules/services/web-apps/nextcloud.nix b/nixos/modules/services/web-apps/nextcloud.nix
index 5636415f6a0d..9a541aba6e43 100644
--- a/nixos/modules/services/web-apps/nextcloud.nix
+++ b/nixos/modules/services/web-apps/nextcloud.nix
@@ -10,7 +10,7 @@ let
extensions = { enabled, all }:
(with all;
enabled
- ++ [ imagick ] # Always enabled
+ ++ optional (!cfg.disableImagemagick) imagick
# Optionally enabled depending on caching settings
++ optional cfg.caching.apcu apcu
++ optional cfg.caching.redis redis
@@ -303,6 +303,18 @@ in {
};
};
+ disableImagemagick = mkOption {
+ type = types.bool;
+ default = false;
+ description = ''
+ Whether to not load the ImageMagick module into PHP.
+ This is used by the theming app and for generating previews of certain images (e.g. SVG and HEIF).
+ You may want to disable it for increased security. In that case, previews will still be available
+ for some images (e.g. JPEG and PNG).
+ See https://github.com/nextcloud/server/issues/13099
+ '';
+ };
+
caching = {
apcu = mkOption {
type = types.bool;
diff --git a/nixos/tests/kafka.nix b/nixos/tests/kafka.nix
index d5c54f7d9910..034601c815b9 100644
--- a/nixos/tests/kafka.nix
+++ b/nixos/tests/kafka.nix
@@ -30,11 +30,6 @@ let
'';
package = kafkaPackage;
zookeeper = "zookeeper1:2181";
- # These are the default options, but UseCompressedOops doesn't work with 32bit JVM
- jvmOptions = [
- "-server" "-Xmx1G" "-Xms1G" "-XX:+UseParNewGC" "-XX:+UseConcMarkSweepGC" "-XX:+CMSClassUnloadingEnabled"
- "-XX:+CMSScavengeBeforeRemark" "-XX:+DisableExplicitGC" "-Djava.awt.headless=true" "-Djava.net.preferIPv4Stack=true"
- ] ++ optionals (! pkgs.stdenv.isi686 ) [ "-XX:+UseCompressedOops" ];
};
networking.firewall.allowedTCPPorts = [ 9092 ];
@@ -82,4 +77,5 @@ let
in with pkgs; {
kafka_2_4 = makeKafkaTest "kafka_2_4" apacheKafka_2_4;
kafka_2_5 = makeKafkaTest "kafka_2_5" apacheKafka_2_5;
+ kafka_2_6 = makeKafkaTest "kafka_2_6" apacheKafka_2_6;
}
diff --git a/nixos/tests/nextcloud/basic.nix b/nixos/tests/nextcloud/basic.nix
index 0b8e1937128c..5074b6cdafef 100644
--- a/nixos/tests/nextcloud/basic.nix
+++ b/nixos/tests/nextcloud/basic.nix
@@ -7,7 +7,7 @@ in {
maintainers = [ globin eqyiel ];
};
- nodes = {
+ nodes = rec {
# The only thing the client needs to do is download a file.
client = { ... }: {
services.davfs2.enable = true;
@@ -47,9 +47,14 @@ in {
environment.systemPackages = [ cfg.services.nextcloud.occ ];
};
+
+ nextcloudWithoutMagick = args@{ config, pkgs, lib, ... }:
+ lib.mkMerge
+ [ (nextcloud args)
+ { services.nextcloud.disableImagemagick = true; } ];
};
- testScript = let
+ testScript = { nodes, ... }: let
withRcloneEnv = pkgs.writeScript "with-rclone-env" ''
#!${pkgs.runtimeShell}
export RCLONE_CONFIG_NEXTCLOUD_TYPE=webdav
@@ -68,8 +73,19 @@ in {
#!${pkgs.runtimeShell}
diff <(echo 'hi') <(${pkgs.rclone}/bin/rclone cat nextcloud:test-shared-file)
'';
+
+ findInClosure = what: drv: pkgs.runCommand "find-in-closure" { exportReferencesGraph = [ "graph" drv ]; inherit what; } ''
+ test -e graph
+ grep "$what" graph >$out || true
+ '';
+ nextcloudUsesImagick = findInClosure "imagick" nodes.nextcloud.config.system.build.vm;
+ nextcloudWithoutDoesntUseIt = findInClosure "imagick" nodes.nextcloudWithoutMagick.config.system.build.vm;
in ''
- start_all()
+ assert open("${nextcloudUsesImagick}").read() != ""
+ assert open("${nextcloudWithoutDoesntUseIt}").read() == ""
+
+ nextcloud.start()
+ client.start()
nextcloud.wait_for_unit("multi-user.target")
# This is just to ensure the nextcloud-occ program is working
nextcloud.succeed("nextcloud-occ status")
diff --git a/nixos/tests/prometheus-exporters.nix b/nixos/tests/prometheus-exporters.nix
index 89d17c9de8c0..78a3afad0ba3 100644
--- a/nixos/tests/prometheus-exporters.nix
+++ b/nixos/tests/prometheus-exporters.nix
@@ -75,6 +75,21 @@ let
'';
};
+ artifactory = {
+ exporterConfig = {
+ enable = true;
+ artiUsername = "artifactory-username";
+ artiPassword = "artifactory-password";
+ };
+ exporterTest = ''
+ wait_for_unit("prometheus-artifactory-exporter.service")
+ wait_for_open_port(9531)
+ succeed(
+ "curl -sSf http://localhost:9531/metrics | grep -q 'artifactory_up'"
+ )
+ '';
+ };
+
bind = {
exporterConfig = {
enable = true;
@@ -248,6 +263,24 @@ let
'';
};
+ knot = {
+ exporterConfig = {
+ enable = true;
+ };
+ metricProvider = {
+ services.knot = {
+ enable = true;
+ extraArgs = [ "-v" ];
+ };
+ };
+ exporterTest = ''
+ wait_for_unit("knot.service")
+ wait_for_unit("prometheus-knot-exporter.service")
+ wait_for_open_port(9433)
+ succeed("curl -sSf 'localhost:9433' | grep -q 'knot_server_zone_count 0.0'")
+ '';
+ };
+
keylight = {
# A hardware device is required to properly test this exporter, so just
# perform a couple of basic sanity checks that the exporter is running
@@ -802,6 +835,22 @@ let
'';
};
+ systemd = {
+ exporterConfig = {
+ enable = true;
+ };
+ metricProvider = { };
+ exporterTest = ''
+ wait_for_unit("prometheus-systemd-exporter.service")
+ wait_for_open_port(9558)
+ succeed(
+ "curl -sSf localhost:9558/metrics | grep -q '{}'".format(
+ 'systemd_unit_state{name="basic.target",state="active",type="target"} 1'
+ )
+ )
+ '';
+ };
+
tor = {
exporterConfig = {
enable = true;