matsavage / DND-5e-LaTeX-Character-Sheet-Template

LaTeX package to typeset character sheets for the fifth edition of the "world's greatest roleplaying game".
96 stars 49 forks source link

Publishing this template to Overleaf #61

Closed PalmaAnd closed 3 months ago

PalmaAnd commented 7 months ago

Hello! I was wondering if you ever thought of publishing this project/template to Overleaf so people can use it there as a template?

Thanks for the answer in advance!

matsavage commented 7 months ago

I had it working on overleaf a couple of years ago, but for whatever reason it doesn't seem to work any more.

It's certainly possible to get it up and running there, but I've never really been able to keep it in sync, as £17/month for the git integration feels a bit much, so I have no way of testing that it currently works.

There has been a lot of work put into the Nix build system by @soispha, and it's really quite painless to run locally now, once you have Nix installed, or if you fork the repository and allow GitHub actions to run, there is an action which will build the latex files for you result.zip at the bottom here will show an example.

PalmaAnd commented 7 months ago

Oh okay I understand. I get the problem with the sync, £17/month is a lot. I will try either Nix or GitHub actions, thank you very much for the fast and helpful answer! :)

matsavage commented 7 months ago

Let me know how it goes. It would be great to have some feedback/a more genuine set up guide.

Also this is quite a complex document and compilation on overleaf was very slow, so it’s never really real-time, but I do get the allure of just being able to edit on a webpage.

PalmaAnd commented 7 months ago

Sure, I can give it a try and add it to my to-do list! 👍🏻 Yeah, it's really convenient, but as soon as I have some free time, I'll attempt to set this up locally. Do you have any recommendations for the setup? I was thinking about using WSL2 to run everything as it works with that too according to the NIX documentation. Also, if I encounter any problems or complications during the installation, may I open a pull request with some additional to-dos?

May you assign this issue to me so I have it on my list? :)

matsavage commented 7 months ago

I use WSL when I'm on a windows machine, and it's very good, but is obviously a huge hurdle for most people.

I just use the standard Ubuntu image then install Nix with the script on their site.

Feel free to ask for more help/raise issues as they come up etc.

PalmaAnd commented 7 months ago

Alright gotcha! Thanks, then I will try to install it in my WSL (I have some experience with it)

I will come back to that offer thanks!

PalmaAnd commented 6 months ago

Sorry for the long pause, I kinda get stuck when executing nix build --experimental-features 'nix-command flakes' I keep getting the following error in my WSL:

warning: Ignoring setting 'auto-allocate-uids' because experimental feature 'auto-allocate-uids' is not enabled
warning: Ignoring setting 'impure-env' because experimental feature 'configurable-impure-env' is not enabled
error: builder for '/nix/store/fz8zpd6ipc807w1yrn1xn86ibyczkw4l-characters-example_2-dnd-char-sheet-1.0.drv' failed with exit code 127;
       last 5 log lines:
       > Running phase: unpackPhase
       > unpacking source archive /nix/store/r3mc3ja4w4j9v1w3q3jazlw9krp0dcdz-gg9xin9f2wk7w6412jprabawzn9rysa0-source
       > source root is gg9xin9f2wk7w6412jprabawzn9rysa0-source
       > Running phase: patchPhase
       > /nix/store/bknngadwym46j65qs14ic2w79rpav888-stdenv-linux/setup: line 1582: $'\r': command not found
       For full logs, run 'nix log /nix/store/fz8zpd6ipc807w1yrn1xn86ibyczkw4l-characters-example_2-dnd-char-sheet-1.0.drv'.
error: 1 dependencies of derivation '/nix/store/z5bkfa5j2xvlb56y57llsp3vidjvbj4r-characters-all.drv' failed to build

Could be a stupid question but I don't really know what to do as I am fairly new with custom LateX stuff and never used NIX too.

Can anyone help me with this? Using Ubuntu 22.04

matsavage commented 6 months ago

Can you run the log command and paste the output please

nix log /nix/store/fz8zpd6ipc807w1yrn1xn86ibyczkw4l-characters-example_2-dnd-char-sheet-1.0.drv

Also can you confirm this also happens when running make build

PalmaAnd commented 6 months ago

Thanks for the quick reply!

Log output:

