diff options
author | Frederik Rietdijk <fridh@fridh.nl> | 2019-01-05 10:15:00 +0100 |
---|---|---|
committer | Frederik Rietdijk <fridh@fridh.nl> | 2019-01-05 10:15:00 +0100 |
commit | 60a3973a55f0574bf3f11303cb1dbc20a8bb6d70 (patch) | |
tree | 2040f2d41050694da9b2431eb1b7adc8719a425c /nixos | |
parent | aca57f1aed4068ee374d51b211844972dcb0192f (diff) | |
parent | d9707792b5e1af8999ddcb790b8b1b06305dd186 (diff) | |
download | nixpkgs-60a3973a55f0574bf3f11303cb1dbc20a8bb6d70.tar nixpkgs-60a3973a55f0574bf3f11303cb1dbc20a8bb6d70.tar.gz nixpkgs-60a3973a55f0574bf3f11303cb1dbc20a8bb6d70.tar.bz2 nixpkgs-60a3973a55f0574bf3f11303cb1dbc20a8bb6d70.tar.lz nixpkgs-60a3973a55f0574bf3f11303cb1dbc20a8bb6d70.tar.xz nixpkgs-60a3973a55f0574bf3f11303cb1dbc20a8bb6d70.tar.zst nixpkgs-60a3973a55f0574bf3f11303cb1dbc20a8bb6d70.zip |
Merge staging-next into staging
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/doc/manual/release-notes/rl-1903.xml | 10 | ||||
-rw-r--r-- | nixos/lib/make-ext4-fs.nix | 61 | ||||
-rw-r--r-- | nixos/modules/installer/tools/nixos-generate-config.pl | 2 | ||||
-rw-r--r-- | nixos/modules/programs/sway.nix | 13 | ||||
-rw-r--r-- | nixos/modules/rename.nix | 3 | ||||
-rw-r--r-- | nixos/modules/services/hardware/tlp.nix | 2 | ||||
-rw-r--r-- | nixos/modules/services/monitoring/prometheus/exporters.nix | 1 | ||||
-rw-r--r-- | nixos/modules/services/monitoring/prometheus/exporters/bind.nix | 55 | ||||
-rw-r--r-- | nixos/modules/services/networking/shairport-sync.nix | 2 | ||||
-rw-r--r-- | nixos/modules/services/networking/ssh/sshd.nix | 5 | ||||
-rw-r--r-- | nixos/modules/services/x11/display-managers/default.nix | 4 | ||||
-rw-r--r-- | nixos/modules/tasks/cpu-freq.nix | 57 | ||||
-rw-r--r-- | nixos/tests/prometheus-exporters.nix | 19 |
13 files changed, 137 insertions, 97 deletions
diff --git a/nixos/doc/manual/release-notes/rl-1903.xml b/nixos/doc/manual/release-notes/rl-1903.xml index 65761c12c6a..89d9f48aedd 100644 --- a/nixos/doc/manual/release-notes/rl-1903.xml +++ b/nixos/doc/manual/release-notes/rl-1903.xml @@ -408,16 +408,6 @@ from nixpkgs due to the lack of maintainers. </para> </listitem> - <listitem> - <para> - The <option>powerManagement.cpuFreqGovernor</option> option has been - aliased to <option>powerManagement.cpufreq.governor</option>. On laptops, - <option>powerManagement.cpuFreqGovernor</option> is sometimes set in - <literal>/etc/nixos/hardware-configuration.nix</literal>, so you can - rename it to the new name, or run - <literal>nixos-generate-config</literal> again. - </para> - </listitem> </itemizedlist> </section> </section> diff --git a/nixos/lib/make-ext4-fs.nix b/nixos/lib/make-ext4-fs.nix index 694142a5123..47c6374c81a 100644 --- a/nixos/lib/make-ext4-fs.nix +++ b/nixos/lib/make-ext4-fs.nix @@ -9,6 +9,7 @@ , e2fsprogs , libfaketime , perl +, lkl }: let @@ -18,16 +19,13 @@ in pkgs.stdenv.mkDerivation { name = "ext4-fs.img"; - nativeBuildInputs = [e2fsprogs.bin libfaketime perl]; + nativeBuildInputs = [e2fsprogs.bin libfaketime perl lkl]; buildCommand = '' # Add the closures of the top-level store objects. storePaths=$(cat ${sdClosureInfo}/store-paths) - # Also include a manifest of the closures in a format suitable for nix-store --load-db. - cp ${sdClosureInfo}/registration nix-path-registration - # Make a crude approximation of the size of the target image. # If the script starts failing, increase the fudge factors here. numInodes=$(find $storePaths | wc -l) @@ -38,55 +36,16 @@ pkgs.stdenv.mkDerivation { truncate -s $bytes $out faketime -f "1970-01-01 00:00:01" mkfs.ext4 -L ${volumeLabel} -U ${uuid} $out - # Populate the image contents by piping a bunch of commands to the `debugfs` tool from e2fsprogs. - # For example, to copy /nix/store/abcd...efg-coreutils-8.23/bin/sleep: - # cd /nix/store/abcd...efg-coreutils-8.23/bin - # write /nix/store/abcd...efg-coreutils-8.23/bin/sleep sleep - # sif sleep mode 040555 - # sif sleep gid 30000 - # In particular, debugfs doesn't handle absolute target paths; you have to 'cd' in the virtual - # filesystem first. Likewise the intermediate directories must already exist (using `find` - # handles that for us). And when setting the file's permissions, the inode type flags (__S_IFDIR, - # __S_IFREG) need to be set as well. - ( - echo write nix-path-registration nix-path-registration - echo mkdir nix - echo cd /nix - echo mkdir store - - # XXX: This explodes in exciting ways if anything in /nix/store has a space in it. - find $storePaths -printf '%y %f %h %m\n'| while read -r type file dir perms; do - # echo "TYPE=$type DIR=$dir FILE=$file PERMS=$perms" >&2 - - echo "cd $dir" - case $type in - d) - echo "mkdir $file" - echo sif $file mode $((040000 | 0$perms)) # magic constant is __S_IFDIR - ;; - f) - echo "write $dir/$file $file" - echo sif $file mode $((0100000 | 0$perms)) # magic constant is __S_IFREG - ;; - l) - echo "symlink $file $(readlink "$dir/$file")" - ;; - *) - echo "Unknown entry: $type $dir $file $perms" >&2 - exit 1 - ;; - esac + # Also include a manifest of the closures in a format suitable for nix-store --load-db. + cp ${sdClosureInfo}/registration nix-path-registration + cptofs -t ext4 -i $out nix-path-registration / - echo sif $file gid 30000 # chgrp to nixbld - done - ) | faketime -f "1970-01-01 00:00:01" debugfs -w $out -f /dev/stdin > errorlog 2>&1 + # Create nix/store before copying paths + faketime -f "1970-01-01 00:00:01" mkdir -p nix/store + cptofs -t ext4 -i $out nix / - # The debugfs tool doesn't terminate on error nor exit with a non-zero status. Check manually. - if egrep -q 'Could not allocate|File not found' errorlog; then - cat errorlog - echo "--- Failed to create EXT4 image of $bytes bytes (numInodes=$numInodes, numDataBlocks=$numDataBlocks) ---" - return 1 - fi + echo "copying store paths to image..." + cptofs -t ext4 -i $out $storePaths /nix/store/ # I have ended up with corrupted images sometimes, I suspect that happens when the build machine's disk gets full during the build. if ! fsck.ext4 -n -f $out; then diff --git a/nixos/modules/installer/tools/nixos-generate-config.pl b/nixos/modules/installer/tools/nixos-generate-config.pl index fa01dc7bbaf..52a129b39bc 100644 --- a/nixos/modules/installer/tools/nixos-generate-config.pl +++ b/nixos/modules/installer/tools/nixos-generate-config.pl @@ -104,7 +104,7 @@ if (-e "/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors") { foreach $e (@desired_governors) { if (index($governors, $e) != -1) { - last if (push @attrs, "powerManagement.cpufreq.governor = lib.mkDefault \"$e\";"); + last if (push @attrs, "powerManagement.cpuFreqGovernor = lib.mkDefault \"$e\";"); } } } diff --git a/nixos/modules/programs/sway.nix b/nixos/modules/programs/sway.nix index 0eaaf6b85b9..b3847db8cd9 100644 --- a/nixos/modules/programs/sway.nix +++ b/nixos/modules/programs/sway.nix @@ -7,11 +7,18 @@ let swayPackage = pkgs.sway; swayWrapped = pkgs.writeShellScriptBin "sway" '' - if [[ "$#" -ge 1 ]]; then + set -o errexit + + if [ ! "$_SWAY_WRAPPER_ALREADY_EXECUTED" ]; then + export _SWAY_WRAPPER_ALREADY_EXECUTED=1 + ${cfg.extraSessionCommands} + fi + + if [ "$DBUS_SESSION_BUS_ADDRESS" ]; then + export DBUS_SESSION_BUS_ADDRESS exec sway-setcap "$@" else - ${cfg.extraSessionCommands} - exec ${pkgs.dbus.dbus-launch} --exit-with-session sway-setcap + exec ${pkgs.dbus}/bin/dbus-run-session sway-setcap "$@" fi ''; swayJoined = pkgs.symlinkJoin { diff --git a/nixos/modules/rename.nix b/nixos/modules/rename.nix index 0ed0f4ac209..dc0a175d5bb 100644 --- a/nixos/modules/rename.nix +++ b/nixos/modules/rename.nix @@ -286,9 +286,6 @@ with lib; (mkRenamedOptionModule [ "hardware" "ckb" "enable" ] [ "hardware" "ckb-next" "enable" ]) (mkRenamedOptionModule [ "hardware" "ckb" "package" ] [ "hardware" "ckb-next" "package" ]) - # cpufeq - (mkAliasOptionModule [ "powerManagement" "cpuFreqGovernor" ] [ "powerManagement" "cpufreq" "governor" ]) - ] ++ (flip map [ "blackboxExporter" "collectdExporter" "fritzboxExporter" "jsonExporter" "minioExporter" "nginxExporter" "nodeExporter" "snmpExporter" "unifiExporter" "varnishExporter" ] diff --git a/nixos/modules/services/hardware/tlp.nix b/nixos/modules/services/hardware/tlp.nix index bbc5b5b80a0..b894025c0fd 100644 --- a/nixos/modules/services/hardware/tlp.nix +++ b/nixos/modules/services/hardware/tlp.nix @@ -55,7 +55,7 @@ in config = mkIf cfg.enable { powerManagement.scsiLinkPolicy = null; - powerManagement.cpufreq.governor = null; + powerManagement.cpuFreqGovernor = null; powerManagement.cpufreq.max = null; powerManagement.cpufreq.min = null; diff --git a/nixos/modules/services/monitoring/prometheus/exporters.nix b/nixos/modules/services/monitoring/prometheus/exporters.nix index 5308c9c4ee0..0a084561002 100644 --- a/nixos/modules/services/monitoring/prometheus/exporters.nix +++ b/nixos/modules/services/monitoring/prometheus/exporters.nix @@ -33,6 +33,7 @@ let tor = import ./exporters/tor.nix { inherit config lib pkgs; }; unifi = import ./exporters/unifi.nix { inherit config lib pkgs; }; varnish = import ./exporters/varnish.nix { inherit config lib pkgs; }; + bind = import ./exporters/bind.nix { inherit config lib pkgs; }; }; mkExporterOpts = ({ name, port }: { diff --git a/nixos/modules/services/monitoring/prometheus/exporters/bind.nix b/nixos/modules/services/monitoring/prometheus/exporters/bind.nix new file mode 100644 index 00000000000..a9746c4d65d --- /dev/null +++ b/nixos/modules/services/monitoring/prometheus/exporters/bind.nix @@ -0,0 +1,55 @@ +{ config, lib, pkgs }: + +with lib; + +let + cfg = config.services.prometheus.exporters.bind; +in +{ + port = 9119; + extraOpts = { + bindURI = mkOption { + type = types.str; + default = "http://localhost:8053/"; + description = '' + HTTP XML API address of an Bind server. + ''; + }; + bindTimeout = mkOption { + type = types.str; + default = "10s"; + description = '' + Timeout for trying to get stats from Bind. + ''; + }; + bindVersion = mkOption { + type = types.enum [ "xml.v2" "xml.v3" "auto" ]; + default = "auto"; + description = '' + BIND statistics version. Can be detected automatically. + ''; + }; + bindGroups = mkOption { + type = types.listOf (types.enum [ "server" "view" "tasks" ]); + default = [ "server" "view" ]; + description = '' + List of statistics to collect. Available: [server, view, tasks] + ''; + }; + }; + serviceOpts = { + serviceConfig = { + DynamicUser = true; + ExecStart = '' + ${pkgs.prometheus-bind-exporter}/bin/bind_exporter \ + -web.listen-address ${cfg.listenAddress}:${toString cfg.port} \ + -bind.pid-file /var/run/named/named.pid \ + -bind.timeout ${toString cfg.bindTimeout} \ + -bind.stats-url ${cfg.bindURI} \ + -bind.stats-version ${cfg.bindVersion} \ + -bind.stats-groups ${concatStringsSep "," cfg.bindGroups} \ + ${concatStringsSep " \\\n " cfg.extraFlags} + ''; + }; + }; +} diff --git a/nixos/modules/services/networking/shairport-sync.nix b/nixos/modules/services/networking/shairport-sync.nix index 90c0689dc7b..68e005ab81d 100644 --- a/nixos/modules/services/networking/shairport-sync.nix +++ b/nixos/modules/services/networking/shairport-sync.nix @@ -27,7 +27,7 @@ in }; arguments = mkOption { - default = "-v pulse"; + default = "-v -o pa"; description = '' Arguments to pass to the daemon. Defaults to a local pulseaudio server. diff --git a/nixos/modules/services/networking/ssh/sshd.nix b/nixos/modules/services/networking/ssh/sshd.nix index 5fab79f1b3d..90d08ca3131 100644 --- a/nixos/modules/services/networking/ssh/sshd.nix +++ b/nixos/modules/services/networking/ssh/sshd.nix @@ -352,6 +352,10 @@ in path = [ cfgc.package pkgs.gawk ]; environment.LD_LIBRARY_PATH = nssModulesPath; + restartTriggers = optionals (!cfg.startWhenNeeded) [ + config.environment.etc."ssh/sshd_config".source + ]; + preStart = '' # Make sure we don't write to stdout, since in case of @@ -387,6 +391,7 @@ in Restart = "always"; Type = "simple"; }); + }; in diff --git a/nixos/modules/services/x11/display-managers/default.nix b/nixos/modules/services/x11/display-managers/default.nix index 047321bd949..0e87e6adbab 100644 --- a/nixos/modules/services/x11/display-managers/default.nix +++ b/nixos/modules/services/x11/display-managers/default.nix @@ -191,7 +191,9 @@ let '') names} ${concatMapStrings (pkg: '' - ${xorg.lndir}/bin/lndir ${pkg}/share/xsessions $out/share/xsessions + if test -d ${pkg}/share/xsessions; then + ${xorg.lndir}/bin/lndir ${pkg}/share/xsessions $out/share/xsessions + fi '') cfg.displayManager.extraSessionFilePackages} diff --git a/nixos/modules/tasks/cpu-freq.nix b/nixos/modules/tasks/cpu-freq.nix index 684c43a1e90..513382936e4 100644 --- a/nixos/modules/tasks/cpu-freq.nix +++ b/nixos/modules/tasks/cpu-freq.nix @@ -4,44 +4,49 @@ with lib; let cpupower = config.boot.kernelPackages.cpupower; - cfg = config.powerManagement.cpufreq; + cfg = config.powerManagement; in { ###### interface - options.powerManagement.cpufreq = { + options.powerManagement = { - governor = mkOption { + # TODO: This should be aliased to powerManagement.cpufreq.governor. + # https://github.com/NixOS/nixpkgs/pull/53041#commitcomment-31825338 + cpuFreqGovernor = mkOption { type = types.nullOr types.str; default = null; example = "ondemand"; description = '' Configure the governor used to regulate the frequence of the available CPUs. By default, the kernel configures the - performance governor, although this may be overwriten in your + performance governor, although this may be overwritten in your hardware-configuration.nix file. Often used values: "ondemand", "powersave", "performance" ''; }; - max = mkOption { - type = types.nullOr types.ints.unsigned; - default = null; - example = 2200000; - description = '' - The maximum frequency the CPU will use. Defaults to the maximum possible. - ''; - }; + cpufreq = { - min = mkOption { - type = types.nullOr types.ints.unsigned; - default = null; - example = 800000; - description = '' - The minimum frequency the CPU will use. - ''; + max = mkOption { + type = types.nullOr types.ints.unsigned; + default = null; + example = 2200000; + description = '' + The maximum frequency the CPU will use. Defaults to the maximum possible. + ''; + }; + + min = mkOption { + type = types.nullOr types.ints.unsigned; + default = null; + example = 800000; + description = '' + The minimum frequency the CPU will use. + ''; + }; }; }; @@ -51,16 +56,16 @@ in config = let - governorEnable = cfg.governor != null; - maxEnable = cfg.max != null; - minEnable = cfg.min != null; + governorEnable = cfg.cpuFreqGovernor != null; + maxEnable = cfg.cpufreq.max != null; + minEnable = cfg.cpufreq.min != null; enable = !config.boot.isContainer && (governorEnable || maxEnable || minEnable); in mkIf enable { - boot.kernelModules = optional governorEnable "cpufreq_${cfg.governor}"; + boot.kernelModules = optional governorEnable "cpufreq_${cfg.cpuFreqGovernor}"; environment.systemPackages = [ cpupower ]; @@ -74,9 +79,9 @@ in Type = "oneshot"; RemainAfterExit = "yes"; ExecStart = "${cpupower}/bin/cpupower frequency-set " + - optionalString governorEnable "--governor ${cfg.governor} " + - optionalString maxEnable "--max ${toString cfg.max} " + - optionalString minEnable "--min ${toString cfg.min} "; + optionalString governorEnable "--governor ${cfg.cpuFreqGovernor} " + + optionalString maxEnable "--max ${toString cfg.cpufreq.max} " + + optionalString minEnable "--min ${toString cfg.cpufreq.min} "; SuccessExitStatus = "0 237"; }; }; diff --git a/nixos/tests/prometheus-exporters.nix b/nixos/tests/prometheus-exporters.nix index 5d1e004c5dd..140687a8182 100644 --- a/nixos/tests/prometheus-exporters.nix +++ b/nixos/tests/prometheus-exporters.nix @@ -106,6 +106,25 @@ let ''; }; + bind = { + exporterConfig = { + enable = true; + }; + metricProvider = { + services.bind.enable = true; + services.bind.extraConfig = '' + statistics-channels { + inet 127.0.0.1 port 8053 allow { localhost; }; + }; + ''; + }; + exporterTest = '' + waitForUnit("prometheus-bind-exporter.service"); + waitForOpenPort(9119); + succeed("curl -sSf http://localhost:9119/metrics" | grep -q 'bind_query_recursions_total 0'); + ''; + }; + dovecot = { exporterConfig = { enable = true; |