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

{
  imports = [ ];

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

  config = lib.mkIf (config.me.sm64ex.enable && config.me.graphical) {
    allowedUnfree = [ "sm64ex" ];

    environment.systemPackages = with pkgs; [
      sm64ex
    ];

    # nixpkgs.overlays = [
    #   (final: prev: {
    #     sm4ex = prev.sm64ex.override {
    #       baseRom.name = "SuperMario64.z64";
    #     };
    #   })
    # ];

    nixpkgs.overlays = [
      (final: prev: {
        sm64ex = prev.sm64ex.overrideAttrs (old: {
          buildInputs = old.buildInputs ++ [ final.libGL ];
        });
      })
    ];

    # TODO perhaps install ~/.local/share/sm64ex/sm64config.txt

    environment.persistence."/persist" = lib.mkIf (config.me.mountPersistence) {
      hideMounts = true;
      users.talexander = {
        directories = [
          {
            directory = ".local/share/sm64ex";
            user = "talexander";
            group = "talexander";
            mode = "0755";
          }
        ];
      };
    };
  };
}
