anchor.diff:      )
     ;
     addDefaults = settings: { backend = "btrfs-progs-sudo"; } // settings;
  -  mkConfigFile = settings: lib.concatStringsSep "\n" (attr2Lines (addDefaults settings));
  +  mkConfigFile = settings: concatStringsSep "\n" (attr2Lines (addDefaults settings));
     mkTestedConfigFile = name: settings:
       let
         configFile = pkgs.writeText "btrbk-${name}.conf" (mkConfigFile settings);
  
positive.code:           };
          }
        )
        (lib.filterAttrs (name: instance: instance.onCalendar != null)
          cfg.instances);
    };
  
  
negative.code: { config, pkgs, lib, ... }:
  let
    inherit (lib)
      concatMapStringsSep
      concatStringsSep
      filterAttrs
      flatten
      isAttrs
      isString
      literalExpression
      mapAttrs'
      mapAttrsToList
      mkIf
      mkOption
      optionalString
      partition
      typeOf
      types
      ;
  
    cfg = config.services.btrbk;
    sshEnabled = cfg.sshAccess != [ ];
    serviceEnabled = cfg.instances != { };
    attr2Lines = attr:
      let
        pairs = mapAttrsToList (name: value: { inherit name value; }) attr;
        isSubsection = value:
          if isAttrs value then true
          else if isString value then false
          else throw "invalid type in btrbk config ${typeOf value}";
        sortedPairs = partition (x: isSubsection x.value) pairs;
      in
      flatten (
        # non subsections go first
        (
          map (pair: [ "${pair.name} ${pair.value}" ]) sortedPairs.wrong
  