-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.nix
74 lines (63 loc) · 1.82 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
{ lib
, lilypond
, makeFontsConf
, stdenv
, symlinkJoin
, writeText
, loglevel ? "info"
, CNAME ? "scores.naptaker.band"
}:
let
version = builtins.readFile ./VERSION;
meta = with lib; {
description = "Scores from Naptime by Naptaker";
homepage = "https://github.com/naptaker/naptime";
maintainers = with maintainers; [ yurrriq ];
license = licenses.cc-by-nc-sa-40;
};
Makefile = writeText "Makefile" (builtins.readFile ./Makefile.src);
inherit (lib) optionalString;
mkScore = attrs@{ songName, pdfName ? songName, ... }:
stdenv.mkDerivation
(
attrs // {
pname = "naptime-${songName}";
inherit pdfName songName version;
src = ./. + "/songs/${songName}";
FONTCONFIG_FILE = makeFontsConf { fontDirectories = [ ]; };
nativeBuildInputs = [
lilypond
];
enableParallelBuilding = true;
buildPhase = ''
install -m644 ${Makefile} ./Makefile
install -dm755 $out
'';
installFlags = [
"job-count=$${NIX_BUILD_CORES:-1}"
"loglevel=${loglevel}"
"pdfName=${pdfName}"
"prefix=${placeholder "out"}"
];
postInstall = optionalString (loglevel != "debug") ''
rm -frv $out/*.log
'';
meta = meta // {
description = "${songName} score from Naptime by Naptaker";
};
}
);
in
symlinkJoin rec {
name = "naptime-${version}";
inherit meta version;
enableParallelBuilding = true;
passthru = with lib;
listToAttrs (map (song: nameValuePair (getName song) song) paths);
paths = with builtins;
map (songName: mkScore { inherit songName; })
(attrNames (readDir ./songs));
postBuild = ''
ln -s ${writeText "CNAME" CNAME} $out/CNAME
'';
}