diff --git a/ginsim.nix b/ginsim.nix index eb26816..064b12e 100644 --- a/ginsim.nix +++ b/ginsim.nix @@ -6,26 +6,61 @@ # # nix-build ginsim.nix # -# Or you can use in a nix-shell as shell.nix in the same directory -# illustrates. +# This will create the symlink result in the current directory. The +# runnable shell script is result/bin/GINsim. +# +# You can use this file in a nix-shell, as shell.nix illustrates. let + # Import nixpkgs to be able to supply reasonable default values for + # the anonymous function this file defines. pkgs = import {}; in -{ stdenv ? pkgs.stdenv, fetchurl ? pkgs.fetchurl, makeWrapper ? pkgs.makeWrapper, jre ? pkgs.jre }: +# These arguments define the resources (packages and native Nix tools) +# that will be used by the package (the anonymous function I define). +# I want this file to be buildable directly using the command +# nix-build ginsim.nix, so I have to supply reasonable default values +# to these arguments. The default values naturally come from the +# corresponding attributes of Nixpkgs, visible here under the binding +# pkgs. +{ stdenv ? pkgs.stdenv +, fetchurl ? pkgs.fetchurl +, makeWrapper ? pkgs.makeWrapper +, jre ? pkgs.jre +}: +# I'll use the default builder, because I don't need any particular +# features. stdenv.mkDerivation rec { name = "GINsim"; version = "2.4"; + # Simply fetch the JAR file of GINsim. src = fetchurl { url = "http://ginsim.org/sites/default/files/${name}-${version}.jar"; sha256 = "0891q75hli6ghgangscygkqw60x9ikx96i8y4fqca6kdh1xgs15h"; }; + # I fetch the JAR file directly, so no archives to unpack. dontUnpack = true; + # I need makeWrapper in my build environment to generate the wrapper + # shell script. This shell script will call the Java executable on + # the JAR file of GINsim and will set the appropriate environment + # variables. nativeBuildInputs = [ makeWrapper ]; + # The only meaningful phase of this build. I create the + # subdirectory share/java/ in the output directory, because this is + # where JAR files are typically stored. I also create the + # subdirectory bin/ to store the executable shell script. I then + # copy the downloaded JAR file to $out/share/java/. Once this is + # done, I create the wrapper shell script using makeWrapper. This + # script wraps the Java executable (${jre}/bin/java) in the output + # shell script file $out/bin/GINsim. The script adds the argument + # -jar … to the Java executable, thus pointing it to the actual + # GINsim JAR file. On my system (NixOS + XMonad), I need to set + # some additional environment variables to get Java windows to + # render properly. installPhase = '' mkdir -pv $out/share/java $out/bin cp ${src} $out/share/java/${name}-${version}.jar @@ -36,10 +71,14 @@ stdenv.mkDerivation rec { --set _JAVA_AWT_WM_NONREPARENTING 1 ''; - meta = { + # Some easy metadata, in case I forget. I use the with statement to + # avoid typing stdenv.lib to specify the license, the platform and + # the maintainer. + meta = with stdenv.lib; { homepage = "http://ginsim.org/"; description = "A computer tool for the modeling and simulation of genetic regulatory networks."; - license = stdenv.lib.licenses.gpl3; - platforms = stdenv.lib.platforms.unix; + license = licenses.gpl3; + platforms = platforms.unix; + maintainers = [ maintainers.scolobb ]; }; }