flux icon indicating copy to clipboard operation
flux copied to clipboard

illegal path references in fixed-output derivation

Open Strosel opened this issue 1 year ago • 18 comments

When trying to set up a minecraft server for the new year I wanted to give flux a try as it looks very promising. However, I quickly faced the error: illegal path references in fixed-output derivation which has proven to be a huge headache.

As far as I understand, the server derivation has to be "fixed-output" as mcman fetches packages in the build phase. So the issue that persists is what references other Nix paths and why. Since the error itself is poorly explained and documented I tried fixing this for quite some time and although I could not fix it I could find which files contain these references. Namely,

  • start.sh
  • run.sh
  • forge-1.20.1-47.3.22-installer.jar.log
  • libraries/net/minecraftforge/forge/1.20.1-47.3.22/unix_args.txt
  • libraries/net/minecraftforge/forge/1.20.1-47.3.22/win_args.txt and potentially others if you use another mod loader.

This seems like unintended behaviour since the readme mentions nothing of it. If this is a previously known issue maybe mod support should be specifically listed in the TODO section?

Strosel avatar Dec 30 '24 15:12 Strosel

Could you provide the mix code you are using to build the server?

This is unexpected behavior.

IogaMaster avatar Dec 30 '24 17:12 IogaMaster

Heres a flake that builds just the server, the issue is identical in a (my) system config. https://github.com/Strosel/mc3/blob/5b002b19e2c3c90dd1ac3c05037917e321a9ad01/flake.nix

Strosel avatar Jan 02 '25 10:01 Strosel

Same issue. I don't know what to do.

hustlerone avatar Jan 03 '25 20:01 hustlerone

The reason this error is present is because the files you have in the fixed output derivation contain a path to the nix store.

You have your server files in the same dir as the flake and lockfile.

image

So ideally you would just put your server files into a subdirectory and change the package to point to the subdir. I think this is the issue

IogaMaster avatar Jan 03 '25 22:01 IogaMaster

Sadly, subdirectories do not solve the issue and from my rudimentary research it seems that mcman is the one pointing to store paths in its output (although I am not sure)

Same repo+branch, new commit with subdirs

Strosel avatar Jan 04 '25 12:01 Strosel

The reason this error is present is because the files you have in the fixed output derivation contain a path to the nix store.

You have your server files in the same dir as the flake and lockfile.

image

So ideally you would just put your server files into a subdirectory and change the package to point to the subdir. I think this is the issue

This would easily be the one of (if not the) best solution for minecraft servers on Nix if this gets fixed

Logs Forge modpack

[root@Fruit:/etc/nixos/Fruit]# nixos-rebuild switch building the system configuration... warning: found empty hash, assuming 'sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=' error: illegal path references in fixed-output derivation '/nix/store/4nbzsgkmfkm40jyz0k5acsq54c235l7s-modpack-build.drv' error: 1 dependencies of derivation '/nix/store/z6f0nkdcw6l17fpa175w7lfyrxrnhpbm-modpack-runtime.drv' failed to build error: 1 dependencies of derivation '/nix/store/ga3dliijx22g9iv8rzj6a8xgwgh37ifn-modpack-usr-target.drv' failed to build error: 1 dependencies of derivation '/nix/store/svrqj0lpqgq8zs1g7ah1nbnisdcmy109-modpack-fhs.drv' failed to build error: 1 dependencies of derivation '/nix/store/4caqzy2z55w64n2vgr4ri4gjrc1sms8c-modpack-bwrap.drv' failed to build error: 1 dependencies of derivation '/nix/store/rcc5qgqpmfy08608fl3r3bmvgljzwyr4-modpack.drv' failed to build error: 1 dependencies of derivation '/nix/store/62iaza53zynxklpypc8lzc68xjg9asx9-unit-script-modpack-start.drv' failed to build error: 1 dependencies of derivation '/nix/store/ii0rspvmvry45j51v2scbw8zvfhj67a3-unit-modpack.service.drv' failed to build error: 1 dependencies of derivation '/nix/store/dcx6zcj8zky7q9pd18iagvjn1k8pvnf0-system-units.drv' failed to build error: 1 dependencies of derivation '/nix/store/8pb0gcdw5ddl9c1m6rj9mdmlp8n5m9ny-etc.drv' failed to build error: 1 dependencies of derivation '/nix/store/mzgf98b5466f8qx7mmk29rfh4xnbw1dn-nixos-system-Fruit-24.05.20241227.31ac92f.drv' failed to build