nix log /nix/store/fz8zpd6ipc807w1yrn1xn86ibyczkw4l-characters-example_2-dnd-char-sheet-1.0.drv  --experimental-features 'nix-command flakes'
warning: The interpretation of store paths arguments ending in `.drv` recently changed. If this command is now failing try again with '/nix/store/fz8zpd6ipc807w1yrn1xn86ibyczkw4l-characters-example_2-dnd-char-sheet-1.0.drv^*'
@nix { "action": "setPhase", "phase": "unpackPhase" }
Running phase: unpackPhase
unpacking source archive /nix/store/r3mc3ja4w4j9v1w3q3jazlw9krp0dcdz-gg9xin9f2wk7w6412jprabawzn9rysa0-source
source root is gg9xin9f2wk7w6412jprabawzn9rysa0-source
@nix { "action": "setPhase", "phase": "patchPhase" }
Running phase: patchPhase
/nix/store/bknngadwym46j65qs14ic2w79rpav888-stdenv-linux/setup: line 1582: $'\r': command not found

When running make build I get the following:

error: builder for '/nix/store/fz8zpd6ipc807w1yrn1xn86ibyczkw4l-characters-example_2-dnd-char-sheet-1.0.drv' failed with exit code 127;
       last 5 log lines:
       > Running phase: unpackPhase
       > unpacking source archive /nix/store/r3mc3ja4w4j9v1w3q3jazlw9krp0dcdz-gg9xin9f2wk7w6412jprabawzn9rysa0-source
       > source root is gg9xin9f2wk7w6412jprabawzn9rysa0-source
       > Running phase: patchPhase
       > /nix/store/bknngadwym46j65qs14ic2w79rpav888-stdenv-linux/setup: line 1582: $'\r': command not found
       For full logs, run 'nix log /nix/store/fz8zpd6ipc807w1yrn1xn86ibyczkw4l-characters-example_2-dnd-char-sheet-1.0.drv'.
error: 1 dependencies of derivation '/nix/store/z5bkfa5j2xvlb56y57llsp3vidjvbj4r-characters-all.drv' failed to build
make: *** [Makefile:6: build] Error 1
matsavage commented 6 months ago

So the same as with make build and the other way, so at least that's consistent.

May I ask how you cloned the repo? in WSL or windows based git client? I haven't seen this issue before, but I wonder if it's something to do with the encoding of linux vs. mac

PalmaAnd commented 6 months ago

I'm not really sure neither. I will try a complete clean install of nix, followed by git cloning the repo and then trying it again 👍🏻

matsavage commented 6 months ago

If you used the windows GUI client I would recommend using the linux native one. Ubuntu on WSL works fine for meSent from my iPhoneOn 28 Feb 2024, at 19:42, André Palma @.***> wrote: I'm not really sure neither. I will try a complete clean install of nix, followed by git cloning the repo and then trying it again 👍🏻

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were assigned.Message ID: @.***>

PalmaAnd commented 6 months ago

