anchor.diff:  
       environment.systemPackages = [ tlp ];
   
  -    # FIXME: When the config is parametrized we need to move these into a
  -    # conditional on the relevant options being enabled.
  -    powerManagement = {
  -      scsiLinkPolicy = null;
  -      cpuFreqGovernor = null;
  -      cpufreq.max = null;
  -      cpufreq.min = null;
  +
  +    services.tlp.settings = let
  +      cfg = config.powerManagement;
  +      maybeDefault = val: lib.mkIf (val != null) (lib.mkDefault val);
  +    in {
  +      CPU_SCALING_GOVERNOR_ON_AC = maybeDefault cfg.cpuFreqGovernor;
  +      CPU_SCALING_GOVERNOR_ON_BAT = maybeDefault cfg.cpuFreqGovernor;
  +      CPU_SCALING_MIN_FREQ_ON_AC = maybeDefault cfg.cpufreq.min;
  +      CPU_SCALING_MAX_FREQ_ON_AC = maybeDefault cfg.cpufreq.max;
  +      CPU_SCALING_MIN_FREQ_ON_BAT = maybeDefault cfg.cpufreq.min;
  +      CPU_SCALING_MAX_FREQ_ON_BAT = maybeDefault cfg.cpufreq.max;
       };
   
       services.udev.packages = [ tlp ];
   
       systemd = {
  +      # use native tlp instead because it can also differentiate between AC/BAT
  +      services.cpufreq.enable = false;
  +
         packages = [ tlp ];
         # XXX: These must always be disabled/masked according to [1].
         #
  
positive.code:   config = mkIf cfg.enable {
      boot.kernelModules = [ "msr" ];
  
      environment.etc = {
        "tlp.conf".text = cfg.extraConfig;
      } // optionalAttrs enableRDW {
        "NetworkManager/dispatcher.d/99tlp-rdw-nm".source =
          "${tlp}/etc/NetworkManager/dispatcher.d/99tlp-rdw-nm";
  
negative.code:   mkTlpConfig = tlpConfig: generators.toKeyValue {
      mkKeyValue = generators.mkKeyValueDefault {
        mkValueString = val:
          if isList val then "\"" + (toString val) + "\""
          else toString val;
      } "=";
    } tlpConfig;
  in
  