diff --git a/pkgs/by-name/sm/sm64baserom/package.nix b/pkgs/by-name/sm/sm64baserom/package.nix new file mode 100644 index 000000000000..ad886cfdb73a --- /dev/null +++ b/pkgs/by-name/sm/sm64baserom/package.nix @@ -0,0 +1,39 @@ +{ + requireFile, + runCommand, + + region ? "us", + showRegionMessage ? true, +}: +# nixpkgs assumes that a file derivation is a setup script and tries to load it, so we have to put this in a directory +let + file = requireFile { + name = "baserom.${region}.z64"; + message = '' + This nix expression requires that baserom.${region}.z64 is + already part of the store. To get this file you can dump your Super Mario 64 cartridge's contents + and add it to the nix store with nix-store --add-fixed sha256 . + ${ + if showRegionMessage then + ''Note that if you are not using a US baserom, you must overwrite the "region" attribute with either "eu" or "jp".'' + else + "" + } + ''; + sha256 = + { + "us" = "17ce077343c6133f8c9f2d6d6d9a4ab62c8cd2aa57c40aea1f490b4c8bb21d91"; + "eu" = "c792e5ebcba34c8d98c0c44cf29747c8ee67e7b907fcc77887f9ff2523f80572"; + "jp" = "9cf7a80db321b07a8d461fe536c02c87b7412433953891cdec9191bfad2db317"; + } + .${region}; + }; + result = runCommand "baserom-${region}-safety-dir" { } '' + mkdir $out + ln -s ${file} $out/${file.name} + ''; +in +result +// { + romPath = "${result.outPath}/${file.name}"; +} diff --git a/pkgs/games/sm64ex/coop.nix b/pkgs/games/sm64ex/coop.nix index 742f41cea361..f1a01664f7dc 100644 --- a/pkgs/games/sm64ex/coop.nix +++ b/pkgs/games/sm64ex/coop.nix @@ -1,8 +1,9 @@ -{ callPackage -, fetchFromGitHub -, autoPatchelfHook -, zlib -, stdenvNoCC +{ + callPackage, + fetchFromGitHub, + autoPatchelfHook, + zlib, + stdenvNoCC, }: callPackage ./generic.nix { @@ -16,13 +17,9 @@ callPackage ./generic.nix { sha256 = "sha256-iwJsq0FN9npxveIoMiB7zL5j1V72IExtEpzGj6lwLXQ="; }; - extraNativeBuildInputs = [ - autoPatchelfHook - ]; + extraNativeBuildInputs = [ autoPatchelfHook ]; - extraBuildInputs = [ - zlib - ]; + extraBuildInputs = [ zlib ]; postInstall = let diff --git a/pkgs/games/sm64ex/default.nix b/pkgs/games/sm64ex/default.nix index 17fcfdd131ac..8068f522482f 100644 --- a/pkgs/games/sm64ex/default.nix +++ b/pkgs/games/sm64ex/default.nix @@ -1,9 +1,8 @@ -{ callPackage -, branch -}: +{ callPackage, branch }: { sm64ex = callPackage ./sm64ex.nix { }; sm64ex-coop = callPackage ./coop.nix { }; -}.${branch} +} +.${branch} diff --git a/pkgs/games/sm64ex/generic.nix b/pkgs/games/sm64ex/generic.nix index fd53b78042f5..b7f38686fe20 100644 --- a/pkgs/games/sm64ex/generic.nix +++ b/pkgs/games/sm64ex/generic.nix @@ -1,39 +1,33 @@ -{ pname -, version -, src -, extraNativeBuildInputs ? [ ] -, extraBuildInputs ? [ ] -, extraMeta ? { } -, compileFlags ? [ ] -, postInstall ? "" -, region ? "us" +{ + pname, + version, + src, + extraNativeBuildInputs ? [ ], + extraBuildInputs ? [ ], + extraMeta ? { }, + compileFlags ? [ ], + postInstall ? "", + region ? "us", -, lib -, stdenv -, python3 -, pkg-config -, audiofile -, SDL2 -, hexdump -, requireFile -, baseRom ? requireFile { - name = "baserom.${region}.z64"; - message = '' - This nix expression requires that baserom.${region}.z64 is - already part of the store. To get this file you can dump your Super Mario 64 cartridge's contents - and add it to the nix store with nix-store --add-fixed sha256 . - Note that if you are not using a US baserom, you must overwrite the "region" attribute with either "eu" or "jp". - ''; - sha256 = { - "us" = "17ce077343c6133f8c9f2d6d6d9a4ab62c8cd2aa57c40aea1f490b4c8bb21d91"; - "eu" = "c792e5ebcba34c8d98c0c44cf29747c8ee67e7b907fcc77887f9ff2523f80572"; - "jp" = "9cf7a80db321b07a8d461fe536c02c87b7412433953891cdec9191bfad2db317"; - }.${region}; - } + lib, + stdenv, + python3, + pkg-config, + audiofile, + SDL2, + hexdump, + sm64baserom, }: - +let + baseRom = (sm64baserom.override { inherit region; }).romPath; +in stdenv.mkDerivation rec { - inherit pname version src postInstall; + inherit + pname + version + src + postInstall + ; nativeBuildInputs = [ python3 @@ -48,11 +42,14 @@ stdenv.mkDerivation rec { enableParallelBuilding = true; - makeFlags = [ - "VERSION=${region}" - ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ - "OSX_BUILD=1" - ] ++ compileFlags; + makeFlags = + [ + "VERSION=${region}" + ] + ++ lib.optionals stdenv.hostPlatform.isDarwin [ + "OSX_BUILD=1" + ] + ++ compileFlags; preBuild = '' patchShebangs extract_assets.py @@ -68,16 +65,20 @@ stdenv.mkDerivation rec { runHook postInstall ''; - meta = with lib; { - longDescription = - extraMeta.description or "Super Mario 64 port based off of decompilation" + "\n" + '' + meta = + with lib; + { + longDescription = '' + ${extraMeta.description or "Super Mario 64 port based off of decompilation"} + Note that you must supply a baserom yourself to extract assets from. If you are not using an US baserom, you must overwrite the "region" attribute with either "eu" or "jp". If you would like to use patches sm64ex distributes as makeflags, add them to the "compileFlags" attribute. ''; - mainProgram = "sm64ex"; - license = licenses.unfree; - maintainers = [ ]; - platforms = platforms.unix; - } // extraMeta; + mainProgram = "sm64ex"; + license = licenses.unfree; + maintainers = [ ]; + platforms = platforms.unix; + } + // extraMeta; } diff --git a/pkgs/games/sm64ex/sm64ex.nix b/pkgs/games/sm64ex/sm64ex.nix index ddac79697c6f..89c2ca5821dd 100644 --- a/pkgs/games/sm64ex/sm64ex.nix +++ b/pkgs/games/sm64ex/sm64ex.nix @@ -1,6 +1,4 @@ -{ callPackage -, fetchFromGitHub -}: +{ callPackage, fetchFromGitHub }: callPackage ./generic.nix { pname = "sm64ex"; @@ -18,4 +16,3 @@ callPackage ./generic.nix { description = "Super Mario 64 port based off of decompilation"; }; } -