Infinidoge / nix-minecraft

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

fetchPackwizModpack support parameter src as drv instead of url #110

Open luochen1990 opened 3 weeks ago

luochen1990 commented 3 weeks ago

I hope these code

  modpack = pkgs.fetchPackwizModpack {
    url = "https://github.com/Misterio77/Modpack/raw/0.2.9/pack.toml";
    packHash = "sha256-L5RiSktqtSQBDecVfGj1iDaXV+E90zrNEcf4jtsg+wk=";
  };

Can be replaced into:

  modpack = pkgs.fetchPackwizModpack {
    src = fetchFromGithub { owner = "Misterio77"; repo = "Modpack"; rev = "master"; sha256 = "";};
  };

And if the name of pack.toml is not special enough, we can specify it like

  modpack = pkgs.fetchPackwizModpack {
    src = fetchFromGithub { owner = "Misterio77"; repo = "Modpack"; rev = "master"; sha256 = "";};
    path = "pack.toml";
  };
haussjonas commented 3 weeks ago

I'm not a nix expert, but I would suggest a more flexible option that supports more fetchers. For example, for my purposes, I use the following solution to load local packages:

let
  serverPack = builtins.path {
    path = ./modpacks/server;
  };
  serverModpack = (pkgs.fetchPackwizModpack {
    url = "file://${serverPack}/pack.toml";
    packHash = "sha256-zdhJ1cv8nCzqoAD9vsXk6vAzPUMFI8G6k3ComHrQaE0=";
  });
in
{}