nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchurl,
5 alsa-lib,
6 copyDesktopItems,
7 wrapGAppsHook3,
8 makeDesktopItem,
9 pkg-config,
10 nix-update-script,
11}:
12stdenv.mkDerivation (finalAttrs: {
13 pname = "plus42";
14 version = "1.3.13";
15
16 src = fetchurl {
17 url = "https://thomasokken.com/plus42/upstream/plus42-upstream-${finalAttrs.version}.tgz";
18 hash = "sha256-I5SAR6vEufzT2Cgs4RQk8AWDZWm+QOLtHRqaED2DQtA=";
19 };
20
21 nativeBuildInputs = [
22 copyDesktopItems
23 pkg-config
24 wrapGAppsHook3
25 ];
26
27 buildInputs = [ alsa-lib ];
28
29 postPatch = ''
30 substituteInPlace gtk/Makefile \
31 --replace-fail /bin/ls ls
32 '';
33
34 dontConfigure = true;
35
36 desktopItems = [
37 (makeDesktopItem {
38 name = "plus42bin";
39 desktopName = "Plus42Bin";
40 genericName = "Calculator";
41 exec = "plus42bin";
42 type = "Application";
43 comment = "Software clone of the HP-42S calculator (enhanced version)";
44 icon = "plus42";
45 categories = [
46 "Utility"
47 "Calculator"
48 ];
49 })
50 (makeDesktopItem {
51 name = "plus42dec";
52 desktopName = "Plus42Dec";
53 genericName = "Calculator";
54 exec = "plus42dec";
55 type = "Application";
56 comment = "Software clone of the HP-42S calculator (enhanced version)";
57 icon = "plus42";
58 categories = [
59 "Utility"
60 "Calculator"
61 ];
62 })
63 ];
64
65 buildPhase = ''
66 runHook preBuild
67
68 make -C gtk cleaner
69 make --jobs=$NIX_BUILD_CORES -C gtk AUDIO_ALSA=1
70 make -C gtk clean
71 make --jobs=$NIX_BUILD_CORES -C gtk AUDIO_ALSA=1 BCD_MATH=1
72
73 runHook postBuild
74 '';
75
76 installPhase = ''
77 runHook preInstall
78
79 install --directory $out/bin \
80 $out/share/doc/plus42 \
81 $out/share/plus42/skins \
82 $out/share/icons/hicolor/48x48/apps \
83 $out/share/icons/hicolor/128x128/apps
84
85 install -m755 gtk/plus42dec gtk/plus42bin $out/bin
86 install -m644 README $out/share/doc/plus42/README
87
88 install -m644 gtk/icon-48x48.png $out/share/icons/hicolor/48x48/apps/plus42.png
89 install -m644 gtk/icon-128x128.png $out/share/icons/hicolor/128x128/apps/plus42.png
90 install -m644 skins/* $out/share/plus42/skins
91
92 runHook postInstall
93 '';
94
95 dontWrapGApps = true;
96
97 postFixup = ''
98 wrapProgram $out/bin/plus42dec \
99 --prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ alsa-lib ]} \
100 "''${gappsWrapperArgs[@]}"
101
102 wrapProgram $out/bin/plus42bin \
103 --prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ alsa-lib ]} \
104 "''${gappsWrapperArgs[@]}"
105 '';
106
107 passthru.updateScript = nix-update-script {
108 extraArgs = [ "--url=https://codeberg.org/thomasokken/plus42desktop" ];
109 };
110
111 meta = {
112 homepage = "https://thomasokken.com/plus42/";
113 changelog = "https://thomasokken.com/plus42/history.html";
114 description = "Software clone of the HP-42S calculator (enhanced version)";
115 license = with lib.licenses; [ gpl2Only ];
116 maintainers = with lib.maintainers; [ elfenermarcell ];
117 mainProgram = "plus42dec";
118 platforms = with lib.platforms; unix;
119 };
120})