Help with failed to build on file shared between nixos and darwin

I have the following file that set some options only for linux as darwin doest have the attributes:

{
  lib,
  config,
  pkgs,
  myvars,
  ...
}:
let
  cfg = config.modules.matrix;
  inherit (pkgs.stdenv) isDarwin;
in
{
  options.modules.matrix = {
    enable = lib.mkEnableOption "enable matrix module";
    pkg = lib.mkPackageOption pkgs "weechat" { };
  };

  config = lib.mkIf cfg.enable (
    lib.mkMerge [
      {
        environment.systemPackages = [
          cfg.pkg
          pkgs.element-desktop
        ];
      }
      (lib.mkIf (!isDarwin) {
        services.weechat.enable = lib.mkDefault true;
        programs.screen.screenrc = ''
          multiuser on
          acladd ${myvars.username}
          term screen-256color
        '';
      })
    ]
  );
}

But even with the if blocks the i still get the error programs.screen does not exist when i try to build on darwin. what do i do?

Make separate modules for nixos vs darwin.
The option declarations could of course be in a shared module, but optional settings based on hostname, platform, etc are not really maintainable.