forked from grafana/loki
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloki.nix
57 lines (47 loc) · 1.47 KB
/
loki.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
{ pkgs, version, imageTag }:
pkgs.stdenv.mkDerivation {
inherit version;
pname = "loki";
src = ./..;
buildInputs = with pkgs; [
bash
gcc
go
git
bash
systemd
yamllint
nettools
golangci-lint
(import ./faillint.nix {
inherit (pkgs) lib buildGoModule fetchFromGitHub;
})
];
configurePhase = with pkgs; ''
patchShebangs tools
substituteInPlace Makefile \
--replace "SHELL = /usr/bin/env bash -o pipefail" "SHELL = ${bash}/bin/bash -o pipefail" \
--replace "IMAGE_TAG := \$(shell ./tools/image-tag)" "IMAGE_TAG := ${imageTag}" \
--replace "GIT_REVISION := \$(shell git rev-parse --short HEAD)" "GIT_REVISION := ${version}" \
--replace "GIT_BRANCH := \$(shell git rev-parse --abbrev-ref HEAD)" "GIT_BRANCH := nix" \
substituteInPlace clients/cmd/fluentd/Makefile \
--replace "SHELL = /usr/bin/env bash -o pipefail" "SHELL = ${bash}/bin/bash -o pipefail"
'';
buildPhase = ''
export GOCACHE=$TMPDIR/go-cache
make clean loki logcli loki-canary promtail
'';
doCheck = true;
checkPhase = ''
export GOCACHE=$TMPDIR/go-cache
export GOLANGCI_LINT_CACHE=$TMPDIR/go-cache
make lint test
'';
installPhase = ''
mkdir -p $out/bin
install -m755 cmd/loki/loki $out/bin/loki
install -m755 cmd/logcli/logcli $out/bin/logcli
install -m755 cmd/loki-canary/loki-canary $out/bin/loki-canary
install -m755 clients/cmd/promtail/promtail $out/bin/promtail
'';
}