1{
2 lib,
3 stdenv,
4 fetchurl,
5 jre,
6 makeWrapper,
7 makeDesktopItem,
8}:
9
10let
11 generic =
12 { version, sha256 }:
13 stdenv.mkDerivation rec {
14 pname = "alloy${lib.versions.major version}";
15 inherit version;
16
17 src = fetchurl {
18 inherit sha256;
19 url = "https://github.com/AlloyTools/org.alloytools.alloy/releases/download/v${version}/org.alloytools.alloy.dist.jar";
20 };
21
22 desktopItem = makeDesktopItem rec {
23 name = pname;
24 exec = name;
25 icon = name;
26 desktopName = "Alloy ${lib.versions.major version}";
27 genericName = "Relational modelling tool";
28 comment = meta.description;
29 categories = [
30 "Development"
31 "IDE"
32 "Education"
33 ];
34 };
35
36 nativeBuildInputs = [ makeWrapper ];
37
38 buildCommand = ''
39 jar=$out/share/alloy/${pname}.jar
40 install -Dm644 $src $jar
41
42 mkdir -p $out/bin
43 makeWrapper ${jre}/bin/java $out/bin/${pname} --add-flags \
44 "-jar $jar"
45
46 install -Dm644 ${./icon.png} $out/share/pixmaps/${pname}.png
47 cp -r ${desktopItem}/share/applications $out/share
48 '';
49
50 meta = with lib; {
51 description = "Language & tool for relational models";
52 longDescription = ''
53 Alloy is a language for describing structures and a tool for exploring
54 them. An Alloy model is a collection of constraints that describes a set
55 of structures, e.g. all the possible security configurations of a web
56 application, or all the possible topologies of a switching network. The
57 Alloy Analyzer is a solver that takes the constraints of a model and
58 finds structures that satisfy them. Structures are displayed graphically,
59 and their appearance can be customized for the domain at hand.
60 '';
61 homepage = "https://alloytools.org/";
62 downloadPage = "https://alloytools.org/download.html";
63 sourceProvenance = with sourceTypes; [ binaryBytecode ];
64 license = licenses.mit;
65 platforms = platforms.unix;
66 maintainers = with maintainers; [ notbandali ];
67 };
68 };
69
70in
71rec {
72 alloy5 = generic {
73 version = "5.1.0";
74 sha256 = "sha256-o7Q+jsmWeUeuotUQG9lrPE6w2B6z3Ju6QcyWSTScaQo=";
75 };
76
77 alloy6 = generic {
78 version = "6.2.0";
79 sha256 = "sha256-a4wctbyTvt/HxhQ1xOGrbmiKJC3HAqOUYo2amAHtt40=";
80 };
81
82 alloy = alloy5;
83}