jlesquembre / clj-nix

Nix helpers for Clojure projects
https://jlesquembre.github.io/clj-nix/
Eclipse Public License 2.0
139 stars 20 forks source link

Inconsistent nar serialization of git libs between aarch64-linux and aarch64-darwin #41

Open slimslenderslacks opened 1 year ago

slimslenderslacks commented 1 year ago

I'm not sure if this is the only place where we see this behavior but if I run the update-deps menu command on aarch64-darwin, the entry in pkgs/builder-lock.json for https://github.com/clojure/tools.build.git will be updated. If I run the same update-deps command on aarch64-linux (in a docker container), the pkgs/builder-lock.json file will not be updated.

I think this points to an issue with the cljnix.nix namespace when running in darwin.

jlesquembre commented 1 year ago

Thanks for reporting, I think that's related to the test errors you see on #39 . Could you post the diff and your darwin version? I have to investigate it , but I suspect maven is picking different versions based on the system. It's a bit hard to test for me, since I don't have a mac.

slimslenderslacks commented 1 year ago

I still haven't figured this one out. I'm actually only seeing issues for gitlibs today though. But if I run update-deps on aarch64-linux, I get the entry below which is what is currently checked in.

{
    "url": "https://github.com/clojure/tools.build.git",
    "rev": "ba1a2bf421838802e7bdefc541b41f57582e53b6",
    "paths": [
      "src/main/clojure",
      "src/main/resources"
    ],
    "hash": "sha256-p8kdg9UmpUq+JeyxL+g5R0GwdcP7cOI6wZuJnXK9Y8I="
  }

However, if I run this on aarch64-darwin, I get the following diff.

index 0ec85ec..4647601 100644
--- a/pkgs/builder-lock.json
+++ b/pkgs/builder-lock.json
@@ -1,12 +1,12 @@
 [
   {
-    "url": "https://github.com/clojure/tools.build.git",
+    "url": "https://github.com/clojure/tools.build",
     "rev": "ba1a2bf421838802e7bdefc541b41f57582e53b6",
     "paths": [
       "src/main/clojure",
       "src/main/resources"
     ],
-    "hash": "sha256-p8kdg9UmpUq+JeyxL+g5R0GwdcP7cOI6wZuJnXK9Y8I="
+    "hash": "sha256-Dif4WtK/9JDfCJq45Do0pWSBVILN5qNnNKfvFNXVgrI="
   },
   {
     "url": "https://repo.clojars.org/babashka/fs/0.1.6/fs-0.1.6.jar",

So obviously the urls are slightly different which is weird, but I wouldn't have thought that would impact the hash anyway. And it's definitely darwin only so far.

jlesquembre commented 1 year ago

I cannot reproduce it, maybe has something to do with the git version? The url value should not impact the hash, but at the same time, the url value comes from running git remote get-url origin. If the value is different, maybe something else is going on and the files are not identical?

slimslenderslacks commented 1 year ago

I just re-ran this against main today and the url is still different (no .git extension) but this time the hashes are NOT different. I can checkout a commit of clj-nix from Feb. 25th and the problem comes back (the hashes are different). Same version of git in both cases. Maybe this was a problem with build tools?

slimslenderslacks commented 1 year ago

The git client on macos still doesn't include a .git extension on the url, but now that the nix-hash is coming out the same on macos, I might be able to close this issue. I'll check a few more projects.

jlesquembre commented 1 year ago

I'll try to test it on a mac. If the only difference is the .git extension, I can add a check for it, and add the extension before we write the lock file.