forked from grafana/loki
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
143 lines (125 loc) · 4.18 KB
/
flake.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
{
description = "Grafana Loki";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
# Nixpkgs / NixOS version to use.
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
golangci-lint-overlay = final: prev: {
golangci-lint = prev.callPackage
"${prev.path}/pkgs/development/tools/golangci-lint"
{
buildGoModule = args:
prev.buildGoModule (args // rec {
version = "1.45.2";
src = prev.fetchFromGitHub rec {
owner = "golangci";
repo = "golangci-lint";
rev = "v${version}";
sha256 =
"sha256-Mr45nJbpyzxo0ZPwx22JW2WrjyjI9FPpl+gZ7NIc6WQ=";
};
vendorSha256 =
"sha256-pcbKg1ePN8pObS9EzP3QYjtaty27L9sroKUs/qEPtJo=";
ldflags = [
"-s"
"-w"
"-X main.version=${version}"
"-X main.commit=v${version}"
"-X main.date=19700101-00:00:00"
];
});
};
};
helm-docs-overlay = final: prev: {
helm-docs = prev.callPackage
"${prev.path}/pkgs/applications/networking/cluster/helm-docs"
{
buildGoModule = args:
prev.buildGoModule (args // rec {
version = "1.8.1";
src = prev.fetchFromGitHub {
owner = "norwoodj";
repo = "helm-docs";
rev = "v${version}";
sha256 = "sha256-OpS/CYBb2Ll6ktvEhqkw/bWMSrFa4duidK3Glu8EnPw=";
};
vendorSha256 = "sha256-FpmeOQ8nV+sEVu2+nY9o9aFbCpwSShQUFOmyzwEQ9Pw=";
ldflags = [
"-w"
"-s"
"-X main.version=v${version}"
];
});
};
};
nix = import ./nix { inherit self nixpkgs system; };
pkgs = import nixpkgs {
inherit system;
overlays = [
golangci-lint-overlay
helm-docs-overlay
nix.overlay
];
config = { allowUnfree = true; };
};
in
with pkgs; {
# The default package for 'nix build'. This makes sense if the
# flake provides only one package or there is a clear "main"
# package.
defaultPackage = loki;
packages = { inherit loki; };
apps = {
lint = {
type = "app";
program = "${
(writeShellScriptBin "lint.sh" ''
${nixpkgs-fmt}/bin/nixpkgs-fmt --check ${self}/flake.nix ${self}/nix/*.nix
${statix}/bin/statix check ${self}
'')
}/bin/lint.sh";
};
loki = {
type = "app";
program = with pkgs; "${loki.overrideAttrs(old: rec { doCheck = false; })}/bin/loki";
};
promtail = {
type = "app";
program = with pkgs; "${loki.overrideAttrs(old: rec { doCheck = false; })}/bin/promtail";
};
logcli = {
type = "app";
program = with pkgs; "${loki.overrideAttrs(old: rec { doCheck = false; })}/bin/logcli";
};
loki-canary = {
type = "app";
program = with pkgs; "${loki.overrideAttrs(old: rec { doCheck = false; })}/bin/loki-canary";
};
};
devShell = mkShell {
nativeBuildInputs = [
gcc
go
systemd
yamllint
nixpkgs-fmt
statix
nettools
golangci-lint
helm-docs
faillint
chart-testing
chart-releaser
];
shellHook = ''
pushd $(git rev-parse --show-toplevel) > /dev/null || exit 1
./nix/generate-build-vars.sh
popd > /dev/null || exit 1
'';
};
});
}