forked from espotek-org/Labrador
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
151 lines (123 loc) · 4.69 KB
/
flake.nix
File metadata and controls
151 lines (123 loc) · 4.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
{
description = "EspoTek Labrador - USB oscilloscope, signal generator, and more";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
};
in
{
devShells.default = pkgs.mkShell {
name = "labrador-dev";
nativeBuildInputs = with pkgs; [
# Build tools
gnumake
pkg-config
qt5.wrapQtAppsHook
# Qt tools
qt5.qmake
];
buildInputs = with pkgs; [
# Qt5 libraries
qt5.qtbase
# Required libraries (from PKGCONFIG in Labrador.pro)
libusb1
fftw
fftwFloat
eigen
# OpenMP support for fftw3_omp
llvmPackages.openmp
# For building
gcc
];
# Set up environment for Qt and pkg-config
shellHook = ''
echo "╔══════════════════════════════════════════════════════════════════╗"
echo "║ EspoTek Labrador Development Environment ║"
echo "╚══════════════════════════════════════════════════════════════════╝"
echo ""
echo "To build and install locally:"
echo " cd Desktop_Interface"
echo " qmake PREFIX=\$PWD/_install"
echo " make -j\$(nproc)"
echo " make install"
echo ""
echo "To run after installing:"
echo " ./_install/bin/labrador"
echo ""
echo "Or use 'nix build' from repo root for a proper package."
echo ""
# Help Qt find plugins
export QT_PLUGIN_PATH="${pkgs.qt5.qtbase}/${pkgs.qt5.qtbase.qtPluginPrefix}"
# Add local install to data dirs so Qt can find resources
export XDG_DATA_DIRS="$PWD/Desktop_Interface/_install/share:''${XDG_DATA_DIRS:-/usr/local/share:/usr/share}"
'';
};
packages.default = pkgs.stdenv.mkDerivation {
pname = "labrador";
version = "unstable-${self.shortRev or "dirty"}";
src = ./.;
nativeBuildInputs = with pkgs; [
gnumake
pkg-config
qt5.wrapQtAppsHook
qt5.qmake
];
buildInputs = with pkgs; [
qt5.qtbase
libusb1
fftw
fftwFloat
eigen
llvmPackages.openmp
];
# Patch the .pro file to use system libraries and skip udev rules installation
preConfigure = ''
cd Desktop_Interface
'';
configurePhase = ''
runHook preConfigure
qmake PREFIX=$out
runHook postConfigure
'';
buildPhase = ''
runHook preBuild
make -j$NIX_BUILD_CORES
runHook postBuild
'';
installPhase = ''
runHook preInstall
# Install binary
mkdir -p $out/bin
cp labrador $out/bin/
# Install firmware
mkdir -p $out/share/EspoTek/Labrador/firmware
cp resources/firmware/labrafirm* $out/share/EspoTek/Labrador/firmware/
# Install waveforms
mkdir -p $out/share/EspoTek/Labrador/waveforms
cp resources/waveforms/* $out/share/EspoTek/Labrador/waveforms/
# Install icons
mkdir -p $out/share/icons/hicolor/48x48/apps
mkdir -p $out/share/icons/hicolor/256x256/apps
cp build_linux/icon48/espotek-labrador.png $out/share/icons/hicolor/48x48/apps/
cp build_linux/icon256/espotek-labrador.png $out/share/icons/hicolor/256x256/apps/
# Install desktop file
mkdir -p $out/share/applications
cp build_linux/espotek-labrador.desktop $out/share/applications/
runHook postInstall
'';
meta = with pkgs.lib; {
description = "EspoTek Labrador - oscilloscope, signal generator, logic analyzer, and more";
homepage = "https://github.com/espotek-org/Labrador";
license = licenses.gpl3;
platforms = platforms.linux;
mainProgram = "labrador";
};
};
});
}