summary refs log tree commit diff
path: root/pkgs/applications/misc/free42/default.nix
blob: 2dd70acb9a7381790b7f990fdd5abb6a50018cea (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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
{ lib
, stdenv
, fetchFromGitHub
, makeDesktopItem
, copyDesktopItems
, pkg-config
, gtk3
, alsa-lib
}:

stdenv.mkDerivation rec {
  pname = "free42";
  version = "3.0.5";

  src = fetchFromGitHub {
    owner = "thomasokken";
    repo = pname;
    rev = "v${version}";
    sha256 = "sha256-ytRPIBE8KcuM+pyfdKt/b+Vi03x8nowdgZjSt8EddSc=";
  };

  nativeBuildInputs = [ copyDesktopItems pkg-config ];
  buildInputs = [ gtk3 alsa-lib ];

  postPatch = ''
    sed -i -e "s|/bin/ls|ls|" gtk/Makefile
  '';

  dontConfigure = true;

  buildPhase = ''
    runHook preBuild
    make -C gtk cleaner
    make --jobs=$NIX_BUILD_CORES -C gtk
    make -C gtk clean
    make --jobs=$NIX_BUILD_CORES -C gtk BCD_MATH=1
    runHook postBuild
  '';

  preInstall = ''
    install --directory $out/bin \
                        $out/share/doc/${pname} \
                        $out/share/${pname}/skins \
                        $out/share/icons/hicolor/48x48/apps \
                        $out/share/icons/hicolor/128x128/apps
  '';

  installPhase = ''
    runHook preInstall
    install -m755 gtk/free42dec gtk/free42bin $out/bin
    install -m644 gtk/README $out/share/doc/${pname}/README-GTK
    install -m644 README $out/share/doc/${pname}/README

    install -m644 gtk/icon-48x48.xpm $out/share/icons/hicolor/48x48/apps
    install -m644 gtk/icon-128x128.xpm $out/share/icons/hicolor/128x128/apps
    install -m644 skins/* $out/share/${pname}/skins
    runHook postInstall
  '';

  desktopItems = [
    (makeDesktopItem {
      name = "com.thomasokken.free42bin";
      desktopName = "Free42Bin";
      genericName = "Calculator";
      exec = "free42bin";
      type = "Application";
      comment = meta.description;
      categories = "Utility;Calculator;";
      terminal = "false";
    })
    (makeDesktopItem {
      name = "com.thomasokken.free42dec";
      desktopName = "Free42Dec";
      genericName = "Calculator";
      exec = "free42dec";
      type = "Application";
      comment = meta.description;
      categories = "Utility;Calculator;";
      terminal = "false";
    })
  ];

  meta = with lib; {
    homepage = "https://github.com/thomasokken/free42";
    description = "A software clone of HP-42S Calculator";
    license = licenses.gpl2Only;
    maintainers = with maintainers; [ AndersonTorres plabadens ];
    platforms = with platforms; unix;
  };
}