@@ -0,0 +1,50 @@
1+{ stdenv, fetchurl, unzip, lib, file, licenseFile, optgamsFile}:
2+
3+assert licenseFile != null;
4+
5+stdenv.mkDerivation rec {
6+ version = "25.0.2";
7+ name = "gams-${version}";
8+ src = fetchurl {
9+ url = "https://d37drm4t2jghv5.cloudfront.net/distributions/${version}/linux/linux_x64_64_sfx.exe";
10+ sha256 = "4f95389579f33ff7c2586838a2c19021aa0746279555cbb51aa6e0efd09bd297";
11+ };
12+ unpackCmd = "unzip $src";
13+ buildInputs = [ unzip file ];
14+ dontBuild = true;
15+
16+ installPhase = ''
17+ mkdir -p "$out/bin" "$out/share/gams"
18+ cp -a * "$out/share/gams"
19+
20+ cp ${licenseFile} $out/share/gamslice.txt
21+ '' + stdenv.lib.optionalString (optgamsFile != null) ''
22+ cp ${optgamsFile} $out/share/optgams.def
23+ ln -s $out/share/gams/optgams.def $out/bin/optgams.def
24+ '';
25+
26+ postFixup = ''
27+ for f in $out/share/gams/*; do
28+ if [[ -x $f ]] && [[ -f $f ]] && [[ ! $f =~ .*\.so$ ]]; then
29+ if patchelf \
30+ --set-rpath "$out/share/gams" \
31+ --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) $f; then
32+ ln -s $f $out/bin/$(basename $f)
33+ fi
34+ fi
35+ done
36+ '';
37+
38+ meta = with stdenv.lib;{
39+ description = "General Algebraic Modeling System";
40+ longDescription = ''
41+ The General Algebraic Modeling System is a high-level modeling system for mathematical optimization.
42+ GAMS is designed for modeling and solving linear, nonlinear, and mixed-integer optimization problems.
43+ '';
44+ homepage = https://www.gams.com/;
45+ license = licenses.unfree;
46+ maintainers = [ maintainers.Scriptkiddi ];
47+ platforms = platforms.linux;
48+ };
49+}
50+