Alright so I completely deleted the existing project, uninstalled nix via sudo rm -rf /nix/ inside WSL, and then reinstalled it as described on their page with sh <(curl -L https://nixos.org/nix/install) --no-daemon for single user installation. Then I cloned my fork via https://github.com/PalmaAnd/DND-5e-LaTeX-Character-Sheet-Template.git and now after I cd into the project and run make I get the following error again:

nix --extra-experimental-features nix-command --extra-experimental-features flakes build
error: builder for '/nix/store/fz8zpd6ipc807w1yrn1xn86ibyczkw4l-characters-example_2-dnd-char-sheet-1.0.drv' failed with exit code 127;
       last 5 log lines:
       > Running phase: unpackPhase
       > unpacking source archive /nix/store/r3mc3ja4w4j9v1w3q3jazlw9krp0dcdz-gg9xin9f2wk7w6412jprabawzn9rysa0-source
       > source root is gg9xin9f2wk7w6412jprabawzn9rysa0-source
       > Running phase: patchPhase
       > /nix/store/bknngadwym46j65qs14ic2w79rpav888-stdenv-linux/setup: line 1582: $'\r': command not found
       For full logs, run 'nix log /nix/store/fz8zpd6ipc807w1yrn1xn86ibyczkw4l-characters-example_2-dnd-char-sheet-1.0.drv'.
error: 1 dependencies of derivation '/nix/store/z5bkfa5j2xvlb56y57llsp3vidjvbj4r-characters-all.drv' failed to build
make: *** [Makefile:6: build] Error 1

When running nix log /nix/store/fz8zpd6ipc807w1yrn1xn86ibyczkw4l-characters-example_2-dnd-char-sheet-1.0.drv --extra-experimental-features nix-command I get the same log as before...

warning: The interpretation of store paths arguments ending in `.drv` recently changed. If this command is now failing try again with '/nix/store/fz8zpd6ipc807w1yrn1xn86ibyczkw4l-characters-example_2-dnd-char-sheet-1.0.drv^*'
@nix { "action": "setPhase", "phase": "unpackPhase" }
Running phase: unpackPhase
unpacking source archive /nix/store/r3mc3ja4w4j9v1w3q3jazlw9krp0dcdz-gg9xin9f2wk7w6412jprabawzn9rysa0-source
source root is gg9xin9f2wk7w6412jprabawzn9rysa0-source
@nix { "action": "setPhase", "phase": "patchPhase" }
Running phase: patchPhase
/nix/store/bknngadwym46j65qs14ic2w79rpav888-stdenv-linux/setup: line 1582: $'\r': command not found

I can't find anything, maybe it is some small configuration I made at some point in time in WSL?

Sorry for the spam and these long logs and all that 😅

Ohh I think I found it... looks like a issue with bash and the \r command. I will look into it further and send an update ASAP

soispha commented 6 months ago

Ohh I think I found it... looks like a issue with bash and the \r command.

This seems really weird to me (as your fork builds fine for me). Would you like to show me the line from the setup script that fails (in your example line 1582)?

matsavage commented 6 months ago

Yeah, my initial thought was that was an escape character which ended up there due to some linux/windows weirdness, but it happening twice make me think something else is happening.

I haven’t seen this before, and main is building fine in CI so it feels like something in the nix stdenv-linux package?

PalmaAnd commented 6 months ago

Sure, this is the code snippet:

if [[ "$curPhase" = configurePhase && -n "${dontConfigure:-}" ]]; then return; fi
    if [[ "$curPhase" = buildPhase && -n "${dontBuild:-}" ]]; then return; fi
    if [[ "$curPhase" = checkPhase && -z "${doCheck:-}" ]]; then return; fi
    if [[ "$curPhase" = installPhase && -n "${dontInstall:-}" ]]; then return; fi
    if [[ "$curPhase" = fixupPhase && -n "${dontFixup:-}" ]]; then return; fi
    if [[ "$curPhase" = installCheckPhase && -z "${doInstallCheck:-}" ]]; then return; fi
    if [[ "$curPhase" = distPhase && -z "${doDist:-}" ]]; then return; fi

    if [[ -n $NIX_LOG_FD ]]; then
        echo "@nix { \"action\": \"setPhase\", \"phase\": \"$curPhase\" }" >&"$NIX_LOG_FD"
    fi

    showPhaseHeader "$curPhase"
    dumpVars

    local startTime=$(date +"%s")

    # Evaluate the variable named $curPhase if it exists, otherwise the
    # function named $curPhase.
    eval "${!curPhase:-$curPhase}"

    local endTime=$(date +"%s")

    showPhaseFooter "$curPhase" "$startTime" "$endTime"

    if [ "$curPhase" = unpackPhase ]; then
        # make sure we can cd into the directory
        [ -n "${sourceRoot:-}" ] && chmod +x "${sourceRoot}"

        cd "${sourceRoot:-.}"
    fi

The eval "${!curPhase:-$curPhase}" is the problem here Thank you both very much for all the time and help 😅

soispha commented 6 months ago

Could it be that the $curPhase variable contains a \n\r line ending? Because that could mean that bash tries to evaluate the command after the \n, which being a \r doesn't work. But the flake.nix file does not contain any carriage returns on my local checkout of your fork, and you haven't changed it locally, have you?

PalmaAnd commented 6 months ago

Okay, sorry for the long pause dos2unix ./* fixed the problem, or at least I got into the building phase I finally was able to execute the following without an error:

nix --extra-experimental-features nix-command --extra-experimental-features flakes build
warning: Git tree '/home/andre/projects/DND-5e-LaTeX-Character-Sheet-Template' is dirty
[1/1/3 built, 0.0 MiB DL] building characters-unnamed-dnd-char-sheet-1.0 (buildPhase): unnamed.xdv -> unnamed.pdf

I will post an update soon, just got a lot to do with university atm sorry

matsavage commented 6 months ago

Thanks a lot André, there’s really no rush. We all have university/jobs etc, just glad you’ve got it working 😊

matsavage commented 6 months ago

Also, that shouldn’t be an issue, you should have files at results/ nix just likes you to have your changes committed when you run.

matsavage commented 3 months ago

I did manage to get Overleaf compilation working, but there is more to do if that's also going to use the DND template: https://github.com/matsavage/DND-5e-LaTeX-Character-Sheet-Template/pull/90