cuplv / cuanto

Apache License 2.0
1 stars 1 forks source link

Reproducible development environment with Nix #56

Closed octalsrc closed 7 years ago

octalsrc commented 7 years ago

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 commented 7 years ago

https://github.com/NixOS/nix/issues/1203

bechang commented 7 years ago

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

octalsrc commented 7 years ago

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

octalsrc commented 7 years ago

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