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

Add command to install all packages in the set #607

Closed
JordanMartinez opened this issue Apr 11, 2020 · 10 comments · Fixed by #625
Closed

Add command to install all packages in the set #607

JordanMartinez opened this issue Apr 11, 2020 · 10 comments · Fixed by #625

Comments

@JordanMartinez
Copy link
Contributor

Having a command that did this would make it easier to update the ecosystem when we having breaking PS releases. Another option would be to document what to execute to get the same effect.

Since I don't know Bash as well as I probably should, I found that this worked after I looked into this more:

sudo apt-get install xclip -y
spago ls packages > example.txt && cat example.txt | sed -r "s/([a-zA-Z0-9-]+).*/\1/" | tr '\n' ' ' | xclip -selection c
spago install <CTRL+SHIFT+V>
@hdgarrood
Copy link
Contributor

I think this does the job, and is a little more straightforward:

$ spago install $(spago ls packages | cut -f 1 -d ' ' | tr '\n' ' ')

@hdgarrood
Copy link
Contributor

I was thinking about this a bit more; since Dhall is supposed to be programmable, why not just derive the packages key as the full set of packages in the set?

I got pretty close with this:

let packages = ./packages.dhall
let Package = { dependencies : List Text, repo : Text, version : Text }
let PackageAssoc = { mapKey : Text, mapValue : Package }
let getPackageName = \(v : PackageAssoc) -> v.mapKey
let List/map = https://prelude.dhall-lang.org/List/map
in
  { name = "core"
  , dependencies =
        List/map PackageAssoc Text getPackageName (toMap packages)
  , packages = packages
  , sources = [ "src/**/*.purs" ]
  }

but unfortunately this results in:

[info] Generating new hashes for the package set file so it will be cached.. (this might take some time)
[error] The following packages do not exist in your package set:
[error]   - metadata

and there does not appear to be any way of filtering the metadata package out of the list, because Dhall deliberately does not provide a string equality operation; its philosophy is that you should be avoiding stringly-typed programming (dhall-lang/dhall-lang#164).

@f-f
Copy link
Member

f-f commented Apr 12, 2020

I'd agree with the solution from @hdgarrood - the reason why that's not working with the current master is that we're excluding (for no reason IMO) the metadata package from the set. With the patch in #609 everything works as intended 😄

P.S.: well, the whole metadata package thing is a giant hack and it's due to keeping backwards compatibility with the package set format over time. I hope we'll be able to fix this with the new registry. I'm working on this too

@f-f f-f added the question label Apr 12, 2020
@f-f
Copy link
Member

f-f commented Apr 14, 2020

Now that #610 is in, I'll pivot this issue towards documenting in the README the pure-Dhall solution proposed by Harry - I'd like a new section called "Install all the packages in the set"

@paulyoung
Copy link

paulyoung commented Jul 22, 2020

I just tried using the suggested spago.dhall file with the monorepo setup and got this:

spago:
 ./spago.dhall

Error: Wrong type of function argument


{ mapValue : - {  :  }
             + <  :  >
, 
}

9                    List/map PackageAssoc Text getPackageName (toMap packages)

I'm not sure if I can look into this now but I'm wondering if it's due to a Dhall or prelude version mismatch.

@paulyoung
Copy link

It seems probable that this is the cause #594

@hdgarrood
Copy link
Contributor

I forgot to post this here previously: even after #610, I was still running into problems with the fancy Dhall approach. I don't recognise the error you are getting, so I'm not sure if it's the same one or if I just forgot what it looked like. I ended up deciding the Dhall approach was too clever and I reverted back to

$ spago install $(spago ls packages | cut -f 1 -d ' ' | tr '\n' ' ')

which works, although you do need to rerun it each time you update your package set.

@paulyoung
Copy link

Using Location instead of Package for the type of mapValue works for me.

@f-f
Copy link
Member

f-f commented Jul 22, 2020

@paulyoung you mean that the Dhall snippet in the README is incorrect in the case of a monorepo and that you have found a fix?

@paulyoung
Copy link

@f-f yes, as I mentioned above. I've only tried it with the monorepo setup but I don't know why it would be any different.

I also inlined List/map for convenience because at the time I didn't want to deal with satisfying Nix that it wasn't going to change out from under me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants