btrbk: add mainProgram
[NixPkgs.git] / pkgs / by-name / su / sunvox / package.nix
bloba5d2af067044925ea9cc35792463680fb699f70e
1 { lib
2 , stdenv
3 , fetchzip
4 , alsa-lib
5 , autoPatchelfHook
6 , libglvnd
7 , libjack2
8 , libX11
9 , libXi
10 , makeWrapper
11 , SDL2
14 let
15   platforms = {
16     "x86_64-linux" = "linux_x86_64";
17     "i686-linux" = "linux_x86";
18     "aarch64-linux" = "linux_arm64";
19     "armv7l-linux" = "arm_armhf_raspberry_pi";
20     "x86_64-darwin" = "macos";
21     "aarch64-darwin" = "macos";
22   };
23   bindir = platforms."${stdenv.hostPlatform.system}" or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
25 stdenv.mkDerivation (finalAttrs: {
26   pname = "sunvox";
27   version = "2.1.2";
29   src = fetchzip {
30     urls = [
31       "https://www.warmplace.ru/soft/sunvox/sunvox-${finalAttrs.version}.zip"
32       # Upstream removes downloads of older versions, please save bumped versions to archive.org
33       # FIXME At the time of writing, archive.org is still recovering from the recent attacks and has not yet re-opened the page saving functionality
34       # https://blog.archive.org/2024/10/21/internet-archive-services-update-2024-10-21/
35     ];
36     hash = "sha256-7DZyoOz3jDYsuGqbs0PRs6jdWCxBhSDUKk8KVJQm/3o=";
37   };
39   nativeBuildInputs = lib.optionals stdenv.hostPlatform.isLinux [
40     autoPatchelfHook
41   ] ++ lib.optionals stdenv.hostPlatform.isDarwin [
42     makeWrapper
43   ];
45   buildInputs = lib.optionals stdenv.hostPlatform.isLinux [
46     alsa-lib
47     libglvnd
48     libX11
49     libXi
50     SDL2
51   ];
53   runtimeDependencies = lib.optionals stdenv.hostPlatform.isLinux [
54     libjack2
55   ];
57   dontConfigure = true;
58   dontBuild = true;
60   installPhase = ''
61     runHook preInstall
63     # Delete platform-specific data for all the platforms we're not building for
64     find sunvox -mindepth 1 -maxdepth 1 -type d -not -name "${bindir}" -exec rm -r {} \;
66     mkdir -p $out/{bin,share/sunvox}
67     mv * $out/share/sunvox/
69   '' + lib.optionalString stdenv.hostPlatform.isLinux ''
70     for binary in $(find $out/share/sunvox/sunvox/${bindir}/ -type f -executable); do
71       mv $binary $out/bin/$(basename $binary)
72     done
74     # Cleanup, make sure we didn't miss anything
75     find $out/share/sunvox/sunvox -type f -name readme.txt -delete
76     rmdir $out/share/sunvox/sunvox/${bindir} $out/share/sunvox/sunvox
77   '' + lib.optionalString stdenv.hostPlatform.isDarwin ''
78     mkdir $out/Applications
79     ln -s $out/share/sunvox/sunvox/${bindir}/SunVox.app $out/Applications/
80     ln -s $out/share/sunvox/sunvox/${bindir}/reset_sunvox $out/bin/
82     # Need to use a wrapper, binary checks for files relative to the path it was called via
83     makeWrapper $out/Applications/SunVox.app/Contents/MacOS/SunVox $out/bin/sunvox
84   '' + ''
86     runHook postInstall
87   '';
89   meta = with lib; {
90     description = "Small, fast and powerful modular synthesizer with pattern-based sequencer";
91     license = licenses.unfreeRedistributable;
92     sourceProvenance = with sourceTypes; [ binaryNativeCode ];
93     homepage = "https://www.warmplace.ru/soft/sunvox/";
94     maintainers = with maintainers; [ puffnfresh OPNA2608 ];
95     platforms = lib.attrNames platforms;
96   };