NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.18k stars 14.19k forks source link

Lubelogger runs but several features (image & document uploads, authentication, etc.) are non-functional #333954

Open firecat53 opened 3 months ago

firecat53 commented 3 months ago

Describe the bug

Lubelogger is unable to use authentication, image or document uploads, or translations due to those directories being unable to be created in the /nix/store/<hash>-lubelogger-1.3.5/lib/lubelogger/wwwroot directory. (as it's part of the Nix Store)

System.IO.IOException: Read-only file system : '/nix/store/qg3ybjq5xbgwpaff3jmry05f423a34f3-lubelogger-1.3.5/lib/lubelogger/wwwroot/temp/'

Steps To Reproduce

  1. Start lubelogger
    $ nix shell nixpkgs-unstable#lubelogger
    $ CarCareTracker
  2. Attempt to upload an image when adding a new vehicle or upload a document as part of a repair record. This triggers the above error.

Expected behavior

Image and document uploads work correctly.

Additional context

When the app is run using Docker/podman, the following volumes are mounted:

      - config:/App/config
      - data:/App/data
      - translations:/App/wwwroot/translations
      - documents:/App/wwwroot/documents
      - images:/App/wwwroot/images
      - temp:/App/wwwroot/temp
      - log:/App/log
      - keys:/root/.aspnet/DataProtection-Keys

The config and data directories will be created in the working directory from where the app is run. The other directories in wwwroot and /root/.aspnet cannot be created.

Notify maintainers

@Samasaur1

Metadata

(note: flakes enabled)

$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.6.41, NixOS, 24.05 (Uakari), 24.05.20240810.a781ff3`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.5`
 - channels(root): `""`
 - nixpkgs: `/nix/store/61502m9h1jl40j7sxbcyjdm6qi1k7x97-source`

Thank you!

Samasaur1 commented 3 months ago

I'm not sure how to fix this. The issue is that lubelogger tries to read and write to the the content root directory. I set DOTNET_CONTENTROOT to /nix/store/<hash>-lubelogger-1.3.5/lib/lubelogger, which works perfectly for reading but as you noticed does not work for writing.

It's possible to replicate the way the Docker image works by copying the entire contents of that directory to the current directory, and then running lubelogger (without the DOTNET_CONTENTROOT variable set, which makes it look in the current directory). The problem with this is that if you don't copy those files, then lubelogger will fail entirely.

eclairevoyant commented 3 months ago

If it needs to write its own data then you probably want a NixOS module

firecat53 commented 3 months ago

Without writing a module, could you add symlinks during the packaging process to wwwroot/{temp,documents,images...} and /root/.aspnet/Data-Proection-Keys that point to XDG_DATA_HOME (/var/lib/lubelogger/xxx or ~/.local/share/lubelogger/xxx) ?

Samasaur1 commented 3 months ago

I suppose I could, yeah, but the issue there is that then multiple instances of lubelogger would share the same state directory, which would be bad

Samasaur1 commented 3 months ago

Okay, I opened a draft PR. I don't actually use lubelogger anymore, so I don't want to be the maintainer for the service, so I have not listed myself as a maintainer and have left the PR as a draft. I think it should resolve this issue, though