Import code

This commit is contained in:
2023-08-16 08:42:22 +03:00
parent e68ca13c9c
commit 60d331434c
10 changed files with 471 additions and 0 deletions

8
.gitignore vendored Normal file
View File

@@ -0,0 +1,8 @@
.DS_Store
.idea
*.log
tmp/
source/
result/

21
default.nix Normal file
View File

@@ -0,0 +1,21 @@
{ pkgs ? import <nixpkgs> {},
kernel ? (import <nixpkgs> {}).linuxPackages_latest }:
#pkgs.libsForQt5.callPackage ./qtpdwidgets.nix {}
#pkgs.libsForQt5.callPackage ./testmanager.nix {}
#pkgs.libsForQt5.callPackage ./dls.nix {}
#pkgs.callPackage ./pdcom.nix {}
#pkgs.callPackage ./etherlab.nix {}
let
packages = rec {
ethercat = pkgs.callPackage ./ethercat.nix {
kernel = pkgs.linux_latest;
};
testmanager = pkgs.libsForQt5.callPackage ./testmanager.nix {};
dls = pkgs.libsForQt5.callPackage ./dls.nix {};
etherlab = pkgs.libsForQt5.callPackage ./etherlab.nix {};
qtpdwidgets = pkgs.libsForQt5.callPackage ./qtpdwidgets.nix {};
pdcom = pkgs.callPackage ./pdcom.nix {};
pdserv = pkgs.callPackage ./pdserv.nix {};
};
in
packages

66
dls.nix Normal file
View File

@@ -0,0 +1,66 @@
{
pkgs,
lib,
qtbase,
qttools,
wrapQtAppsHook,
stdenv,
pdcom ? pkgs.callPackage ./pdcom.nix {},
}:
with pkgs;
let
version="1.5.0";
#rev = "aa943dbb6919b83cf90028fda1acbecc554177c5"; #1.4.0
rev = "bc458cc89e667d8dd03c9fdaf9d87cac7754b6a5"; #1.5.0
in
stdenv.mkDerivation {
name = "dls";
inherit version;
src = fetchGit {
url = "https://gitlab.com/etherlab.org/dls.git";
ref = "refs/tags/${version}";
inherit rev;
#sha256 = "05w6k4925lwjlm0n3xp4k83ymcxrc6qzz825rv7yrh4pdgzdvwxi";
};
enableParallelBuilding = true;
#nativeBuildInputs = [ wrapQtAppsHook bash pkg-config autoreconfHook ];
nativeBuildInputs = [ wrapQtAppsHook bash pkg-config cmake ];
buildInputs = [ qtbase qttools libxml2 fftw pcre zlib protobuf uriparser hdf5-cpp fltk pdcom ];
#buildInputs = [ libxcrypt expat gnutls cyrus_sasl log4cplus db libyaml ];
#
cmakeFlags = [ "-DREVISION=${rev}" ];
#configureFlags = [
# "--with-fltk-dir=${fltk}"
# "--with-fftw3-dir=${fftw.dev}"
# "--with-zlib-dir=${zlib.dev}"
#];
#makeFlags = [ "REVISION=${rev}" ];
#preAutoreconf = ''
# bash bootstrap.sh
#'';
#preConfigure = ''
# echo ${rev} > revision
## #bash bootstrap.sh
## set -e
## set -x
## touch ChangeLog
## mkdir -p autoconf
#'';
#preConfigure = ''
# qmake
# #PREFIX=$out qmake
#'';
meta = with lib; {
description = "Acquisition, compression, storage, visualization and export of long-time data via graphical user interfaces.";
platforms = platforms.linux;
};
}

105
ethercat.nix Normal file
View File

