nixos/btrbk: Add required stream_compress packages

Changed files
+51 -5
nixos
doc
manual
release-notes
modules
services
backup
tests
+5
nixos/doc/manual/release-notes/rl-2405.section.md
···
- The `hardware.pulseaudio` module now sets permission of pulse user home directory to 755 when running in "systemWide" mode. It fixes [issue 114399](https://github.com/NixOS/nixpkgs/issues/114399).
+
- The `btrbk` module now automatically selects and provides required compression
+
program depending on the configured `stream_compress` option. Since this
+
replaces the need for the `extraPackages` option, this option will be
+
deprecated in future releases.
+
- QtMultimedia has changed its default backend to `QT_MEDIA_BACKEND=ffmpeg` (previously `gstreamer` on Linux or `darwin` on MacOS).
The previous native backends remain available but are now minimally maintained. Refer to [upstream documentation](https://doc.qt.io/qt-6/qtmultimedia-index.html#ffmpeg-as-the-default-backend) for further details about each platform.
+46 -4
nixos/modules/services/backup/btrbk.nix
···
concatMapStringsSep
concatStringsSep
filterAttrs
+
flatten
+
getAttr
isAttrs
literalExpression
mapAttrs'
mapAttrsToList
mkIf
mkOption
+
optional
optionalString
sort
types
···
'';
};
+
streamCompressMap = {
+
gzip = pkgs.gzip;
+
pigz = pkgs.pigz;
+
bzip2 = pkgs.bzip2;
+
pbzip2 = pkgs.pbzip2;
+
bzip3 = pkgs.bzip3;
+
xz = pkgs.xz;
+
lzo = pkgs.lzo;
+
lz4 = pkgs.lz4;
+
zstd = pkgs.zstd;
+
};
+
cfg = config.services.btrbk;
sshEnabled = cfg.sshAccess != [ ];
serviceEnabled = cfg.instances != { };
···
options = {
services.btrbk = {
extraPackages = mkOption {
-
description = lib.mdDoc "Extra packages for btrbk, like compression utilities for `stream_compress`";
+
description = lib.mdDoc ''
+
Extra packages for btrbk, like compression utilities for `stream_compress`.
+
+
**Note**: This option will get deprecated in future releases.
+
Required compression programs will get automatically provided to btrbk
+
depending on configured compression method in
+
`services.btrbk.instances.<name>.settings` option.
+
'';
type = types.listOf types.package;
default = [ ];
example = literalExpression "[ pkgs.xz ]";
···
'';
};
settings = mkOption {
-
type = let t = types.attrsOf (types.either types.str (t // { description = "instances of this type recursively"; })); in t;
+
type = types.submodule {
+
freeformType = let t = types.attrsOf (types.either types.str (t // { description = "instances of this type recursively"; })); in t;
+
options = {
+
stream_compress = mkOption {
+
description = lib.mdDoc ''
+
Compress the btrfs send stream before transferring it from/to remote locations using a
+
compression command.
+
'';
+
type = types.enum ["gzip" "pigz" "bzip2" "pbzip2" "bzip3" "xz" "lzo" "lz4" "zstd" "no"];
+
default = "no";
+
};
+
};
+
};
default = { };
example = {
snapshot_preserve_min = "2d";
···
};
config = mkIf (sshEnabled || serviceEnabled) {
+
+
warnings = optional (cfg.extraPackages != []) ''
+
extraPackages option will be deprecated in future releases. Programs required for compression are now automatically selected depending on services.btrbk.instances.<name>.settings.stream_compress option.
+
'';
+
environment.systemPackages = [ pkgs.btrbk ] ++ cfg.extraPackages;
security.sudo.extraRules = mkIf (sudo_doas == "sudo") [ sudoRule ];
···
cfg.instances;
systemd.services = mapAttrs'
(
-
name: _: {
+
name: instance: {
name = "btrbk-${name}";
value = {
description = "Takes BTRFS snapshots and maintains retention policies.";
unitConfig.Documentation = "man:btrbk(1)";
-
path = [ "/run/wrappers" ] ++ cfg.extraPackages;
+
path = [ "/run/wrappers" ]
+
++ cfg.extraPackages
+
++ optional (instance.settings.stream_compress != "no")
+
(getAttr instance.settings.stream_compress streamCompressMap);
serviceConfig = {
User = "btrbk";
Group = "btrbk";
-1
nixos/tests/btrbk.nix
···
# don't do it with real ssh keys.
environment.etc."btrbk_key".text = privateKey;
services.btrbk = {
-
extraPackages = [ pkgs.lz4 ];
instances = {
remote = {
onCalendar = "minutely";