{
  config,
  lib,
  pkgs,
  ...
}:

{
  imports = [ ];

  options.me = {
    chromium.enable = lib.mkOption {
      type = lib.types.bool;
      default = false;
      example = true;
      description = "Whether we want to install chromium.";
    };
  };

  config = lib.mkIf (config.me.chromium.enable && config.me.graphical) {
    environment.systemPackages = with pkgs; [
      chromium
    ];
    allowedUnfree = [
      "chromium"
      "chromium-unwrapped"
      "widevine-cdm"
    ];

    environment.persistence."/persist" = lib.mkIf (config.me.mountPersistence) {
      hideMounts = true;
      users.talexander = {
        directories = [
          {
            directory = ".config/chromium";
            user = "talexander";
            group = "talexander";
            mode = "0700";
          }
        ];
      };
    };
    environment.persistence."/state" = lib.mkIf (config.me.mountPersistence) {
      hideMounts = true;
      users.talexander = {
        directories = [
          {
            directory = ".cache/chromium";
            user = "talexander";
            group = "talexander";
            mode = "0700";
          }
        ];
      };
    };

    nixpkgs.overlays = [
      (final: prev: {
        chromium = prev.chromium.override {
          enableWideVine = true;
          commandLineArgs = [
            "--enable-features=VaapiVideoDecoder,VaapiIgnoreDriverChecks,Vulkan,DefaultANGLEVulkan,VulkanFromANGLE,AcceleratedVideoEncoder"
            # Enabling vulkan causes video to render as white
            # "--enable-features=Vulkan";
          ];
        };
      })
    ];
  };
}