@@ -0,0 +1,105 @@
{
pkgs,
lib,
stdenv,
# interface name (eg. "eth0") or MAC address (eg. "e9:22:a4:62:74:23"). ff:ff:ff:ff:ff:ff means first available NIC
master_device0 ? "ff:ff:ff:ff:ff:ff",
kernel
}:
# Based on: https://aur.archlinux.org/packages/etherlab-ethercat
with pkgs;
let
version="1.5";
device_modules="generic";
in
stdenv.mkDerivation {
name = "ethercat-master-module-${kernel.modDirVersion}";
inherit version;
inherit master_device0;
src = fetchGit {
url = "https://gitlab.com/etherlab.org/ethercat.git";
ref = "stable-${version}";
rev = "c8a512ac077f2ab51bb072bfbef1a687f9f1c090";
#ref = "refs/tags/1.9";
#sha256 = lib.fakeSha256;
};
enableParallelBuilding = true;
buildInputs = [ git pkg-config bash autoreconfHook kernel.moduleBuildDependencies kmod iproute2 ];
patches = [ ];
hardeningDisable = [ "pic" "format" ];
setSourceRoot = ''
export sourceRoot=$(pwd)/source
'';
postUnpack = ''
cd $sourceRoot
echo 'KERNEL=="EtherCAT[0-9]*", GROUP="ethercat", MODE="0660"' > 99-EtherCAT.rules
'';
preConfigure = ''
bash bootstrap
'';
configureFlags = [
"--prefix=${placeholder "out"}/"
"--sysconfdir=${placeholder "out"}/etc"
"--sbindir=${placeholder "out"}/bin"
"--libdir=${placeholder "out"}/lib"
"--enable-kernel"
"--enable-generic"
"--disable-8139too"
"--enable-tool"
"--enable-userlib"
"--with-linux-dir=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"
];
#++ lib.optionals (!guiSupport) [ "--disable-gui" "--enable-systemd" ] # TODO add flags for nongeneric NICs like this
makeFlags = [ "all" "modules" ];
# Make systemd service unit
postBuild = ''
cd script
make all ethercat.service
cd ..
'';
checkPhase = ''
make check
'';
installFlags = [ "INSTALL_MOD_PATH=${placeholder "out"}" ];
installTargets = [ "install" "modules_install" ];
postInstall = ''
mkdir -p $out/lib/udev/rules.d/
cp 99-EtherCAT.rules $out/lib/udev/rules.d/
mkdir -p $out/lib/systemd/system
mkdir -p $out/etc/systemd/system
cp script/ethercat.service $out/etc/systemd/system/
substituteInPlace $out/etc/systemd/system/ethercat.service --replace '#Requires' 'Requires'
substituteInPlace $out/etc/systemd/system/ethercat.service --replace '#After' 'After'
cp $out/etc/systemd/system/ethercat.service $out/lib/systemd/system/ethercat.service
substituteInPlace $out/etc/ethercat.conf --replace 'MASTER0_DEVICE=""' 'MASTER0_DEVICE="${master_device0}"'
substituteInPlace $out/etc/ethercat.conf --replace 'DEVICE_MODULES=""' 'DEVICE_MODULES="${device_modules}"'
substituteInPlace $out/bin/ethercatctl --replace 'LSMOD=/sbin/lsmod' 'LSMOD=lsmod'
substituteInPlace $out/bin/ethercatctl --replace 'MODPROBE=/sbin/modprobe' 'MODPROBE=modprobe'
substituteInPlace $out/bin/ethercatctl --replace 'RMMOD=/sbin/rmmod' 'RMMOD=rmmod'
substituteInPlace $out/bin/ethercatctl --replace 'MODINFO=/sbin/modinfo' 'MODINFO=modinfo'
substituteInPlace $out/bin/ethercatctl --replace 'IP=/bin/ip' 'IP=ip'
'';
meta = with lib; {
description = "Kernel modules and tools for IgH EtherCAT(R) Master component";
platforms = platforms.linux;
};
}

31
etherlab.nix Normal file
View File

