-
Notifications
You must be signed in to change notification settings - Fork 4
/
flake.nix
145 lines (123 loc) · 3.91 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
144
145
{
description = "ddapm-test-agent";
nixConfig.bash-prompt-prefix = "\[ddapm-test-agent\] ";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/24.05";
flake-utils.url = "github:numtide/flake-utils";
treefmt-nix.url = "github:numtide/treefmt-nix";
nix-github-actions.url = "github:nix-community/nix-github-actions/";
nix-github-actions.inputs.nixpkgs.follows = "nixpkgs";
};
outputs =
{
self,
nixpkgs,
flake-utils,
treefmt-nix,
nix-github-actions,
}:
(flake-utils.lib.eachDefaultSystem (
system:
let
# setup dependencies
pkgs = nixpkgs.legacyPackages.${system};
python = pkgs.python312;
treefmt = treefmt-nix.lib.evalModule pkgs ./treefmt.nix;
# include dependencies not publish to nixpkgs
ddsketch = pkgs.callPackage ./ddsketch.nix { inherit python pkgs; };
ddtrace = pkgs.callPackage ./ddtrace.nix { inherit python pkgs ddsketch; };
pretendVersion = "0.0.0";
# build test agent
ddapm-test-agent_base = (
attrs:
python.pkgs.buildPythonApplication {
inherit (attrs) doCheck;
name = "ddapm-test-agent";
version = pretendVersion;
src = ./.;
postPatch = ''
# remove riot since its not available from nixpkgs
substituteInPlace test_deps.txt --replace "riot==0.13.0" ""
'';
dontUseCmakeConfigure = true;
propagatedBuildInputs = with python.pkgs; [
aiohttp
msgpack
ddsketch
requests
yarl
];
nativeBuildInputs = with python.pkgs; [
setuptools
setuptools_scm
];
checkInputs = [
python.pkgs.pytest
ddtrace
pkgs.cmake
];
installCheckPhase = ''
runHook preCheck
export TEST_AGENT="$out/bin/ddapm-test-agent"
$TEST_AGENT --version
# use nix provided agent for testing
substituteInPlace \
tests/test_snapshot_integration.py \
tests/test_agent.py \
tests/conftest.py \
--replace "ddapm-test-agent" "$TEST_AGENT"
${python.pkgs.pytest}/bin/pytest -vv
runHook postCheck
'';
env.SETUPTOOLS_SCM_PRETEND_VERSION = pretendVersion;
}
);
ddapm-test-agent = ddapm-test-agent_base { doCheck = false; };
skopeo = pkgs.skopeo;
image = pkgs.dockerTools.buildImage {
name = "ghcr.io/pawelchcki/ddapm-test-agent";
tag = "latest";
copyToRoot = pkgs.buildEnv {
name = "root";
paths = [ ddapm-test-agent ];
pathsToLink = [ "/bin" ];
};
config = {
entrypoint = [ "/bin/ddapm-test-agent" ];
};
};
in
{
packages = {
inherit
python
ddapm-test-agent
ddtrace
ddsketch
image
skopeo
;
default = ddapm-test-agent;
reno = pkgs.reno;
};
formatter = treefmt.config.build.wrapper;
checks = {
ddapm-test-agent = ddapm-test-agent_base { doCheck = true; };
formatting = treefmt.config.build.check self;
};
devShells.default = pkgs.mkShell {
venvDir = "./.venv";
nativeBuildInputs = ddapm-test-agent.nativeBuildInputs ++ [ ddapm-test-agent ];
};
}
))
// {
githubActions = nix-github-actions.lib.mkGithubMatrix {
attrPrefix = "";
checks = {
inherit (self.checks) x86_64-linux;
aarch64-darwin = builtins.removeAttrs (self.checks.aarch64-darwin) [ "formatting" ];
};
};
};
}