Merge pull request #128117 from jonringer/nomad-autoscaler

nomad-autoscaler: init at 0.3.3

authored by Timothy DeHerrera and committed by GitHub c8ad4e02 3fee6644

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