-
Notifications
You must be signed in to change notification settings - Fork 2
/
default.nix
110 lines (91 loc) · 2.5 KB
/
default.nix
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
let
sources = import nix/sources.nix;
# +1 and -1 for the slash after the prefix
getRelativeFileName = prefix: fileName:
builtins.substring
(builtins.stringLength prefix + 1)
(builtins.stringLength fileName - builtins.stringLength prefix - 1)
fileName;
srcFilter = prefix: fileName: fileType:
let relativeFileName = getRelativeFileName prefix fileName; in
(
(fileType == "regular") &&
(
builtins.elem relativeFileName ["LICENSE" "README.md" "Makefile"] ||
builtins.match "^[^/]+[.]ttl$" relativeFileName != null
)
)
||
(
(fileType == "directory") &&
(builtins.match "^src(/.+)?$" relativeFileName != null)
)
||
(
(fileType == "regular") &&
(builtins.match "^src/.+[.](h|c)$" relativeFileName != null)
);
cleanSrc = pkgs: path:
assert builtins.isPath path;
pkgs.nix-gitignore.gitignoreFilterRecursiveSource
(srcFilter (toString path))
[ ./.gitignore ]
path;
availableCompilers = [ "gcc" "clang" ];
in
{ pkgs ? import sources.nixpkgs {}
, lib ? pkgs.lib
, src ? cleanSrc pkgs ./.
, debugBuild ? false
, compiler ? "gcc" # See “availableCompilers”
, gcc ? pkgs.gcc12 # “pkgs.gcc” is 11.x
, clang ? pkgs.clang_14 # “pkgs.clang” is 11.x
}:
let
compilerMap = {
gcc = "${gcc}/bin/gcc";
clang = "${clang}/bin/clang";
};
in
assert builtins.isBool debugBuild;
assert builtins.isString compiler;
assert builtins.elem compiler availableCompilers;
assert
builtins.all
(lib.flip builtins.elem availableCompilers)
(builtins.attrNames compilerMap);
let
esc = lib.escapeShellArg;
midi-trigger = pkgs.stdenv.mkDerivation rec {
name = "midi-trigger";
inherit src;
nativeBuildInputs = [
pkgs.gnumake
pkgs.pkg-config
];
buildInputs = [
pkgs.lv2
];
buildPhase = ''(
set -o nounset
make BUILD_DIR=. CXX=${esc compilerMap.${compiler}} ${
pkgs.lib.optionalString debugBuild (esc "DEBUG=Y")
}
)'';
installPhase = ''(
set -o nounset
LV2_DIR=$out/lib/lv2
mkdir -p -- "$LV2_DIR"
mv -- "$name".lv2 "$LV2_DIR"
)'';
meta = with lib; {
homepage = "https://github.com/unclechu/MIDI-Trigger";
description =
"LV2 plugin which generates MIDI notes by detected audio signal peaks";
maintainers = with maintainers; [ unclechu ];
license = licenses.gpl3Only;
platforms = platforms.linux ++ platforms.darwin;
};
};
in
midi-trigger