Commit 96111942 authored by Marcell Tóth's avatar Marcell Tóth
Browse files

free42: 3.3.8 -> 3.3.10

This changes the source as recommended on the program's website because
1) it means we only download the part needed for the linux build
2) it doesn't contain the HP logo
and makes it so the alsa dependency actually gets used
parent d2c031c2
Loading
Loading
Loading
Loading
+37 −23
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  fetchFromGitea,
  fetchurl,
  alsa-lib,
  copyDesktopItems,
  wrapGAppsHook3,
  makeDesktopItem,
  pkg-config,
  nix-update-script,
}:

stdenv.mkDerivation (finalAttrs: {
stdenv.mkDerivation rec {
  pname = "free42";
  version = "3.3.8";

  src = fetchFromGitea {
    domain = "codeberg.org";
    owner = "thomasokken";
    repo = "free42";
    tag = "v${finalAttrs.version}";
    hash = "sha256-L6WZM5/+ujM6hv85ppt9YiqHLkd0vYFx3nFVcJwzEBM=";
  version = "3.3.10";

  src = fetchurl {
    url = "https://thomasokken.com/free42/upstream/free42-nologo-${version}.tgz";
    hash = "sha256-Vh+Sh3oX1ICy0R6R4zu9Df2+ba2mM33qHtifINNpn7Y=";
  };

  nativeBuildInputs = [
@@ -30,19 +27,20 @@ stdenv.mkDerivation (finalAttrs: {
  buildInputs = [ alsa-lib ];

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

  dontConfigure = true;

  desktopItems = [
    (makeDesktopItem {
      name = "com.thomasokken.free42bin";
      name = "free42bin";
      desktopName = "Free42Bin";
      genericName = "Calculator";
      exec = "free42bin";
      type = "Application";
      comment = "A software clone of HP-42S Calculator";
      comment = "Software clone of the HP-42S calculator";
      icon = "free42";
      categories = [
        "Utility"
@@ -50,12 +48,12 @@ stdenv.mkDerivation (finalAttrs: {
      ];
    })
    (makeDesktopItem {
      name = "com.thomasokken.free42dec";
      name = "free42dec";
      desktopName = "Free42Dec";
      genericName = "Calculator";
      exec = "free42dec";
      type = "Application";
      comment = "A software clone of HP-42S Calculator";
      comment = "Software clone of the HP-42S calculator";
      icon = "free42";
      categories = [
        "Utility"
@@ -68,9 +66,9 @@ stdenv.mkDerivation (finalAttrs: {
    runHook preBuild

    make -C gtk cleaner
    make --jobs=$NIX_BUILD_CORES -C gtk
    make --jobs=$NIX_BUILD_CORES -C gtk AUDIO_ALSA=1
    make -C gtk clean
    make --jobs=$NIX_BUILD_CORES -C gtk BCD_MATH=1
    make --jobs=$NIX_BUILD_CORES -C gtk AUDIO_ALSA=1 BCD_MATH=1

    runHook postBuild
  '';
@@ -87,20 +85,36 @@ stdenv.mkDerivation (finalAttrs: {
    install -m755 gtk/free42dec gtk/free42bin $out/bin
    install -m644 README $out/share/doc/free42/README

    install -m644 gtk/icon-48x48.xpm $out/share/icons/hicolor/48x48/apps/free42.xpm
    install -m644 gtk/icon-128x128.xpm $out/share/icons/hicolor/128x128/apps/free42.xpm
    install -m644 gtk/icon-48x48.png $out/share/icons/hicolor/48x48/apps/free42.png
    install -m644 gtk/icon-128x128.png $out/share/icons/hicolor/128x128/apps/free42.png
    install -m644 skins/* $out/share/free42/skins

    runHook postInstall
  '';

  dontWrapGApps = true;

  postFixup = ''
    wrapProgram $out/bin/free42dec \
      --prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ alsa-lib ]} \
      "''${gappsWrapperArgs[@]}"

    wrapProgram $out/bin/free42bin \
      --prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ alsa-lib ]} \
      "''${gappsWrapperArgs[@]}"
  '';

  passthru.updateScript = nix-update-script {
    extraArgs = [ "--url=https://codeberg.org/thomasokken/free42" ];
  };

  meta = {
    homepage = "https://thomasokken.com/free42/";
    changelog = "https://thomasokken.com/free42/history.html";
    description = "Software clone of HP-42S Calculator";
    description = "Software clone of the HP-42S calculator";
    license = with lib.licenses; [ gpl2Only ];
    maintainers = [ ];
    maintainers = with lib.maintainers; [ elfenermarcell ];
    mainProgram = "free42dec";
    platforms = with lib.platforms; unix;
  };
})
}