forked from grafana/loki
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloki.nix
78 lines (63 loc) · 1.84 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
{ pkgs, version, imageTag }:
let
lambda-promtail-gomod = pkgs.buildGoModule {
inherit version;
pname = "lambda-promtail";
src = ./../../tools/lambda-promtail;
vendorHash = "sha256-m9nuCliQBhUo+B3K+x6c/9hOkr/iTR9kOLhiFcc1P30=";
doCheck = false;
installPhase = ''
runHook preInstall
cp -r --reflink=auto vendor $out
runHook postInstall
'';
};
in
pkgs.stdenv.mkDerivation {
inherit version;
pname = "loki";
src = ./../..;
buildInputs = with pkgs; [
bash
gcc
git
go_1_23
golangci-lint
gotools
nettools
yamllint
(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
export GOMODCACHE=$TMPDIR/gomodcache
export GOPROXY=off
cp -r ${lambda-promtail-gomod} tools/lambda-promtail/vendor
make clean loki
'';
doCheck = false;
checkPhase = ''
export GOCACHE=$TMPDIR/go-cache
export GOMODCACHE=$TMPDIR/gomodcache
export GOLANGCI_LINT_CACHE=$TMPDIR/go-cache
export GOPROXY=off
export BUILD_IN_CONTAINER=false
make lint test
'';
installPhase = ''
mkdir -p $out/bin
install -m755 cmd/loki/loki $out/bin/loki
'';
}