about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/tools/mars-mips/default.nix
blob: 66b9684175c3721089cefb3c4513d83cf46782b6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
{ lib
, stdenv
, fetchurl
, makeBinaryWrapper
, copyDesktopItems
, makeDesktopItem
, desktopToDarwinBundle
, unzip
, imagemagick
, jre
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "mars-mips";
  version = "4.5";

  src = fetchurl {
    url = "https://courses.missouristate.edu/KenVollmar/MARS/MARS_${lib.replaceStrings ["."] ["_"] finalAttrs.version}_Aug2014/Mars${lib.replaceStrings ["."] ["_"] finalAttrs.version}.jar";
    hash = "sha256-rDQLZ2uitiJGud935i+BrURHvP0ymrU5cWvNCZULcJY=";
  };

  dontUnpack = true;

  nativeBuildInputs = [
    makeBinaryWrapper
    copyDesktopItems
    unzip
    imagemagick
  ] ++ lib.optionals stdenv.isDarwin [
    desktopToDarwinBundle
  ];

  desktopItems = [
    (makeDesktopItem {
      name = "mars";
      desktopName = "MARS";
      exec = "Mars";
      icon = "mars";
      comment = finalAttrs.meta.description;
      categories = [ "Development" "IDE" ];
    })
  ];

  installPhase = ''
    runHook preInstall

    export JAR=$out/share/java/mars/Mars.jar
    install -Dm444 $src $JAR
    makeWrapper ${jre}/bin/java $out/bin/Mars \
      --add-flags "-jar $JAR"

    unzip $src images/MarsThumbnail.gif
    for size in 16 24 32 48 64 128 256 512
    do
      mkdir -p $out/share/icons/hicolor/"$size"x"$size"/apps
      convert -resize "$size"x"$size" images/MarsThumbnail.gif $out/share/icons/hicolor/"$size"x"$size"/apps/mars.png
    done

    runHook postInstall
  '';

  meta = {
    description = "An IDE for programming in MIPS assembly language intended for educational-level use";
    mainProgram = "Mars";
    homepage = "https://courses.missouristate.edu/KenVollmar/MARS/";
    sourceProvenance = with lib.sourceTypes; [ binaryBytecode ];
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ emilytrau ];
    platforms = lib.platforms.all;
  };
})