Created
May 24, 2020 14:43
-
-
Save yorickvP/92812b9dd12be9e14eb5df6c1fc79c36 to your computer and use it in GitHub Desktop.
picoscope.nix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let pkgs = import <nixpkgs> {}; | |
in | |
rec { | |
libpicoipp = pkgs.callPackage ./libpicoipp.nix {}; | |
picoscope = pkgs.callPackage ./picoscope.nix { | |
inherit libpicoipp; | |
mono = pkgs.mono6; | |
gtk-sharp-2_0 = pkgs.gtk-sharp-2_0.override { mono = pkgs.mono6; }; | |
}; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ stdenv, fetchurl, autoPatchelfHook, dpkg, mkl }: | |
stdenv.mkDerivation rec { | |
pname = "libpicoipp"; | |
version = "1.3.0-4r29"; | |
src = fetchurl { | |
url = "http://labs.picotech.com/debian/pool/main/libp/libpicoipp/${pname}_${version}_amd64.deb"; | |
sha256 = "0j5di2sjk0rgc7zx2szws98giqgl81d13hnr2fzgir7yvb24cv5s"; | |
}; | |
nativeBuildInputs = [ dpkg autoPatchelfHook ]; | |
buildInputs = [ /*mkl*/ stdenv.cc.cc.lib ]; | |
sourceRoot = "."; | |
unpackCmd = "dpkg-deb -x $src ."; | |
installPhase = '' | |
mkdir -p $out/lib | |
cp -d opt/picoscope/lib/* $out/lib | |
install -Dt $out/usr/share/doc/libpicoipp usr/share/doc/libpicoipp/copyright | |
''; | |
meta = with stdenv.lib; { | |
homepage = "http://www.picotech.com/linux.html"; | |
description = "library for picotech oscilloscope software"; | |
maintainers = [ maintainers.yorickvp ]; | |
platforms = [ "x86_64-linux" ]; | |
license = licenses.unfreeRedistributable; # todo: redistributable? | |
}; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ stdenv, fetchurl, dpkg, libpicoipp, gtk-sharp-2_0, mono, glib, makeWrapper | |
, gtk2-x11, gnome2, libusb1, zlib, writeTextDir, scopes ? [ "ps2000a" ] }: | |
let | |
sources = { | |
ps2000a = { | |
version = "2.1.34-5r2002"; | |
sha256 = "0gd9b1jvpd149d9pz6cssvy2h10ay4f6shzislbpb27ngvj66995"; | |
}; | |
ps2000 = { | |
version = "3.0.34-3r2002"; | |
sha256 = "0fz4gfvaml7vrdcx04vpagcmp5zakl5lff8knb6y2rbfmg82v6vm"; | |
}; | |
ps3000a = { | |
version = "2.1.34-6r2002"; | |
sha256 = "1a8vn0f2szq10xj7ji13jakjw7czms35ad4gw810ml6dfg431zmx"; | |
}; | |
}; | |
scopePkg = name: | |
{ version, sha256 }: | |
stdenv.mkDerivation rec { | |
pname = "lib${name}"; | |
inherit version; | |
src = fetchurl { | |
url = "http://labs.picotech.com/debian/pool/main/${ | |
builtins.substring 0 4 pname | |
}/${pname}/${pname}_${version}_amd64.deb"; | |
inherit sha256; | |
}; | |
# picoscope does a signature check, so we can't patchelf these | |
nativeBuildInputs = [ dpkg ]; | |
sourceRoot = "."; | |
unpackCmd = "dpkg-deb -x $src ."; | |
installPhase = '' | |
mkdir -p $out/lib | |
cp -d opt/picoscope/lib/* $out/lib | |
''; | |
meta = with stdenv.lib; { | |
homepage = "http://www.picotech.com/linux.html"; | |
description = "library for picotech oscilloscope ${name} series"; | |
maintainers = [ maintainers.yorickvp ]; | |
platforms = [ "x86_64-linux" ]; | |
license = licenses.unfreeRedistributable; # todo: redistributable? | |
}; | |
}; | |
scopePkgs = stdenv.lib.mapAttrs scopePkg sources; | |
in stdenv.mkDerivation rec { | |
pname = "picoscope"; | |
version = "6.14.17-4r544"; | |
src = fetchurl { | |
url = | |
"http://labs.picotech.com/debian/pool/main/p/${pname}/${pname}_${version}_all.deb"; | |
sha256 = "09qmdfw829h04gvp45mg6ygdvkzml63l1md2vqa45pksl24a7ghy"; | |
}; | |
scopeLibs = stdenv.lib.attrVals scopes scopePkgs; | |
buildInputs = [ makeWrapper gtk-sharp-2_0 mono glib libusb1 zlib ]; | |
# services.udev.packages = [ pkgs.picoscope.rules ]; | |
# users.groups.pico = {}; | |
# users.users.you.extraGroups = [ "pico" ]; | |
passthru.rules = writeTextDir "lib/udev/rules.d/95-pico.rules" '' | |
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0ce9", MODE="664",GROUP="pico" | |
''; | |
nativeBuildInputs = [ dpkg ]; | |
sourceRoot = "."; | |
unpackCmd = "dpkg-deb -x $src ."; | |
installPhase = '' | |
install -Dt $out/share/ usr/share/ | |
cp -dr opt/picoscope $out/ | |
MPATH="${gtk-sharp-2_0}/lib/mono/gtk-sharp-2.0:${ | |
stdenv.lib.makeLibraryPath ([ | |
glib | |
gtk2-x11 | |
gnome2.libglade | |
gtk-sharp-2_0 | |
libpicoipp | |
libusb1 | |
zlib | |
stdenv.cc.cc.lib | |
] ++ scopeLibs) | |
}" | |
makeWrapper $(command -v mono) $out/bin/picoscope --add-flags $out/lib/PicoScope.GTK.exe --prefix MONO_PATH : "$MPATH" --prefix LD_LIBRARY_PATH : "$MPATH" | |
''; | |
meta = with stdenv.lib; { | |
homepage = "http://www.picotech.com/linux.html"; | |
description = "gui for picotech oscilloscope"; | |
maintainers = [ maintainers.yorickvp ]; | |
platforms = [ "x86_64-linux" ]; | |
license = licenses.unfreeRedistributable; # todo: redistributable? | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment