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

Local packages in mono repos #19

Open
m-bock opened this issue Nov 10, 2019 · 4 comments
Open

Local packages in mono repos #19

m-bock opened this issue Nov 10, 2019 · 4 comments

Comments

@m-bock
Copy link

m-bock commented Nov 10, 2019

Consider a setup as described here: https://github.com/spacchetti/spago#monorepo

When spago2nix is run inside app1 it just produces a comment for the local package:

  # lib1 is a Local package in (Local "./../lib1")

(See

# PKGNAME is a Local package in PATH
)

With this the nix build fails because of a missing module from the dependency.

How should this be handled?

Should we just generate something like this instead of the the comment?:

    "lib1" = pkgs.stdenv.mkDerivation {
        name = "lib1";
        src = ./../lib1;
        phases = "installPhase";
        installPhase = "ln -s $src $out";
      };

@justinwoo
Copy link
Owner

Thanks for the PR, but I don't think this is what I would want to do. The problems are that

  1. trying to use the PATH as a source would mean you still generate derivations that rely on the user environment
  2. you would end up putting every file tree version of the local package in the store, meaning that not only do you get git reversions but also revisions of any file in the directory
  3. this will not produce the same result as spago build, which is not necessarily a huge problem, but it is a goal for me to generate a .spago/ directory with the correct packages inside, without shims that are treated differently by spago2nix build

What I think should be done is to write this information out somewhere in spago2nix generate (if not already available otherwise), and to adjust the build to feed in source globs. It's kind of a pain, but local packages are also an abomination anway

@m-bock
Copy link
Author

m-bock commented Nov 11, 2019

Ok, I think I get your point. What do you think, does this go into the right direction: #21 ?

This should cover 1. and 2., but not yet 3.

@m-bock
Copy link
Author

m-bock commented Nov 11, 2019

Well, no. Now it's impure. We have a relative path inside the generated nix file.
The local packages have to be somehow put into a derivation to get around this. At least their src dir. But why the overhead of treating them differently. I'd look at them as Git repos that happen to be located inside the (mono) repo. And I also think it's ok if every revision ends up in the store as new derivation. This is also the case with your actual project sources.

After this, I think (again) the first solution is better. But I may be wrong, it's kind of tricky.

@shmish111
Copy link
Contributor

@justinwoo I just came across this and was wondering what do suggest other than local packages when you have a monorepo? Currently we are using extra source directories but it seems...wrong somehow.

shmish111 added a commit to IntersectMBO/plutus that referenced this issue Jan 18, 2021
There is code that is shared between plutus playground and plutus SCB that is not used by marlowe playground or marlowe dashboard. The same will be true for Marlowe once SCP-1672 is implemented. There is also code that is useful to all web projects. We wouldn't normally mind mixing these 3 types in one location however some of the purescript code depends on code generated by the psgenerator scripts. If we have them all together we have to add lots of superfluous types to our psgenerators. It started to get our of hand when I looked at implementing SCP-1672. This commit splits these 3 types into 3 different directories and should allow the psgenerator scripts to be simplified.

web-common-marlowe doesn't have anything in it yet but it will do with SCP-1672

Currently we're sticking with the model of "add an extra source directory" rather than having full on purescript or node modules. This is because it's currently much simpler, also spago2nix can't handle local modules yet (justinwoo/spago2nix#19). Finally, it makes it much easier to make changes to web-common and web-common-* during development of the main client projects because they are symlinks in the project, this means (in VSCode at least) that intellisense etc work perfectly.
kayvank pushed a commit to input-output-hk/marconi that referenced this issue Mar 11, 2023
There is code that is shared between plutus playground and plutus SCB that is not used by marlowe playground or marlowe dashboard. The same will be true for Marlowe once SCP-1672 is implemented. There is also code that is useful to all web projects. We wouldn't normally mind mixing these 3 types in one location however some of the purescript code depends on code generated by the psgenerator scripts. If we have them all together we have to add lots of superfluous types to our psgenerators. It started to get our of hand when I looked at implementing SCP-1672. This commit splits these 3 types into 3 different directories and should allow the psgenerator scripts to be simplified.

web-common-marlowe doesn't have anything in it yet but it will do with SCP-1672

Currently we're sticking with the model of "add an extra source directory" rather than having full on purescript or node modules. This is because it's currently much simpler, also spago2nix can't handle local modules yet (justinwoo/spago2nix#19). Finally, it makes it much easier to make changes to web-common and web-common-* during development of the main client projects because they are symlinks in the project, this means (in VSCode at least) that intellisense etc work perfectly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants