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

{
  imports = [ ];

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

  config = lib.mkIf (config.me.spaghettikart.enable && config.me.graphical) {
    allowedUnfree = [ "spaghettikart" ];
    environment.systemPackages = with pkgs; [
      spaghettikart
    ];

    me.install.user.talexander.file = {
      ".local/share/spaghettikart/spaghettify.cfg.json" = {
        source = ./files/spaghettify.cfg.json;
        method = "overwrite";
      };
    };

    environment.persistence."/persist" = lib.mkIf (config.me.mountPersistence) {
      hideMounts = true;
      users.talexander = {
        files = [
          ".local/share/spaghettikart/default.sav"
          ".local/share/spaghettikart/mk64.o2r"
        ];
      };
    };
  };
}
