sqlite_orm: 1.9 -> 1.9.1 (#379250)
[NixPkgs.git] / pkgs / by-name / pi / picoscope / package.nix
blob65e51ef983cb42c29235133f3b972f53e875918f
2   stdenv,
3   lib,
4   fetchurl,
5   dpkg,
6   makeWrapper,
7   mono,
8   gtk-sharp-3_0,
9   glib,
10   libusb1,
11   zlib,
12   gtk3-x11,
13   callPackage,
14   writeTextDir,
15   scopes ? [
16     "picocv"
17     "ps2000"
18     "ps2000a"
19     "ps3000"
20     "ps3000a"
21     "ps4000"
22     "ps4000a"
23     "ps5000"
24     "ps5000a"
25     "ps6000"
26     "ps6000a"
27   ],
30 let
31   shared_meta = lib: {
32     homepage = "https://www.picotech.com/downloads/linux";
33     maintainers = with lib.maintainers; [ wirew0rm ] ++ lib.teams.lumiguide.members;
34     platforms = [ "x86_64-linux" ];
35     license = lib.licenses.unfree;
36   };
38   libpicoipp = callPackage (
39     {
40       stdenv,
41       lib,
42       fetchurl,
43       autoPatchelfHook,
44       dpkg,
45     }:
46     stdenv.mkDerivation rec {
47       pname = "libpicoipp";
48       inherit (sources.libpicoipp) version;
49       src = fetchurl { inherit (sources.libpicoipp) url sha256; };
50       nativeBuildInputs = [
51         dpkg
52         autoPatchelfHook
53       ];
54       buildInputs = [ (lib.getLib stdenv.cc.cc) ];
56       installPhase = ''
57         runHook preInstall
58         mkdir -p $out/lib
59         cp -d opt/picoscope/lib/* $out/lib
60         install -Dt $out/usr/share/doc/libpicoipp usr/share/doc/libpicoipp/copyright
61         runHook postInstall
62       '';
63       meta = shared_meta lib // {
64         sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
65         description = "library for picotech oscilloscope software";
66       };
67     }
68   ) { };
70   # If we don't have a platform available, put a dummy version here, so at
71   # least evaluation succeeds.
72   sources =
73     (lib.importJSON ./sources.json).${stdenv.system} or (throw "unsupported system ${stdenv.system}");
75   scopePkg =
76     name:
77     {
78       url,
79       version,
80       sha256,
81     }:
82     stdenv.mkDerivation rec {
83       pname = "lib${name}";
84       inherit version;
85       src = fetchurl { inherit url sha256; };
86       # picoscope does a signature check, so we can't patchelf these
87       nativeBuildInputs = [ dpkg ];
88       installPhase = ''
89         runHook preInstall
90         mkdir -p $out/lib
91         cp -d opt/picoscope/lib/* $out/lib
92          runHook postInstall
93       '';
94       meta =
95         with lib;
96         shared_meta lib
97         // {
98           description = "library for picotech oscilloscope ${name} series";
99         };
100     };
102   scopePkgs = lib.mapAttrs scopePkg sources;
105 stdenv.mkDerivation rec {
106   pname = "picoscope";
107   inherit (sources.picoscope) version;
109   src = fetchurl { inherit (sources.picoscope) url sha256; };
111   nativeBuildInputs = [
112     dpkg
113     makeWrapper
114   ];
115   buildInputs = [
116     gtk-sharp-3_0
117     mono
118     glib
119     libusb1
120     zlib
121   ];
123   scopeLibs = lib.attrVals (map (x: "lib${x}") scopes) scopePkgs;
124   MONO_PATH =
125     "${gtk-sharp-3_0}/lib/mono/gtk-sharp-3.0:"
126     + (lib.makeLibraryPath (
127       [
128         glib
129         gtk3-x11
130         gtk-sharp-3_0
131         libusb1
132         zlib
133         libpicoipp
134       ]
135       ++ scopeLibs
136     ));
138   installPhase = ''
139     runHook preInstall
140     mkdir -p $out/
141     cp -dr usr/share $out/share
142     cp -dr opt/picoscope/* $out/
143     makeWrapper "$(command -v mono)" $out/bin/picoscope \
144       --add-flags $out/lib/PicoScope.GTK.exe \
145       --prefix MONO_PATH : "$MONO_PATH" \
146       --prefix LD_LIBRARY_PATH : "$MONO_PATH" \
147       --set LANG C
148     runHook postInstall
149   '';
151   # usage:
152   # services.udev.packages = [ pkgs.picoscope.rules ];
153   # users.groups.pico = {};
154   # users.users.you.extraGroups = [ "pico" ];
155   passthru.rules = writeTextDir "lib/udev/rules.d/95-pico.rules" ''
156     SUBSYSTEMS=="usb", ATTRS{idVendor}=="0ce9", MODE="664",GROUP="pico"
157   '';
159   meta =
160     with lib;
161     shared_meta lib
162     // {
163       description = "Oscilloscope application that works with all PicoScope models";
164       longDescription = ''
165         PicoScope for Linux is a powerful oscilloscope application that works
166         with all PicoScope models. The most important features from PicoScope
167         for Windows are included—scope, spectrum analyzer, advanced triggers,
168         automated measurements, interactive zoom, persistence modes and signal
169         generator control. More features are being added all the time.
171         Waveform captures can be saved for off-line analysis, and shared with
172         PicoScope for Linux, PicoScope for macOS and PicoScope for Windows
173         users, or exported in text, CSV and MathWorks MATLAB 4 formats.
174       '';
175       sourceProvenance = with sourceTypes; [ binaryBytecode ];
176     };