-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.nix
150 lines (127 loc) · 4.38 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
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
let
sources = import nix/sources.nix;
availableBuildTools = [ "cabal" "stack" ];
in
{ pkgs ? import sources.nixpkgs {}
, ghcVersion ? null # e.g. “--argstr ghcVersion ghc923”
, haskellPackages ?
if isNull ghcVersion
then pkgs.haskellPackages # The default one from the nixpkgs pin
else
assert builtins.isString ghcVersion;
pkgs.haskell.packages.${ghcVersion}
# When this file is called by nix-shell it’s set to `true` automatically.
, inNixShell ? false
# These flags are only for nix-shell (when `inNixShell` is `true`).
# `with-APPNAME` means APPNAME executable will be built and added to the shell.
, with-midihaskey ? false
, with-midiplayer-jack-hs ? false
, with-midiplayer-jack-cpp ? false
, buildTools ? [ "cabal" ] # See “availableBuildTools”
, withHoogle ? true # Generate Hoogle index
, withHLS ? true # Haskell Language Server (LSP) https://github.com/haskell/haskell-language-server
}:
assert builtins.all (x: builtins.elem x availableBuildTools) buildTools;
let
inherit (pkgs) lib;
inherit (pkgs.haskell.lib) justStaticExecutables doJailbreak overrideCabal overrideSrc;
cleanSource = pkgs.callPackage nix/clean-source.nix {};
# Some fixes to make it build successfully with GHC 9.2.3
overridesForGHC923 = self: super: {
linux-evdev = overrideCabal (overrideSrc super.linux-evdev {
src = fetchTarball {
url = "https://github.com/bgamari/linux-evdev/archive/89869658c421b70e29fadd3e99ed75139048aced.tar.gz";
sha256 = "1i37fibalrqw86kkp02nzgahdv4ja6ckh6yfrb3165hi8jkq8r58";
};
}) {
patches = [ nix/linux-evdev-cabal-fix.patch ];
};
qm-interpolated-string = overrideCabal super.qm-interpolated-string {
version = "0.3.1.0";
sha256 = "sha256-U1x8iSZvuaT7G7RotNKR/C24CTVfECFnlrnNetecXYo=";
};
midi = overrideCabal super.midi {
version = "0.2.2.3";
sha256 = "sha256-dRLrW0JbJtSWhb269BpTLSe9AtfyevpasZ/Otg9Mcos=";
};
jack = doJailbreak super.jack;
singletons-th = overrideCabal super.singletons-th {
version = "3.1";
sha256 = "sha256-6tRWxCHrKOV1gJNexeTYyfnoSITZZ4iPU/0f3pQ+HdY=";
};
};
hsPkgs = (haskellPackages.override {
overrides =
if builtins.elem ghcVersion ["ghc923"]
then overridesForGHC923
else _: _: {};
}).extend (self: super:
(
let
dir = ./midihaskey-utils;
name = baseNameOf (toString dir);
pkg = self.callCabal2nix name (cleanSource dir) {};
in
{ ${name} = pkg; }
) // (
let
dir = ./midihaskey;
name = baseNameOf (toString dir);
pkg = self.callCabal2nix name (cleanSource dir) {};
in
{ ${name} = pkg // { exe = justStaticExecutables pkg; }; }
) // (
let
dir = ./midiplayer-jack-hs;
name = baseNameOf (toString dir);
pkg = self.callCabal2nix name (cleanSource dir) {};
in
{ ${name} = pkg // { exe = justStaticExecutables pkg; }; }
)
);
midiplayer-jack-cpp = pkgs.stdenv.mkDerivation {
name = "MIDIHaskKey-midiplayer-jack-cpp";
src = cleanSource ./midiplayer-jack-cpp;
nativeBuildInputs = [ pkgs.gnumake pkgs.pkg-config ];
buildInputs = [ pkgs.jack2 ];
buildPhase = ''
make
'';
installPhase = ''(
set -o nounset
mkdir -p -- "$out"/bin
cp -- build/midiplayer-jack-cpp "$out"/bin
)'';
meta = with lib; {
homepage = "https://github.com/metachronica/audio-midihaskey";
description = "MIDIHasKey JACK MIDI player written in C++";
maintainers = with maintainers; [ unclechu ];
license = licenses.gpl3;
platforms = platforms.linux;
};
};
shell = hsPkgs.shellFor {
name = "MIDIHasKey-shell";
packages = p: [
p.midihaskey-utils
p.midiplayer-jack-hs
p.midihaskey
];
inherit withHoogle;
buildInputs =
lib.optional (builtins.elem "cabal" buildTools) hsPkgs.cabal-install
++ lib.optional (builtins.elem "stack" buildTools) hsPkgs.stack
++ lib.optional withHLS hsPkgs.haskell-language-server
++ lib.optional with-midihaskey hsPkgs.midihaskey.exe
++ lib.optional with-midiplayer-jack-hs hsPkgs.midiplayer-jack-hs.exe
++ lib.optional with-midiplayer-jack-cpp midiplayer-jack-cpp;
};
in
(if inNixShell then shell else {}) // {
inherit shell midiplayer-jack-cpp;
inherit (hsPkgs)
midihaskey-utils
midihaskey
midiplayer-jack-hs
;
}