ieda: init at 0-unstable-2024-10-11 (#338769)
[NixPkgs.git] / pkgs / by-name / sc / scilab-bin / package.nix
blob243f17def1f102e678ac80efd085fc07831ba3f2
2   lib,
3   stdenv,
4   fetchurl,
5   makeWrapper,
6   undmg,
7   autoPatchelfHook,
8   alsa-lib,
9   ncurses5,
10   xorg,
13 let
14   pname = "scilab-bin";
15   version = "6.1.1";
17   srcs = {
18     aarch64-darwin = fetchurl {
19       url = "https://www.utc.fr/~mottelet/scilab/download/${version}/scilab-${version}-accelerate-arm64.dmg";
20       sha256 = "sha256-L4dxD8R8bY5nd+4oDs5Yk0LlNsFykLnAM+oN/O87SRI=";
21     };
22     x86_64-darwin = fetchurl {
23       url = "https://www.utc.fr/~mottelet/scilab/download/${version}/scilab-${version}-x86_64.dmg";
24       sha256 = "sha256-tBeqzllMuogrGcJxGqEl2DdNXaiwok3yhzWSdlWY5Fc=";
25     };
26     x86_64-linux = fetchurl {
27       url = "https://www.scilab.org/download/${version}/scilab-${version}.bin.linux-x86_64.tar.gz";
28       sha256 = "sha256-PuGnz2YdAhriavwnuf5Qyy0cnCeRHlWC6dQzfr7bLHk=";
29     };
30   };
31   src =
32     srcs.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
34   meta = {
35     homepage = "http://www.scilab.org/";
36     description = "Scientific software package for numerical computations (Matlab lookalike)";
37     platforms = [
38       "aarch64-darwin"
39       "x86_64-darwin"
40       "x86_64-linux"
41     ];
42     sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
43     license = lib.licenses.gpl2Only;
44     mainProgram = "scilab";
45   };
47   darwin = stdenv.mkDerivation rec {
48     inherit
49       pname
50       version
51       src
52       meta
53       ;
55     nativeBuildInputs = [
56       makeWrapper
57       undmg
58     ];
60     sourceRoot = "scilab-${version}.app";
62     installPhase = ''
63       runHook preInstall
65       mkdir -p $out/{Applications/scilab.app,bin}
66       cp -R . $out/Applications/scilab.app
67       makeWrapper $out/{Applications/scilab.app/Contents/MacOS,bin}/scilab
69       runHook postInstall
70     '';
71   };
73   linux = stdenv.mkDerivation rec {
74     inherit
75       pname
76       version
77       src
78       meta
79       ;
81     nativeBuildInputs = [
82       autoPatchelfHook
83     ];
85     buildInputs =
86       [
87         alsa-lib
88         ncurses5
89         stdenv.cc.cc
90       ]
91       ++ (with xorg; [
92         libX11
93         libXcursor
94         libXext
95         libXft
96         libXi
97         libXrandr
98         libXrender
99         libXtst
100         libXxf86vm
101       ]);
103     installPhase = ''
104       runHook preInstall
106       mkdir -p $out
107       mv -t $out bin include lib share thirdparty
108       sed -i \
109         -e 's|\$(/bin/|$(|g' \
110         -e 's|/usr/bin/||g' \
111         $out/bin/{scilab,xcos}
112       sed -i \
113         -e "s|Exec=|Exec=$out/bin/|g" \
114         -e "s|Terminal=.*$|Terminal=true|g" \
115         $out/share/applications/*.desktop
117       runHook postInstall
118     '';
119   };
121 if stdenv.hostPlatform.isDarwin then darwin else linux