@@ -0,0 +1,31 @@
{
pkgs,
lib,
stdenv,
pdserv ? pkgs.callPackage ./pdserv.nix {},
}:
with pkgs;
let
version="2.3.4";
rev = "aa5d574b096db1ea91479e4fb3c1aa63abedf4d0";
in
stdenv.mkDerivation {
name = "etherlab";
inherit version;
src = fetchGit {
url = "https://gitlab.com/etherlab.org/etherlab.git";
ref = "refs/tags/${version}";
inherit rev;
};
enableParallelBuilding = true;
nativeBuildInputs = [ bash cmake pkg-config ];
buildInputs = [ pdserv ];
meta = with lib; {
description = "Generation of realtime applications via a C-Interface or via MATLAB/Simulink with Real-Time Workshop.";
platforms = platforms.linux;
};
}

77
pdcom.nix Normal file
View File

@@ -0,0 +1,77 @@
{
pkgs,
lib,
stdenv
}:
with pkgs;
let
version="stable-3.0";
#version="5.1.0";
#version="stable-5.0";
#version="master";
in
stdenv.mkDerivation {
name = "pdcom";
inherit version;
src = fetchGit {
url = "https://gitlab.com/etherlab.org/pdcom.git";
ref = "${version}";
rev = "66bb0428137c0d795bddd0312875df9388c7e9b6"; #stable-3.0
#rev = "b9e4ca1d61d34474b7d50f7806f26aaf4cfe5100"; #5.1.0
#rev = "0e96e5d4bc2ad038ef6583d771f60fb0c2c563b1"; #stable-5.0
#rev = "89a79c902b536f9913ef4a4a9a868f5c42105368"; #master
#ref = "refs/tags/${version}";
#rev = "b9e4ca1d61d34474b7d50f7806f26aaf4cfe5100";
#ref = "refs/tags/1.9";
#sha256 = lib.fakeSha256;
};
enableParallelBuilding = true;
nativeBuildInputs = [ bash autoreconfHook pkg-config ];
#buildInputs = [ glibc glibc.static expat gnutls cyrus_sasl ];
buildInputs = [ libxcrypt expat gnutls cyrus_sasl ];
#configurePhase = ''
# ./configure
#'';
#patches = [ ];
#setSourceRoot = ''
# export sourceRoot=$(pwd)/source
#'';
#postUnpack = ''
# cd $sourceRoot
#'';
#preBuild = "set -x";
#preConfigure = ''
# mkdir build
# cd build
#'';
#cmakeFlags = [ "-DBUILD_TESTING=OFF" "-DCMAKE_BUILD_TYPE=Release" ];
#cmakeFlags = [ "-DCMAKE_POSITION_INDEPENDENT_CODE=ON" ];
#configurePhase = ''
# cmake -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release ..
#'';
#makeFlags = [ "-DCMAKE_INSTALL_PREFIX=${placeholder "out"}" ];
#installTargets = [ "install" ];
#postInstall = ''
# ln -s $out/include/pdcom5 $out/include/pdcom
# ln -s $out/include/pdcom5.h $out/include/pdcom.h
#'';
meta = with lib; {
description = "Flexible C++ library for platform- and protocol-independent process data exchange.";
platforms = platforms.linux;
};
}

33
pdserv.nix Normal file
View File

@@ -0,0 +1,33 @@
{
pkgs,
lib,
stdenv
}:
with pkgs;
let
version="master";
in
stdenv.mkDerivation {
name = "pdserv";
inherit version;
src = fetchGit {
url = "https://gitlab.com/etherlab.org/pdserv.git";
ref = "${version}";
rev = "8642c3fe7456d85f5147fdee39fe9918945d175c"; #master
};
enableParallelBuilding = true;
#nativeBuildInputs = [ bash cmake autoreconfHook ];
nativeBuildInputs = [ bash cmake pkg-config ];
buildInputs = [ libxcrypt expat gnutls cyrus_sasl log4cplus db libyaml ];
#cmakeFlags = [ "-DENABLE_DOC=0" ];
meta = with lib; {
description = "Server library (C/C++) for process-data of user-space realtime applications.";
platforms = platforms.linux;
};
}

