Lix and CppNix disagree on how ?ref= in flake inputs should be represented in lockfiles #520

Open
opened 2024-09-13 16:35:15 +00:00 by rbt · 4 comments
Owner

Describe the bug

If a github flake input URL contains a ?ref argument, CppNix will represent it as a ref in the flake.lock, but Lix represents it as a rev in the flake.lock. This leads to incompatibility when CppNix and Lix users attempt to collaborate on a project.

Workaround

Replacing ref with rev in the input URL seems to work:

- github:MercuryTechnologies/hs-temporal-sdk?ref=aec7f9be371fba0429be2488cf0a27fff4dfb490
+ github:MercuryTechnologies/hs-temporal-sdk?rev=aec7f9be371fba0429be2488cf0a27fff4dfb490

Then, Lix and CppNix will both represent it as a rev in the flake.lock.

Steps To Reproduce

$ cat flake.nix
{
  inputs.temporal-sdk.url =
    "github:MercuryTechnologies/hs-temporal-sdk?ref=aec7f9be371fba0429be2488cf0a27fff4dfb490";

  outputs = { self }: { };
}
$ nix run nixpkgs#nix -- --version
nix (Nix) 2.18.5
$ nix run nixpkgs#nix -- flake lock
$ nix --version
nix (Lix, like Nix) 2.91.0
$ nix flake lock
warning: updating lock file '/Users/wiggles/tmp/lix-flake-lock-bug/flake.lock'
$ git diff --text
diff --git a/flake.lock b/flake.lock
index 3d411c3..b930b49 100644
--- a/flake.lock
+++ b/flake.lock
@@ -510,8 +510,8 @@
       },
       "original": {
         "owner": "MercuryTechnologies",
-        "ref": "aec7f9be371fba0429be2488cf0a27fff4dfb490",
         "repo": "hs-temporal-sdk",
+        "rev": "aec7f9be371fba0429be2488cf0a27fff4dfb490",
         "type": "github"
       }
     }

Notes

For a git+ssh:// URL, both CppNix and Lix only accept a ?rev= argument, and ?ref= fails with a rather odd error:

$ nix run nixpkgs#nix -- flake lock
ssh: Could not resolve hostname github.com:MercuryTechnologies: nodename nor servname provided, or not known
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
error:
       … while updating the lock file of flake 'git+file:///Users/wiggles/tmp/lix-flake-lock-bug'

       … while updating the flake input 'temporal-sdk'

       … while fetching the input 'git+ssh://git@github.com:MercuryTechnologies/hs-temporal-sdk.git?ref=aec7f9be371fba0429be2488cf0a27fff4dfb490'

       error: program 'git' failed with exit code 128
## Describe the bug If a `github` flake input URL contains a `?ref` argument, CppNix will represent it as a `ref` in the `flake.lock`, but Lix represents it as a `rev` in the `flake.lock`. This leads to incompatibility when CppNix and Lix users attempt to collaborate on a project. ## Workaround Replacing `ref` with `rev` in the input URL seems to work: ```diff - github:MercuryTechnologies/hs-temporal-sdk?ref=aec7f9be371fba0429be2488cf0a27fff4dfb490 + github:MercuryTechnologies/hs-temporal-sdk?rev=aec7f9be371fba0429be2488cf0a27fff4dfb490 ``` Then, Lix and CppNix will both represent it as a `rev` in the `flake.lock`. ## Steps To Reproduce ``` $ cat flake.nix { inputs.temporal-sdk.url = "github:MercuryTechnologies/hs-temporal-sdk?ref=aec7f9be371fba0429be2488cf0a27fff4dfb490"; outputs = { self }: { }; } $ nix run nixpkgs#nix -- --version nix (Nix) 2.18.5 $ nix run nixpkgs#nix -- flake lock $ nix --version nix (Lix, like Nix) 2.91.0 $ nix flake lock warning: updating lock file '/Users/wiggles/tmp/lix-flake-lock-bug/flake.lock' $ git diff --text diff --git a/flake.lock b/flake.lock index 3d411c3..b930b49 100644 --- a/flake.lock +++ b/flake.lock @@ -510,8 +510,8 @@ }, "original": { "owner": "MercuryTechnologies", - "ref": "aec7f9be371fba0429be2488cf0a27fff4dfb490", "repo": "hs-temporal-sdk", + "rev": "aec7f9be371fba0429be2488cf0a27fff4dfb490", "type": "github" } } ``` ## Notes For a `git+ssh://` URL, both CppNix and Lix only accept a `?rev=` argument, and `?ref=` fails with a rather odd error: ``` $ nix run nixpkgs#nix -- flake lock ssh: Could not resolve hostname github.com:MercuryTechnologies: nodename nor servname provided, or not known fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. error: … while updating the lock file of flake 'git+file:///Users/wiggles/tmp/lix-flake-lock-bug' … while updating the flake input 'temporal-sdk' … while fetching the input 'git+ssh://git@github.com:MercuryTechnologies/hs-temporal-sdk.git?ref=aec7f9be371fba0429be2488cf0a27fff4dfb490' error: program 'git' failed with exit code 128 ```
rbt added the
bug
E/reproducible
regression
labels 2024-09-13 16:35:15 +00:00
Owner

This is most likely a CppNix regression; can you check if it works on 2.18? I have pretty high confidence we didn't break it since 2.18, but it's possible we did. i am also pattern matching this change as possibly related to fixing it: https://gerrit.lix.systems/c/lix/+/1353

owwww i really can't read today sorry

~~This is most likely a CppNix regression; can you check if it works on 2.18? I have pretty high confidence we didn't break it since 2.18, but it's possible we did. i am also pattern matching this change as possibly related to fixing it: https://gerrit.lix.systems/c/lix/+/1353~~ owwww i really can't read today sorry
Owner

As for the ssh URLs you're using the wrong URL format (git will also fail at this ssh url itself!), you need to replace : with / because : is for the port. The scp style ssh URLs are kind of a weird legacy thing in git itself that annoyingly don't support port numbers among other issues.

As for the ssh URLs you're using the wrong URL format (git will also fail at this ssh url itself!), you need to replace : with / because : is for the port. The scp style ssh URLs are kind of a weird legacy thing in git itself that annoyingly don't support port numbers among other issues.
Owner

maybe @ma27 knows about/wants to see this bug

maybe @ma27 knows about/wants to see this bug
Member

Most likely a similar issue as #472, I'm pretty sure it's the same root cause.

This leads to incompatibility when CppNix and Lix users attempt to collaborate on a project.

I'll see if I find a reasonable way to revert the behavior here.
But bottom line is that we shouldn't write lock files unless we actually need to.

Self assigning, will try to get something done within the next ~2 weeks (together with #472).

Most likely a similar issue as #472, I'm pretty sure it's the same root cause. > This leads to incompatibility when CppNix and Lix users attempt to collaborate on a project. I'll see if I find a reasonable way to revert the behavior here. But bottom line is that we shouldn't write lock files unless we actually need to. Self assigning, will try to get something done within the next ~2 weeks (together with #472).
ma27 self-assigned this 2024-09-15 21:09:39 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lix-project/lix#520
No description provided.