{ pkgs, inputs, ... }:

{
  imports = [ inputs.flux.nixosModules.default ];

  environment.systemPackages = with pkgs; [ mcman ];

  nixpkgs.overlays = [ inputs.flux.overlays.default ];

  flux = {
    enable = true;
    servers = {
      modpack = {
        package = pkgs.mkMinecraftServer {
          name = "modpack";
          src = ./minecraft-servers/modpack;
          hash = "";
        };
      };
    };
  };
}

hustlerone avatar Jan 04 '25 14:01 hustlerone

Sadly, subdirectories do not solve the issue and from my rudimentary research it seems that mcman is the one pointing to store paths in its output (although I am not sure)

Same repo+branch, new commit with subdirs

Doing a velocity instance seems fine for some reason. I installed plugins on it like you would on Forge

hustlerone avatar Jan 04 '25 15:01 hustlerone

Doing a velocity instance seems fine for some reason. I installed plugins on it like you would on Forge

Could you share the flake/derivation that worked? I'm not super savvy with mods but velocity uses plugins not mods right? So the issue could be caused by the choice of platform/modloader which would be a shame.

Strosel avatar Jan 04 '25 19:01 Strosel

It's like you did but i declared velocity and added the plugins like you would imnport on forge

hustlerone avatar Jan 05 '25 00:01 hustlerone

The last line is interesting... checking for references to /build/ in /nix/store/prwmfz3lh7c8yf5kdswys2hlpx8fr12i-modpack-build...

hustlerone avatar Jan 05 '25 00:01 hustlerone

Fabric also seems fine?

hustlerone avatar Jan 05 '25 01:01 hustlerone

But yeah, something's going on iwth forge

hustlerone avatar Jan 07 '25 16:01 hustlerone

Interesting

IogaMaster avatar Jan 07 '25 18:01 IogaMaster

For what it's worth, I'm having the exact same issue

starlightsys avatar Feb 11 '25 09:02 starlightsys

When trying to set up a minecraft server for the new year I wanted to give flux a try as it looks very promising. However, I quickly faced the error: illegal path references in fixed-output derivation which has proven to be a huge headache.

As far as I understand, the server derivation has to be "fixed-output" as mcman fetches packages in the build phase. So the issue that persists is what references other Nix paths and why. Since the error itself is poorly explained and documented I tried fixing this for quite some time and although I could not fix it I could find which files contain these references. Namely,

* start.sh

* run.sh

* forge-1.20.1-47.3.22-installer.jar.log

* libraries/net/minecraftforge/forge/1.20.1-47.3.22/unix_args.txt

* libraries/net/minecraftforge/forge/1.20.1-47.3.22/win_args.txt
  and potentially others if you use another mod loader.

This seems like unintended behaviour since the readme mentions nothing of it. If this is a previously known issue maybe mod support should be specifically listed in the TODO section?

Funnily enough these files (namely *_args.txt) are now missing on old forge versions too, although it won't prevent your minecraft instance from building.

hustlerone avatar Mar 13 '25 18:03 hustlerone

News here, Nix now reports what's wrong:

fixed-output derivations must not reference store paths

And given that you use two separate derivations and you use the path of one of them (instead of passing it in as a function input) is probably the culprit.

I'll see if I can fix it up.

hustlerone avatar Apr 09 '25 15:04 hustlerone

patchELF is at fault FYI

hustlerone avatar Apr 15 '25 15:04 hustlerone

Disabled patchELF, errors at installPhase

hustlerone avatar Apr 15 '25 16:04 hustlerone