Skip to content

Instantly share code, notes, and snippets.

@oscarduignan
Last active October 12, 2017 16:34
Show Gist options
  • Save oscarduignan/821a0201e416144b11e8b4653a8afbd4 to your computer and use it in GitHub Desktop.
Save oscarduignan/821a0201e416144b11e8b4653a8afbd4 to your computer and use it in GitHub Desktop.
nixos package and an overlay that uses it to install commandbox (command line tool for the lucee cfml programming language)
self: super: {
commandbox = super.callPackage /path/to/commandbox_package {};
}
{ stdenv, fetchurl, unzip, makeWrapper, jre }:
stdenv.mkDerivation rec {
name = "commandbox-3.8.0";
phases = ["unpackPhase" "patchPhase" "installPhase"];
src = fetchurl {
name = "${name}.zip";
url = "https://www.ortussolutions.com/parent/download/commandbox/type/bin"; # will break when there's a new release...
sha256 = "e184e380713b6e4e94c1266bf4abc352da2e5c7b19bdb9d5ce5f36665d1c58ec";
};
sourceRoot = "./";
buildInputs = [ makeWrapper unzip ];
installPhase = ''
mkdir -p $out/bin
cp ./box $out/bin
wrapProgram $out/bin/box --prefix PATH ":" ${jre}/bin ;
'';
}
@oscarduignan
Copy link
Author

With the overlay in place you can run the commands below

nix-build '<nixpkgs>' -A commandbox
nix-shell -p commandbox
nix-env -i commandbox
  1. builds the package and puts it in a results subfolder of the current directory
  2. builds package and puts you in a shell where you can run it without installing it
  3. builds package and installs it for the current user

After running nix-shell or nix-env -i try running box to interact with the tool

Important: a "problem" with this is that it's downloading the binary rather than building from source. I couldn't work out how to build the tool myself, build process seems to be using ANT. Extra problem is that this URL points to the latest binary not just version 3.8.0 - I couldn't find a way to get just the specific version we want - tried checking the docker images but they also just use whatever the latest version is. Not ideal but good enough, if you try to build this and it fails then it's likely they released a new version so you need to update the sha256 for the zip file you get from the url listed in the above derivation.

@oscarduignan
Copy link
Author

oscarduignan commented Oct 12, 2017

To install this I put the overlay at ~/.config/nixpkgs/overlays/commandbox.nix and the package at ~/.config/nixpkgs/pkgs/commandbox.nix and update the paths in the file above accordingly and run nix-env -i commandbox.

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