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

Reproducible development environment with Nix #56

Merged
merged 11 commits into from
Jul 28, 2017
Merged

Conversation

octalsrc
Copy link
Contributor

This adds a cuanto Nix derivation which specifies cuanto's external system-installed dependencies and allows quick entry into a complete development environment (as explained in CONTRIBUTING.md):

# Clone the cuanto project
$ git clone https://github.com/cuplv/cuanto

# Enter the cuanto build environment
$ cd cuanto
$ nix-shell

# Test the build environment
[nix-shell:~/cuanto]$ sbt test

The CONTRIBUTING.md doc also instructs you to add cuplv-nixpkgs to your Nix overlays. This is not necessary for any of cuanto's current dependencies, but is used by the apron branch currently under PR (for the japron package). This overlay would be a convenient way for CUPLV researchers to quickly make their own projects available for integration into cuanto in the future.

Usage: Adding new dependencies

To add a new dependency (with a package existing in either the main nixpkgs or cuplv-nixpkgs, edit default.nix. Add the package's name to the derivation inputs (the comma-separated list in curly braces at the top of the file) and to the build inputs (the space-separated list in square brackets assigned to buildInputs).

For an example of adding a dependency, see this commit for setting up japron.

Travis builds

Additionally, this PR modifies the Travis configuration so that our CI builds use the same environment. This way, adding new dependencies to your development environment by editing default.nix adds them to the Travis build environment as well.

System class-path for SBT

Finally, this PR configures SBT to search for unmanaged jars in $CLASSPATH, the standard environment variable which points to all system-installed java libraries (in particular this variable is set by nix-shell to point to all jars from the specified dependencies). It is necessary to use system-installed jars when they depend on native libraries, as is the case for japron.

@jpw234
Copy link
Contributor

jpw234 commented Jul 26, 2017

NixOS/nix#1203

build.sbt Outdated
// Tell sbt to look at $CLASSPATH for unmanaged jars. This is
// where system-installed jars (such as jars that depend on native
// libraries) are usually found.
unmanagedClasspath in Compile ++= systemClasspath,
Copy link
Member

Choose a reason for hiding this comment

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

We decided to use something like cuantoClasspath or nixClasspath.

@bechang
Copy link
Member

bechang commented Jul 26, 2017

@jpw234 @ftc Can one of you guys at to CONTRIBUTING.md.

@octalsrc
Copy link
Contributor Author

I have changed the SBT configuration to search in $CUANTO_CLASSPATH for system-installed jars, and provided a utility in default.nix that sets this variable correctly for dependencies.

I've tested this change for japron on the japron-test branch

Copy link
Contributor

@jpw234 jpw234 left a comment

Choose a reason for hiding this comment

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

Looks good and works on my (abnormal) system

@tianhan0 tianhan0 self-requested a review July 28, 2017 16:33
Copy link
Member

@tianhan0 tianhan0 left a comment

Choose a reason for hiding this comment

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

Confirmed that japron-test passed sbt test on Mac

@octalsrc octalsrc merged commit fa54595 into develop Jul 28, 2017
@octalsrc
Copy link
Contributor Author

As discussed, the Windows troubleshooting documentation will be its own PR, addressing Issue #57.

@octalsrc octalsrc deleted the dev-environment branch July 28, 2017 17:08
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.

4 participants