2021-07-11 19:28:56 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.programs.sm64ex;
|
|
|
|
|
|
|
|
# This is required for tests, we cannot overwrite the dummy package.
|
|
|
|
package = if cfg.region == null && cfg.baserom == null
|
|
|
|
&& cfg.extraCompileFlags == null then
|
|
|
|
cfg.package
|
|
|
|
|
|
|
|
else
|
|
|
|
cfg.package.override (attrs:
|
|
|
|
{ } // optionalAttrs (cfg.region != null) { region = cfg.region; }
|
|
|
|
// optionalAttrs (cfg.baserom != null) { baseRom = cfg.baserom; }
|
|
|
|
// optionalAttrs (cfg.extraCompileFlags != null) {
|
|
|
|
compileFlags = cfg.extraCompileFlags;
|
|
|
|
});
|
|
|
|
|
|
|
|
mkConfig = key: value:
|
|
|
|
let
|
|
|
|
generatedValue = if isBool value then
|
|
|
|
(if value then "true" else "false")
|
|
|
|
else if isList value then
|
|
|
|
concatStringsSep " " value
|
|
|
|
else
|
|
|
|
toString value;
|
|
|
|
in "${key} ${generatedValue}";
|
|
|
|
|
|
|
|
in {
|
2024-07-03 09:39:20 +02:00
|
|
|
meta.maintainers = [ ];
|
2021-07-11 19:28:56 +02:00
|
|
|
|
|
|
|
options.programs.sm64ex = {
|
2023-07-02 01:45:18 +02:00
|
|
|
enable = mkEnableOption "sm64ex";
|
2021-07-11 19:28:56 +02:00
|
|
|
|
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.sm64ex;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "The sm64ex package to use.";
|
2021-07-11 19:28:56 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
region = mkOption {
|
|
|
|
type = types.nullOr (types.enum [ "us" "eu" "jp" ]);
|
|
|
|
default = null;
|
|
|
|
defaultText =
|
2021-10-09 11:14:08 +02:00
|
|
|
literalExpression "us"; # This is set both in nixpkgs and upstream
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2021-07-11 19:28:56 +02:00
|
|
|
Your baserom's region. Note that only "us", "eu", and "jp" are supported.
|
|
|
|
'';
|
2021-10-09 11:14:08 +02:00
|
|
|
example = literalExpression "jp";
|
2021-07-11 19:28:56 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
baserom = mkOption {
|
|
|
|
type = types.nullOr types.path;
|
|
|
|
default = null;
|
2023-07-02 01:45:18 +02:00
|
|
|
description =
|
2021-07-11 19:28:56 +02:00
|
|
|
"The path to the Super Mario 64 baserom to extract assets from.";
|
2021-10-09 11:14:08 +02:00
|
|
|
example = literalExpression "/home/foo/baserom.us.z64";
|
2021-07-11 19:28:56 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
extraCompileFlags = mkOption {
|
|
|
|
type = with types; nullOr (listOf str);
|
|
|
|
default = null;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2021-07-11 19:28:56 +02:00
|
|
|
Extra flags to pass to the compiler. See
|
2023-07-01 01:30:13 +02:00
|
|
|
<https://github.com/sm64pc/sm64ex/wiki/Build-options>
|
2021-07-11 19:28:56 +02:00
|
|
|
for more information.
|
|
|
|
'';
|
2021-10-09 11:14:08 +02:00
|
|
|
example = literalExpression ''
|
2021-07-11 19:28:56 +02:00
|
|
|
[
|
|
|
|
"BETTERCAMERA=1"
|
|
|
|
"NODRAWINGDISTANCE=1"
|
|
|
|
];
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
settings = mkOption {
|
|
|
|
type = with types;
|
|
|
|
nullOr (attrsOf (either str (either int (either bool (listOf str)))));
|
|
|
|
default = null;
|
2023-07-02 01:45:18 +02:00
|
|
|
description =
|
2023-07-01 01:30:13 +02:00
|
|
|
"Settings for sm64ex's {file}`$XDG_DATA_HOME/sm64pc/sm64config.txt` file.";
|
2021-10-09 11:14:08 +02:00
|
|
|
example = literalExpression ''
|
2021-07-11 19:28:56 +02:00
|
|
|
{
|
|
|
|
fullscreen = false;
|
|
|
|
window_x = 0;
|
|
|
|
window_y = 0;
|
|
|
|
window_w = 1920;
|
|
|
|
window_h = 1080;
|
|
|
|
vsync = 1;
|
|
|
|
texture_filtering = 1;
|
|
|
|
master_volume = 127;
|
|
|
|
music_volume = 127;
|
|
|
|
sfx_volume = 127;
|
|
|
|
env_volume = 127;
|
|
|
|
key_a = [ "0026" "1000" "1103" ];
|
|
|
|
key_b = [ "0033" "1002" "1101" ];
|
|
|
|
key_start = [ "0039" "1006" "ffff" ];
|
|
|
|
key_l = [ "0034" "1007" "1104" ];
|
|
|
|
key_r = [ "0036" "100a" "1105" ];
|
|
|
|
key_z = [ "0025" "1009" "1102" ];
|
|
|
|
key_cup = [ "100b" "ffff" "ffff" ];
|
|
|
|
key_cdown = [ "100c" "ffff" "ffff" ];
|
|
|
|
key_cleft = [ "100d" "ffff" "ffff" ];
|
|
|
|
key_cright = [ "100e" "ffff" "ffff" ];
|
|
|
|
key_stickup = [ "0011" "ffff" "ffff" ];
|
|
|
|
key_stickdown = [ "001f" "ffff" "ffff" ];
|
|
|
|
key_stickleft = [ "001e" "ffff" "ffff" ];
|
|
|
|
key_stickright = [ "0020" "ffff" "ffff" ];
|
|
|
|
stick_deadzone = 16;
|
|
|
|
rumble_strength = 10;
|
|
|
|
skip_intro = 1;
|
|
|
|
};
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = let
|
|
|
|
configFile = optionals (cfg.settings != null)
|
|
|
|
(concatStringsSep "\n" ((mapAttrsToList mkConfig cfg.settings)));
|
|
|
|
in mkIf cfg.enable {
|
|
|
|
home.packages = [ package ];
|
|
|
|
|
|
|
|
xdg.dataFile."sm64pc/sm64config.txt" =
|
|
|
|
mkIf (cfg.settings != null) { text = configFile; };
|
|
|
|
};
|
|
|
|
}
|