tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
lol
0
fork
atom
overview
issues
pulls
pipelines
nomad-autoscaler: init at 0.3.3
Jonathan Ringer
4 years ago
b432c3ca
c223fd60
+114
2 changed files
expand all
collapse all
unified
split
pkgs
applications
networking
cluster
nomad-autoscaler
default.nix
top-level
all-packages.nix
+112
pkgs/applications/networking/cluster/nomad-autoscaler/default.nix
···
1
1
+
{ lib, fetchFromGitHub, buildGoModule, go, removeReferencesTo, buildEnv }:
2
2
+
3
3
+
let
4
4
+
package = buildGoModule rec {
5
5
+
pname = "nomad-autoscaler";
6
6
+
version = "0.3.3";
7
7
+
8
8
+
outputs = [
9
9
+
"out"
10
10
+
"bin"
11
11
+
"aws_asg"
12
12
+
"azure_vmss"
13
13
+
"datadog"
14
14
+
"fixed_value"
15
15
+
"gce_mig"
16
16
+
"nomad_apm"
17
17
+
"nomad_target"
18
18
+
"pass_through"
19
19
+
"prometheus"
20
20
+
"target_value"
21
21
+
"threshold"
22
22
+
];
23
23
+
24
24
+
src = fetchFromGitHub {
25
25
+
owner = "hashicorp";
26
26
+
repo = "nomad-autoscaler";
27
27
+
rev = "v${version}";
28
28
+
sha256 = "sha256-bN/U6aCf33B88ouQwTGG8CqARzWmIvXNr5JPr3l8cVI=";
29
29
+
};
30
30
+
31
31
+
vendorSha256 = "sha256-Ls8gkfLyxfQD8krvxjAPnZhf1r1s2MhtQfMMfp8hJII=";
32
32
+
33
33
+
subPackages = [ "." ];
34
34
+
35
35
+
nativeBuildInputs = [ removeReferencesTo ];
36
36
+
37
37
+
# buildGoModule overrides normal buildPhase, can't use makeTargets
38
38
+
postBuild = ''
39
39
+
make build plugins
40
40
+
'';
41
41
+
42
42
+
# tries to pull tests from network, and fails silently anyway
43
43
+
doCheck = false;
44
44
+
45
45
+
postInstall = ''
46
46
+
mkdir -p $bin/bin
47
47
+
mv $out/bin/nomad-autoscaler $bin/bin/nomad-autoscaler
48
48
+
ln -s $bin/bin/nomad-autoscaler $out/bin/nomad-autoscaler
49
49
+
50
50
+
for d in $outputs; do
51
51
+
mkdir -p ''${!d}/share
52
52
+
done
53
53
+
rmdir $bin/share
54
54
+
55
55
+
# have out contain all of the plugins
56
56
+
for plugin in bin/plugins/*; do
57
57
+
remove-references-to -t ${go} "$plugin"
58
58
+
cp "$plugin" $out/share/
59
59
+
done
60
60
+
61
61
+
# populate the outputs as individual plugins
62
62
+
# can't think of a more generic way to handle this
63
63
+
# bash doesn't allow for dashes '-' to be in a variable name
64
64
+
# this means that the output names will need to differ slightly from the binary
65
65
+
mv bin/plugins/aws-asg $aws_asg/share/
66
66
+
mv bin/plugins/azure-vmss $azure_vmss/share/
67
67
+
mv bin/plugins/datadog $datadog/share/
68
68
+
mv bin/plugins/fixed-value $fixed_value/share/
69
69
+
mv bin/plugins/gce-mig $gce_mig/share/
70
70
+
mv bin/plugins/nomad-apm $nomad_apm/share/
71
71
+
mv bin/plugins/nomad-target $nomad_target/share/
72
72
+
mv bin/plugins/pass-through $pass_through/share/
73
73
+
mv bin/plugins/prometheus $prometheus/share/
74
74
+
mv bin/plugins/target-value $target_value/share/
75
75
+
mv bin/plugins/threshold $threshold/share/
76
76
+
'';
77
77
+
78
78
+
# make toggle-able, so that overrided versions can disable this check if
79
79
+
# they want newer versions of the plugins without having to modify
80
80
+
# the output logic
81
81
+
doInstallCheck = true;
82
82
+
installCheckPhase = ''
83
83
+
rmdir bin/plugins || {
84
84
+
echo "Not all plugins were extracted"
85
85
+
echo "Please move the following to their related output: $(ls bin/plugins)"
86
86
+
exit 1
87
87
+
}
88
88
+
'';
89
89
+
90
90
+
passthru = {
91
91
+
inherit plugins withPlugins;
92
92
+
};
93
93
+
94
94
+
meta = with lib; {
95
95
+
description = "Autoscaling daemon for Nomad";
96
96
+
homepage = "https://github.com/hashicorp/nomad-autoscaler";
97
97
+
license = licenses.mpl20;
98
98
+
maintainers = with maintainers; [ jonringer ];
99
99
+
};
100
100
+
};
101
101
+
102
102
+
plugins = let
103
103
+
plugins = builtins.filter (n: !(lib.elem n [ "out" "bin" ])) package.outputs;
104
104
+
in lib.genAttrs plugins (output: package.${output});
105
105
+
106
106
+
# Intended to be used as: (nomad-autoscaler.withPlugins (ps: [ ps.aws_asg ps.nomad_target ])
107
107
+
withPlugins = f: buildEnv {
108
108
+
name = "nomad-autoscaler-env";
109
109
+
paths = [ package.bin ] ++ f plugins;
110
110
+
};
111
111
+
in
112
112
+
package
+2
pkgs/top-level/all-packages.nix
···
7265
7265
nvidiaGpuSupport = config.cudaSupport or false;
7266
7266
};
7267
7267
7268
7268
+
nomad-autoscaler = callPackage ../applications/networking/cluster/nomad-autoscaler { };
7269
7269
+
7268
7270
nomad-driver-podman = callPackage ../applications/networking/cluster/nomad-driver-podman { };
7269
7271
7270
7272
notable = callPackage ../applications/misc/notable { };