Infinidoge / nix-minecraft

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

fix: create parent directories for symlinks with nested paths #27

Closed ghost closed 1 year ago

ghost commented 1 year ago

If the parent directory doesn't exist ln will fail, so i mkdir -p the parent. My usecase was

{
  services.minecraft-servers = {
      enable = true;
      eula = true;

      servers = {
        "test" = {
          enable = true;
          openFirewall = true;

          package = mcPkgs.paperServers.paper-1_19_3;

          symlinks = {
            mods = pkgs.linkFarmFromDrvs "mods" (map mcPkgs.fetchModrinthMod (builtins.attrValues {
              UnifiedMetrics = {
                id = "YREl7q0o";
                hash = "sha256-3/MjbjBI+FkDOiTeHftZuARGIrgexXdAPsrcTfLFih8=";
              };
            }));

            "config/unifiedmetrics/config.yml" = pkgs.writeText "unifiedmetrics-config.yml" (builtins.toJSON {
              server.name = "global";

              metrics = {
                enabled = true;
                driver = "prometheus";
                collectors = {
                  systemGc = true;
                  systemMemory = true;
                  systemProcess = true;
                  systemThread = true;
                  server = true;
                  world = true;
                  tick = true;
                  events = true;
                };
              };
            });
          };
        };
      };
    };
}

failing because config/unifiedmetrics didnt get created