1 { lib, fetchFromGitHub, buildGoModule, buildEnv }:
4 package = buildGoModule rec {
5 pname = "nomad-autoscaler";
24 src = fetchFromGitHub {
26 repo = "nomad-autoscaler";
28 sha256 = "sha256-fK5GsszNhz/WP0zVk2lOfU/gwYijdQa5qhNYO33RhXc=";
31 vendorHash = "sha256-Duzjpl011mj/SNoX/jQGMXwqUHPDz7iIMygRmK1vC3Q=";
39 # tries to pull tests from network, and fails silently anyway
44 mkdir -p $bin/bin $out/bin
45 mv bin/nomad-autoscaler $bin/bin
46 ln -s $bin/bin/nomad-autoscaler $out/bin/nomad-autoscaler
48 for d in $(getAllOutputNames); do
49 mkdir -p ''${!d}/share
53 # have out contain all of the plugins
54 for plugin in bin/plugins/*; do
55 cp "$plugin" $out/share/
58 # populate the outputs as individual plugins
59 # can't think of a more generic way to handle this
60 # bash doesn't allow for dashes '-' to be in a variable name
61 # this means that the output names will need to differ slightly from the binary
62 mv bin/plugins/aws-asg $aws_asg/share/
63 mv bin/plugins/azure-vmss $azure_vmss/share/
64 mv bin/plugins/datadog $datadog/share/
65 mv bin/plugins/fixed-value $fixed_value/share/
66 mv bin/plugins/gce-mig $gce_mig/share/
67 mv bin/plugins/nomad-apm $nomad_apm/share/
68 mv bin/plugins/nomad-target $nomad_target/share/
69 mv bin/plugins/pass-through $pass_through/share/
70 mv bin/plugins/prometheus $prometheus/share/
71 mv bin/plugins/target-value $target_value/share/
72 mv bin/plugins/threshold $threshold/share/
76 # make toggle-able, so that overrided versions can disable this check if
77 # they want newer versions of the plugins without having to modify
79 doInstallCheck = true;
80 installCheckPhase = ''
81 rmdir bin/plugins || {
82 echo "Not all plugins were extracted"
83 echo "Please move the following to their related output: $(ls bin/plugins)"
89 inherit plugins withPlugins;
93 description = "Autoscaling daemon for Nomad";
94 mainProgram = "nomad-autoscaler";
95 homepage = "https://github.com/hashicorp/nomad-autoscaler";
96 license = licenses.mpl20;
102 plugins = builtins.filter (n: !(lib.elem n [ "out" "bin" ])) package.outputs;
103 in lib.genAttrs plugins (output: package.${output});
105 # Intended to be used as: (nomad-autoscaler.withPlugins (ps: [ ps.aws_asg ps.nomad_target ])
106 withPlugins = f: buildEnv {
107 name = "nomad-autoscaler-env";
108 paths = [ package.bin ] ++ f plugins;