anchor.diff:  
       jobs.swap =
         { task = true;
  -        
  +
           startOn = ["startup" "new-devices"];
   
           script =
             ''
  +            unused="$(sed '1d; s/ .*//' /proc/swaps)"
  +
               ${toString (map (x: x.command) config.swapDevices)}
   
  -            # Remove swap devices not listed in swapDevices.
  -            for used in $(cat /proc/swaps | grep '^/' | sed 's/ .*//'); do
  -                found=
  -                for device in $swapDevices; do
  -                    device=$(readlink -f $device)
  -                    if test "$used" = "$device"; then found=1; fi
  -                done
  -                if test -z "$found"; then
  -                    ${utillinux}/sbin/swapoff "$used" || true
  -                fi
  -            done
  +            # Remove remaining swap devices.
  +            test -n "$unused" && ${utillinux}/sbin/swapoff $unused || true
             '';
         };
   
  
positive.code:     };
  
    };
    
  
    ###### implementation
  
  
negative.code:           command = ''
              if test -e "${config.device}"; then
                ${if config.cipher then ''
                    plainDevice="${config.device}"
                    name="crypt$(echo "$plainDevice" | sed -e 's,/,.,g')"
                    device="/dev/mapper/$name"
                    if ! test -e "$device"; then
                      ${cryptsetup}/sbin/cryptsetup -c aes -s 128 -d /dev/urandom create "$name" "$plainDevice"
                      ${utillinux}/sbin/mkswap -f "$device" || true
                    fi
                  ''
                  else ''
                    device="${config.device}"
                  ''
                }
                # Add new swap devices.
                if echo $unused | grep -q "^$device\$"; then
                  unused="$(echo $unused | grep -v "^$device\$")"
                else
                  ${utillinux}/sbin/swapon "$device" || true
                fi
              fi
            '';
          };
  