33
qtpdcom.nix Normal file
View File

@@ -0,0 +1,33 @@
{
stdenv,
lib,
pkgs,
qtbase,
qttools,
wrapQtAppsHook,
pdcom ? pkgs.callPackage ./pdcom.nix {},
}:
with pkgs;
let
version="main";
in
stdenv.mkDerivation {
name = "qtpdcom";
inherit version;
src = fetchGit {
url = "https://gitlab.com/etherlab.org/qtpdcom.git";
ref = "${version}";
rev = "da7b15d764220371050674ce4618562e0d87beaf"; #main
};
enableParallelBuilding = true;
buildInputs = [ qtbase qttools pdcom ];
nativeBuildInputs = [ cmake wrapQtAppsHook ];
meta = with lib; {
description = "";
platforms = platforms.linux;
};
}

49
qtpdwidgets.nix Normal file
View File

@@ -0,0 +1,49 @@
{
stdenv,
lib,
pkgs,
qtbase,
qttools,
wrapQtAppsHook,
pdcom ? pkgs.callPackage ./pdcom.nix {},
#qtpdcom ? pkgs.libsForQt5.callPackage ./qtpdcom.nix {},
}:
with pkgs;
let
version="stable-1.3";
in
stdenv.mkDerivation {
name = "qtpdwidgets";
inherit version;
src = fetchGit {
url = "https://gitlab.com/etherlab.org/qtpdwidgets.git";
ref = "${version}";
rev = "1f963f3acb6b250eb7447829d5c40bde1e6dd8d1"; #stable-1.3
};
enableParallelBuilding = true;
buildInputs = [ qtbase qttools pdcom ];
nativeBuildInputs = [ wrapQtAppsHook ];
preConfigure = ''
#qmake
PREFIX=$out qmake
substituteInPlace Makefile.Release --replace 'DESTDIR =' 'DESTDIR =${placeholder "out"}'
'';
installFlags = [ "INSTALL_ROOT=${placeholder "out"}" ];
postInstall = ''
#ln -s $out/include/QtPdWidgets2 $out/include/QtPdWidgets
mv $out/usr/local/* $out/
rm -r $out/usr
'';
meta = with lib; {
description = "Process-data aware widget library for Qt, that uses PdCom for process variable access.";
platforms = platforms.linux;
};
}

48
testmanager.nix Normal file
View File

@@ -0,0 +1,48 @@
{
stdenv,
lib,
pkgs,
qtbase,
qttools,
wrapQtAppsHook,
pdcom ? pkgs.callPackage ./pdcom.nix {},
qtpdwidgets ? pkgs.libsForQt5.callPackage ./qtpdwidgets.nix {},
}:
with pkgs;
let
version="master";
rev = "ea10d2b5b872ea2269bf08169d18d52212f8a0af"; #master
in
stdenv.mkDerivation {
name = "testmanager";
inherit version;
src = fetchGit {
url = "https://gitlab.com/etherlab.org/testmanager.git";
ref = "${version}";
inherit rev;
};
enableParallelBuilding = true;
buildInputs = [ qtbase qttools python3 pdcom qtpdwidgets ];
nativeBuildInputs = [ wrapQtAppsHook ];
installFlags = [ "INSTALL_ROOT=${placeholder "out"}" ];
preConfigure = ''
#set -x
echo ${rev} > revision
VERSION=${version} qmake
'';
postInstall = ''
mv $out/usr/local/* $out/
rm -r $out/usr
'';
meta = with lib; {
description = "Dynamic operation and visualization software. Connects to a realtime application via TCP/IP";
platforms = platforms.linux;
};
}