Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: collision between A and B #268

Closed
deemp opened this issue Jul 27, 2023 · 2 comments
Closed

error: collision between A and B #268

deemp opened this issue Jul 27, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@deemp
Copy link
Contributor

deemp commented Jul 27, 2023

Describe the bug

There happen collisions between outputs of derivations.

error: builder for '/nix/store/b26vcwkva5jibrsfgfyy0yr8a26b1xcq-devshell-dir.drv' failed with exit code 25;
       last 1 log lines:
       > error: collision between `/nix/store/wnkqs7395ycrhx4igkpk4vkpsq1j2fr7-purs-tidy-0.10.0/package.json' and `/nix/store/d85k0zkqr9d52gkd7nwvy11x562vz4ar-spago-0.93.9/package.json'
       For full logs, run 'nix log /nix/store/b26vcwkva5jibrsfgfyy0yr8a26b1xcq-devshell-dir.drv'.
error: 1 dependencies of derivation '/nix/store/i06ac43b0040qzpa3xf0gdvqqmm05dwy-devshell-env.drv' failed to build

To Reproduce

nix develop github:deemp/gists/ffd2e94d21f1939a4c55d7fa3459bc2c910f4f50?dir=purifixProject#devshell

Expected behavior

purs, spago, purs-tidy binaries are on PATH.

System information

x86_64-linux

Additional context

There are other issues mentioning the problem.

Possible solution

devShells.default = pkgs.devshell.mkShell {
  packages = pkgs.lib.lists.imap0 pkgs.lib.setPrio [
    pkgs.purs-unstable
    pkgs.spago-unstable
    pkgs.purs-tidy-unstable
  ];
};
@deemp deemp added the bug Something isn't working label Jul 27, 2023
@zimbatm
Copy link
Member

zimbatm commented Jul 27, 2023

The issue is that both packages have a package.json in their output, and so the merging doesn't like it.

The proper fix would be to not put the package.json in the top of the $out of the package. In general, $out should only contain folders like ./bin ./lib ... so that there are no clashes like that.

The quick fix is to wrap one of the packages with pkgs.lib.lowPrio to instruct buildEnv on which one's package.json should be linked to. Eg:

diff --git a/purifixProject/flake.nix b/purifixProject/flake.nix
index 868298a..f2677fc 100644
--- a/purifixProject/flake.nix
+++ b/purifixProject/flake.nix
@@ -38,7 +38,7 @@
           devShells.devshell = pkgs.devshell.mkShell {
             packages = [
               pkgs.purs-unstable
-              pkgs.spago-unstable
+              (pkgs.lib.lowPrio pkgs.spago-unstable)
               pkgs.purs-tidy-unstable
             ];
           };

@deemp
Copy link
Contributor Author

deemp commented Jul 27, 2023

Here's where package.json is moved to $out:

https://github.com/thomashoneyman/purescript-overlay/blob/df8b03689a92d5be94732b445206d0e4837d395f/manifests/build-support/mkSpagoDerivation.nix#L27

If not move it there, there'll be NodeJS errors when trying to execute $out/bin/spago.

UPD:
NodeJS package files can be moved to $out/node_modules/package_name

like here
thomashoneyman/purescript-overlay#40

@deemp deemp closed this as completed Aug 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants