CrazyChaoz / gradle-dot-nix

This flake can generate the full maven repo required to build a gradle app from gradle/verification-metadata.xml, all in the sandbox, without code generation.
MIT License
4 stars 2 forks source link

added user id and verbose information to tmp module file name to avoid race condition issues #3

Closed eeedean closed 5 months ago

eeedean commented 6 months ago

Parallel building may fail, because multiple build users try to write to the same file (/tmp/module_file.module). In order to avoid that, I added the user id as well as some more verbose information to the file name.

Unfortunately user id (or something unique to the build user) is required, because some modules are referenced by multiple other modules. However, since Nix does always build in a *NIX-compatible environment, there should always be some user id available.

CrazyChaoz commented 6 months ago

have you encountered this issue ? because afaik the /tmp dir is empty for each sandbox, and since the derivations do not use any impurities (yet?) there should be no possibility for a collision.

eeedean commented 6 months ago

I cannot rule out, that this is a special issue, I run into, because I develop on a macOS host, set up using determinate-systems installer and nix-darwin.

At least in my particular setup I had the described behavior. Maybe it's similar, when running Nix Builds on non-NixOS based Linux-Distributions. Did not test that in detail.

CrazyChaoz commented 6 months ago

could you try it with just tmp/module_file.module, so that its still a generic file, but definitely in the build dir?

mschwaig commented 6 months ago

Can you post the output of the nix doctor command?

Mine looks like this:

[PASS] PATH contains only one nix version.
[PASS] All profiles are gcroots.
[PASS] Client protocol matches store protocol.
[INFO] You are trusted by store uri: daemon

My intuition on this would be that at least for a multi-user (deamon) Install of Nix, builds should not share the same /tmp directory. I do not know in https://github.com/DeterminateSystems/nix-installer supports both single- and multi-user installs on macOS.

mschwaig commented 6 months ago

Looks like this might still be the state of things: https://stackoverflow.com/a/67607698

eeedean commented 6 months ago

Looks like this might still be the state of things: https://stackoverflow.com/a/67607698

I indeed can verify that behavior on my machine.

could you try it with just tmp/module_file.module, so that its still a generic file, but definitely in the build dir?

I adjusted my branch accordingly. That works beautifully and I think, that's a better approach than my initial proposal.