anchor.diff:  
     options = {
       services.btrbk = {
  -      extraPackages = lib.mkOption {
  +      extraPackages = mkOption {
           description = "Extra packages for btrbk, like compression utilities for <literal>stream_compress</literal>";
  -        type = lib.types.listOf lib.types.package;
  +        type = types.listOf types.package;
           default = [ ];
  -        example = lib.literalExpression "[ pkgs.xz ]";
  -      };
  -      niceness = lib.mkOption {
  +        example = literalExpression "[ pkgs.xz ]";
  +      };
  +      niceness = mkOption {
           description = "Niceness for local instances of btrbk. Also applies to remote ones connecting via ssh when positive.";
  -        type = lib.types.ints.between (-20) 19;
  +        type = types.ints.between (-20) 19;
           default = 10;
         };
  -      ioSchedulingClass = lib.mkOption {
  +      ioSchedulingClass = mkOption {
           description = "IO scheduling class for btrbk (see ionice(1) for a quick description). Applies to local instances, and remote ones connecting by ssh if set to idle.";
  -        type = lib.types.enum [ "idle" "best-effort" "realtime" ];
  +        type = types.enum [ "idle" "best-effort" "realtime" ];
           default = "best-effort";
         };
  -      instances = lib.mkOption {
  +      instances = mkOption {
           description = "Set of btrbk instances. The instance named <literal>btrbk</literal> is the default one.";
  -        type = with lib.types;
  +        type = with types;
             attrsOf (
               submodule {
                 options = {
  -                onCalendar = lib.mkOption {
  -                  type = lib.types.nullOr lib.types.str;
  +                onCalendar = mkOption {
  +                  type = types.nullOr types.str;
                     default = "daily";
                     description = ''
                       How often this btrbk instance is started. See systemd.time(7) for more information about the format.
                       Setting it to null disables the timer, thus this instance can only be started manually.
                     '';
                   };
  -                settings = lib.mkOption {
  -                  type = let t = lib.types.attrsOf (lib.types.either lib.types.str (t // { description = "instances of this type recursively"; })); in t;
  +                settings = mkOption {
  +                  type = let t = types.attrsOf (types.either types.str (t // { description = "instances of this type recursively"; })); in t;
                     default = { };
                     example = {
                       snapshot_preserve_min = "2d";
  
positive.code: { config, pkgs, lib, ... }:
  let
    cfg = config.services.btrbk;
    sshEnabled = cfg.sshAccess != [ ];
    serviceEnabled = cfg.instances != { };
    attr2Lines = attr:
      let
        pairs = lib.attrsets.mapAttrsToList (name: value: { inherit name value; }) attr;
        isSubsection = value:
          if builtins.isAttrs value then true
          else if builtins.isString value then false
          else throw "invalid type in btrbk config ${builtins.typeOf value}";
        sortedPairs = lib.lists.partition (x: isSubsection x.value) pairs;
      in
      lib.flatten (
        # non subsections go first
        (
          map (pair: [ "${pair.name} ${pair.value}" ]) sortedPairs.wrong
  
negative.code:         (
            v:
            let
              options = concatMapStringsSep " " (x: "--" + x) v.roles;
              ioniceClass = {
                "idle" = 3;
                "best-effort" = 2;
                "realtime" = 1;
              }.${cfg.ioSchedulingClass};
            in
            ''command="${pkgs.util-linux}/bin/ionice -t -c ${toString ioniceClass} ${optionalString (cfg.niceness >= 1) "${pkgs.coreutils}/bin/nice -n ${toString cfg.niceness}"} ${pkgs.btrbk}/share/btrbk/scripts/ssh_filter_btrbk.sh --sudo ${options}" ${v.key}''
          )
          cfg.sshAccess;
      };
  