···5454 */
5555 void gitCheckout(File dir, String ref, BuildOutputListener listener) throws IOException;
56565757+ // --- Baserom management ---
5858+5959+ /**
6060+ * Installs the base ROM into /tmp as papermario.us.z64 and adds it to the Nix store.
6161+ * @param sourceRom The source ROM file to install
6262+ * @throws BuildException If the installation fails
6363+ * @throws IOException If an I/O error occurs
6464+ */
6565+ void installBaserom(File sourceRom) throws BuildException, IOException;
6666+5767 // --- Build operations ---
58685969 /**
-12
src/main/java/project/engine/Engine.java
···1818{
1919 private static final String BARE_REPO_NAME = "papermario-dx.git";
2020 private static final String REPO_URL = "https://github.com/bates64/papermario-dx.git";
2121- private static final String BASEROM_PATH = "ver/us/baserom.z64";
2222- private static final String DUMP_PATH = "ver/us/build/star-rod-dump";
23212422 /** If a project provides a custom engine, it should be a git repo at this directory. */
2523 public static final String PROJECT_ENGINE_PATH = "papermario-dx";
···8785 public File getDirectory()
8886 {
8987 return directory;
9090- }
9191-9292- public File getBaseRom()
9393- {
9494- return new File(directory, BASEROM_PATH);
9595- }
9696-9797- public File getDumpDir()
9898- {
9999- return new File(directory, DUMP_PATH);
10088 }
1018910290 public String getRef()
+41
src/main/java/project/engine/NixEnvironment.java
···6262 }
6363 }
64646565+ // --- Baserom management ---
6666+6767+ @Override
6868+ public void installBaserom(File sourceRom) throws BuildException, IOException
6969+ {
7070+ if (!sourceRom.exists()) {
7171+ throw new IOException("Source ROM does not exist: " + sourceRom);
7272+ }
7373+7474+ // Check if ROM is already in Nix store
7575+ String expectedHash = "9ec6d2a5c2fca81ab86312328779fd042b5f3b920bf65df9f6b87b376883cb5b";
7676+ String[] checkCmd = new String[] {
7777+ "bash", "-c",
7878+ "test -e $(nix-store --print-fixed-path sha256 " + expectedHash + " papermario.us.z64)"
7979+ };
8080+8181+ ProcessRunner.ProcessResult checkResult = runner.run(checkCmd, null, BuildOutputListener.toLogger());
8282+ if (checkResult.isSuccess()) {
8383+ return; // Already in store
8484+ }
8585+8686+ File targetRom = new File("/tmp/papermario.us.z64");
8787+8888+ // Copy ROM to /tmp
8989+ java.nio.file.Files.copy(
9090+ sourceRom.toPath(),
9191+ targetRom.toPath(),
9292+ java.nio.file.StandardCopyOption.REPLACE_EXISTING
9393+ );
9494+9595+ // Add to Nix store
9696+ String[] cmd = new String[] {
9797+ "nix-store", "--add-fixed", "sha256", targetRom.getAbsolutePath()
9898+ };
9999+100100+ ProcessRunner.ProcessResult result = runner.run(cmd, null, BuildOutputListener.toLogger());
101101+ if (!result.isSuccess()) {
102102+ throw new BuildException("Failed to add ROM to Nix store (exit code " + result.getExitCode() + ")");
103103+ }
104104+ }
105105+65106 // --- Build operations ---
6610767108 @Override