Skip to content

An example project that uses plutus as a library #1373

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

Merged
merged 1 commit into from
Aug 23, 2019
Merged

Conversation

shmish111
Copy link
Contributor

It takes about 40 minutes to go from scratch to coding in VS Code in a new virtual machine. We can take a snapshot of a machine to avoid this time though.


# launch vs code from this nix-shell
# You must run `code` from within the nix shell in order for Haskell IDE Engine to work correctly
code
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this has to be done inside the VM, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should work on any machine with nix, updating the README to clarify

packages:
./

source-repository-package
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could really do with haskell/cabal#5472...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I doubt this type of thing will be in cabal 2.x ever, I imagine we will have to wait for cabal-install 3

@@ -0,0 +1,33 @@
{ nixpkgs ? <nixpkgs> }:
let
pkgs = import (builtins.fetchTarball {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not do this at the system level? If they're just doing it for one thing we can install HIE globally.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, why do we need to pin this? A lot of things here are using the ambient nixpkgs, either we should just assume that it's got a working vscode or we should pin it at the top level.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pinning here means we can use it on any computer and it will work, for example on my mac it works. Same with hie, it all just works having it in this nix shell

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this example I just prefer a known-good setup that should work for everyone

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess my concern is that e.g. we're not getting a pinned version of the nixos virtualbox bits, but maybe that's okay.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are not using anything unstable in the nixos config though and they're pretty good about keeping that working well. There's almost nothing that depends on <nixpkgs> in there anyway.

@@ -0,0 +1,57 @@
cabal-version: 1.12
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly should be a newer version, although I'm not sure that it matters much.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is what appears in some plutus packages. all this stuff is just from the stack or cabal-install new package template

@michaelpj
Copy link
Contributor

Given that, in the end, this doesn't share anything with the rest of the repository, not even the default nixpkgs pin, maybe we should just put it in a separate repository? Especially since then it's less annoying if it's out of sync - that just means it's pointing at an older commit.

@michaelpj
Copy link
Contributor

I also want to try this out.

@shmish111
Copy link
Contributor Author

WRT external repository, I don't have an opinion either way except that it might be an administration burden to get a repo set up correctly, why go through the potential pain if we don't need to.

@michaelpj
Copy link
Contributor

I'm guessing you need to put some of the stuff that's in the system packages in the shell too. I tried just on my Nixos machine and got:

<command line>: can't load .so/.DLL for: libcrypto.so (libcrypto.so: cannot open shared object file: No such file or directory)
cabal: Failed to build language-plutus-core-0.1.0.0 (which is required by
exe:example-exe from example-0.1.0.0)

@shmish111
Copy link
Contributor Author

Yeah, it's in the configuration.nix file

@michaelpj
Copy link
Contributor

So maybe let's move it to the shell? That way we preserve the property that it will work if you just have Nix installed too.

@shmish111
Copy link
Contributor Author

I couldn't get it to work in the shell

@michaelpj
Copy link
Contributor

Ah right, because we have this system library issue. This is on me, actually, I hadn't run the command to add the extra-lib-dirs!

Having done so, I see it's written to the cabal.config in my home directory, which I'm not sure I want. Could we provide a cabal.project and tell them to put the setting in there?

@shmish111
Copy link
Contributor Author

I thought about that but I don't like changing a file and adding a system specific setting that should be committed. It would be a PITA as your project grew and you wanted more things in shell.nix. You could import something but it works without this addition on most systems where the libs will be in standard locations.

@michaelpj
Copy link
Contributor

I mean just tell them to put it in cabal.project, not add it to the committed cabal.project ourselves.

@shmish111
Copy link
Contributor Author

Sorry I meant cabal.project not shell.nix. Same thing though, this is an example project that I imagine people will want to share at some point so you want to commit cabal.project to your own VCS and you don't want system specific stuff in there.

I think if people are using this rather than the VM then they are somewhat likely to want to do this.

@michaelpj
Copy link
Contributor

Then: cabal.project.local? I think that's precisely for the intersection of project-specific and machine-specific settings.

@shmish111
Copy link
Contributor Author

Oh I hadn't heard of that, nice

@shmish111
Copy link
Contributor Author

@michaelpj I've updated the README to comment out that command and leave it as an example with an explanation of what the user might need to do including the option of cabal.project.local

@michaelpj
Copy link
Contributor

👍

@michaelpj michaelpj merged commit 9007066 into master Aug 23, 2019
@kwxm kwxm deleted the vm-image branch February 20, 2020 20:00
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

Successfully merging this pull request may close these issues.

2 participants