blob: 48044b14daa44e1128e1d87c0dd21f31c127c569 (
plain) (
blame)
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
|
{ pkgs
, lib
, stdenv
, buildGoModule
, callPackage
, fetchFromGitHub
, nixosTests
, nodejs-18_x
}:
let
uiNodeDependencies = (import ./node-composition.nix {
inherit pkgs;
inherit (stdenv.hostPlatform) system;
# pin nodejs version
nodejs = nodejs-18_x;
}).nodeDependencies;
in
buildGoModule rec {
pname = "karma";
version = "0.112";
src = fetchFromGitHub {
owner = "prymitive";
repo = "karma";
rev = "v${version}";
hash = "sha256-Dzz5BgWrI5f9HlRm7Mna8JgUJlTVJia31v1In2zzcBY=";
};
vendorHash = "sha256-iYm19oAYPi3OUxp0wQsqgEkBLp3Fw2nCSdDI2vbV37w=";
nativeBuildInputs = [
nodejs-18_x
];
postPatch = ''
# Since we're using node2nix packages, the NODE_INSTALL hook isn't needed in the makefile
sed -i \
-e 's/$(NODE_INSTALL)//g' ./ui/Makefile \
-e 's~NODE_PATH := $(shell npm bin)~NODE_PATH := ./node_modules~g' ./ui/Makefile \
-e 's~NODE_MODULES := $(shell dirname `npm bin`)~NODE_MODULES := ./~g' ./ui/Makefile
'';
buildPhase = ''
# node will fail without this
export HOME=$(mktemp -d)
# build requires a writable .cache directory, so we'll create a
# temporary writable node_modules dir and link every package to it
# simply linking the node_modules directory would increase the closure size for uiNodeDependencies to >700MB
cp -r ${uiNodeDependencies}/lib/node_modules ./ui/
chmod -R +w ./ui/node_modules
mkdir -p ./ui/node_modules/.bin
pushd ./ui/node_modules/.bin
for x in ${uiNodeDependencies}/lib/node_modules/.bin/*; do
ln -sfv ./$(readlink "$x") ./$(basename "$x")
done
popd
mkdir -p ./ui/node_modules/.cache
# build package
VERSION="v${version}" make -j$NIX_BUILD_CORES
# clean up
rm -rf ./ui/node_modules
'';
installPhase = ''
install -Dm 755 ./karma $out/bin/karma
'';
passthru.tests.karma = nixosTests.karma;
meta = with lib; {
description = "Alert dashboard for Prometheus Alertmanager";
homepage = "https://karma-dashboard.io/";
license = licenses.asl20;
maintainers = with maintainers; [ nukaduka ];
};
}
|