Infinidoge / nix-minecraft

An attempt to better support Minecraft-related content for the Nix ecosystem
MIT License
234 stars 23 forks source link

error: hash mismatch in fixed-output derivation #82

Closed Vartroc closed 1 month ago

Vartroc commented 1 month ago

I have been trying to install mods for two days now, but I can't seem to get it right, so I ask here for help, because I don't have any ideas left.

Files

Steps I already did:

Vartroc commented 1 month ago

I think it has to do with me getting the wrong hash. But how do I get the right hash then? nix-prefetch-url doesn't work wget -O pack.toml https://raw.githubusercontent.com/Vartroc/hexamods/main/pack.toml and then sha256sum pack.toml doesn't work. I can't find anything relating that in the documentation as well...

Infinidoge commented 1 month ago

Change hash to packHash in the fetchPackwizModpack call. I'm... not quite sure why it's packHash, I suppose because it's not the hash of the final output and instead the hash of an input file.

Also by the way, you don't need to put the minecraft server in systemPackages, unless you intend to run it outside of the systemd unit.

Vartroc commented 1 month ago

Change hash to packHash in the fetchPackwizModpack call. I'm... not quite sure why it's packHash, I suppose because it's not the hash of the final output and instead the hash of an input file.

I have realized that yesterday evening, but was too tired to update you. I now redid my whole packwiz modpack (first one was just for testing purposes), pushed it to another repo, but now, when I rebuild, it says Side changed: invalidating all mods before aborting the process and giving me this error:

error: builder for '/nix/store/mkpbxlrk4dmn5dcsafgm4cf542x3ygk8-packwiz-pack-.drv' failed with exit code 1;
       last 10 log lines:
       >  at link.infra.packwiz.installer.UpdateManager.<init>(SourceFile:42)
       >    at link.infra.packwiz.installer.Main.startup(SourceFile:112)
       >   at link.infra.packwiz.installer.Main.<init>(SourceFile:154)
       >    at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62)
       >         at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502)
       >         at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:486)
       >   at link.infra.packwiz.installer.bootstrap.LoadJAR.start(LoadJAR.java:51)
       >       at link.infra.packwiz.installer.bootstrap.Main.<init>(Main.java:73)
       >    at link.infra.packwiz.installer.bootstrap.Main.main(Main.java:46)
       > Update cancelled by user!
       For full logs, run 'nix log /nix/store/mkpbxlrk4dmn5dcsafgm4cf542x3ygk8-packwiz-pack-.drv'.
error: 1 dependencies of derivation '/nix/store/821h0i0iw2aq5363zlrv6mc12fbvab6s-minecraft-server-hexagon-symlinks.drv' failed to build
error: 1 dependencies of derivation '/nix/store/z7qi7jw7563vi28hxdsb2ynzngb508vr-unit-script-minecraft-server-hexagon-pre-start.drv' failed to build
error: 1 dependencies of derivation '/nix/store/1aff0khb7l8919b1n7gs9szlch9g8gq7-unit-minecraft-server-hexagon.service.drv' failed to build
error: 1 dependencies of derivation '/nix/store/qf6yagk3629qc1hgc2sgvmwsymryk96l-system-units.drv' failed to build
error: 1 dependencies of derivation '/nix/store/f1g5fwgpkyyh79v4r97xlggyqp743yjz-etc.drv' failed to build
error: 1 dependencies of derivation '/nix/store/b2rdiv7k68n5rg2zs74z22dwq45y8av9-nixos-system-Gartroc-24.11.20240709.feb2849.drv' failed to build

I have already deleted my old repo (didn't want to deal with merge issues) and created a new one so the url stays the same, but I still get the same error. I tried deleting the whole /srv/minecraft but that didn't do anything either.

P.S.: how do I get the correct hash for the fetchPackwizModpack.packHash? Until now, I got it from the error, where it told me the hash it was expecting, but that's not what the purpose of a hash is supposed to be...

Infinidoge commented 1 month ago

Believe it or not getting it from the error is generally the easiest and most common way in the Nix ecosystem lol. It's easier than creating a whole prefetch tool for every new kind of fixed output derivation, though that would be preferred to have one. I don't know off of the top of my head what a prefetch process for a packwiz pack is, since I don't currently use it for any servers.

With regards to the error, could you put the full builder log on a pastebin?

Vartroc commented 1 month ago

https://paste.gg/p/anonymous/7ff41ca8a9944afa918c962d396c7f0b I think you meant that?

Vartroc commented 1 month ago

So after troubleshooting a bit, I have found something out. When I try to rebuild using a packwiz repo that only contains one mod (Immersive Aircraft), everything works fine. If I now try to import the BetterMC2 curseforge modpack, create a repo, and and change the url to the git repo I just created (with the BMC2 Modpack) it doesn't work. This indicates, that either packwiz or nix-minecraft has a problem with BetterMC...

Vartroc commented 1 month ago

So I did some more troubleshooting, and I have got to say, I'm confused as f***: I tried some other modpack from curseforge and none I've tried worked (https://www.curseforge.com/minecraft/modpacks/fantasy-minecraft-fabric/download/5484909 and some other, that I forgot the name of) After that, I tried shaving off different part of the mods, didn't do anything even with just the pack.tom. and index.toml left. only when I made a new directory, did packwiz init and copied the resulting pack.toml and index.toml to my original repo did it work. My only guess is that some copywright thing or something that is stored in the hash the pack from building prevents, giving me a user interruption and breaking the whole nix-minecraft thing...

Vartroc commented 1 month ago

And even more troubleshooting... I had the idea of starting with a normal packwiz repo and then gradually moving files from the other one over, while tracking everything with git. Well so I did:

Do you see anything suspicous?

Infinidoge commented 1 month ago

Ah, you're getting mods from CurseForge. I'm pretty sure the problem is CurseForge itself, then. Because of petty and greed reasons, CurseForge made it so mods and opt-out of being downloadable via an API. If my reading of the original error log is correct, it's failing because of trying to download some mods that aren't allowed to be downloaded via the API, thus Packwiz is asking you to download them manually from the website. (Which naturally wouldn't work inside a derivation.)

Vartroc commented 1 month ago

Thanks, I think that solved it. I did packwiz mr export and removed all the mods that it couldn't download. Then I readded them using modrinth... What a dumb thing. Why would any mod dev revoke access to their mod via api? Oh, and I want to improve documentation, so that nobody else gets the same error and has to ask again... Am I allowed to do so or do you want to keep the documentation short (Asking this before writing it, so that I don't waste my time :) )

Vartroc commented 1 month ago

I would just open a pull request...

Infinidoge commented 1 month ago

Feel free :)

I want to eventually move documentation to somewhere that makes more sense, since right now it's kinda just... in the readme, and is pretty cluttered as such. But that's a project for When I Have Spoons.

And personally, I always get all of my mods from Modrinth where possible. It's just better.

Vartroc commented 1 month ago

ok, I will do so when I get around to it. On the modrinth thing, the problem is that, currently, you can't import a modrinth modpack...

Vartroc commented 1 month ago

Would you be so kind and help me with this as well as you seem way more experienced than I am with minecraft servers and I have no clue why my server is crashing...

So in the logs it seems like everything is alright, but when run sudo systemctl status minecraft-servers-hexagon.service I get informed, that my server isn't running. I have no idea where to even start debugging this issue....

Vartroc commented 1 month ago

It doesn't even generate a mods folder... but the config file, that is included in the packwiz mod is there? I have set up a git repo in the servers directory (/srv/minecraft/testing/)