I have been trying to package Splashtop (a remote desktop application) and have almost got it working.
The application is proving quite annoying to package because it generates logging information in a directory which is a level deeper than its binary. For example:
/nix/store/Foo
\__ app-binary
\__ log
\__ Foo.log
When the application is run, it starts writing to the Foo.log file which it will not be able to do because /nix/store is a RO path. Annoyingly, the application doesn’t provide me with a way to define the output path for its logs.
I have attempted to make this work using the buildFHSUserEnv and it almost works if I simply initialise the env using flake.nix and then manually run the binary from a writable location as a nasty workaround but a proper solution would be really helpful.
Would anyone be able to give me any suggestions or hints as to how I can achieve this?
Thanks for the suggestions folks! @Atemu I did try something slightly similar however not what you suggested. How would you work around the Permission Denied errors though?
I am not able to create any directories/files in /var . I managed to create a directory in /tmp and link that but I think that path is invalid at runtime.
Following is what my flake.nix looks like. Please bear with me, I am still very much a nix noob
If anyone has any suggestions or improvements (in addition to a solution ) please let me know!
You’d use /var/tmp/ as I suggested which is publicly writable. In the ideal case, the app would then create the log file at /var/tmp/Foo.log through the symlink. Not certain that actually works but that’s the theory at least.
You could wrap the executable using makeWrapper to create the directory/file whenever the application is ran.
I’d rather try @bme’s suggestion though, you probably want stdout logging anyways.
So did it work? What are you asking? Every process has a fd for stdout. That fd is exposed by /proc/$pid/fd/1. /proc/self/ is a special entry in the proc file system accessible by any process to see it’s own entry in procfs. /dev/stdout is just a symlink into that.
❯ ls -la /dev/stdout
lrwxrwxrwx 1 root root 15 Jan 13 09:56 /dev/stdout -> /proc/self/fd/1
So hopefully the solution that I am proposing is obvious: symlink any stupid log files this program wants to create to /dev/stdout which always exists for every process and you are golden.
I was doing it incorrectly the first time around and decided to simply copy the binary in a tmp directory and execute it from there which worked. I did not really like it though.
The second time around I read your comment again and realised I had done what you suggested incorrectly
Today has been quite productive thanks for all your suggestions!
I had a brief look at this as I use splashtop to help out immediate family and it’s extremely concerning to say the least.
The fact that splashtop makes these kinds of fundamental mistakes in addition to the included gather-system-info.sh script which uses a fixed location under /tmpand helpfully recommends running as root makes me question all their other engineering practices.