Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ stdenv 2, lib 3, go 4, buildGoModule 5, fetchFromGitHub 6, fetchurl 7, nixosTests 8, enableAWS ? true 9, enableAzure ? true 10, enableConsul ? true 11, enableDigitalOcean ? true 12, enableDNS ? true 13, enableEureka ? true 14, enableGCE ? true 15, enableHetzner ? true 16, enableIONOS ? true 17, enableKubernetes ? true 18, enableLinode ? true 19, enableMarathon ? true 20, enableMoby ? true 21, enableNomad ? true 22, enableOpenstack ? true 23, enableOVHCloud ? true 24, enablePuppetDB ? true 25, enableScaleway ? true 26, enableTriton ? true 27, enableUyuni ? true 28, enableVultr ? true 29, enableXDS ? true 30, enableZookeeper ? true 31}: 32 33let 34 version = "2.46.0"; 35 webUiStatic = fetchurl { 36 url = "https://github.com/prometheus/prometheus/releases/download/v${version}/prometheus-web-ui-${version}.tar.gz"; 37 hash = "sha256-H6RRyemawt9NRLTVG0iH4vNFNiuvdPZz7u43Zop0vVI="; 38 }; 39in 40buildGoModule rec { 41 pname = "prometheus"; 42 inherit version; 43 44 outputs = [ "out" "doc" "cli" ]; 45 46 src = fetchFromGitHub { 47 owner = "prometheus"; 48 repo = "prometheus"; 49 rev = "v${version}"; 50 hash = "sha256-TB4N5aAfNw34HJ1HSt6rHTETTyAgpGA8B5VOFHisZFU="; 51 }; 52 53 vendorHash = "sha256-jeGtna7IeKAOiu4FFA2xRv+fwpzCpnqwI5nj641dlM4="; 54 55 excludedPackages = [ "documentation/prometheus-mixin" ]; 56 57 postPatch = '' 58 tar -C web/ui -xzf ${webUiStatic} 59 60 patchShebangs scripts 61 62 # Enable only select service discovery to shrink binaries. 63 ( 64 true # prevent bash syntax error when all plugins are disabled 65 ${lib.optionalString enableAWS "echo - github.com/prometheus/prometheus/discovery/aws"} 66 ${lib.optionalString enableAzure "echo - github.com/prometheus/prometheus/discovery/azure"} 67 ${lib.optionalString enableConsul "echo - github.com/prometheus/prometheus/discovery/consul"} 68 ${lib.optionalString enableDigitalOcean "echo - github.com/prometheus/prometheus/discovery/digitalocean"} 69 ${lib.optionalString enableDNS "echo - github.com/prometheus/prometheus/discovery/dns"} 70 ${lib.optionalString enableEureka "echo - github.com/prometheus/prometheus/discovery/eureka"} 71 ${lib.optionalString enableGCE "echo - github.com/prometheus/prometheus/discovery/gce"} 72 ${lib.optionalString enableHetzner "echo - github.com/prometheus/prometheus/discovery/hetzner"} 73 ${lib.optionalString enableIONOS "echo - github.com/prometheus/prometheus/discovery/ionos"} 74 ${lib.optionalString enableKubernetes "echo - github.com/prometheus/prometheus/discovery/kubernetes"} 75 ${lib.optionalString enableLinode "echo - github.com/prometheus/prometheus/discovery/linode"} 76 ${lib.optionalString enableMarathon "echo - github.com/prometheus/prometheus/discovery/marathon"} 77 ${lib.optionalString enableMoby "echo - github.com/prometheus/prometheus/discovery/moby"} 78 ${lib.optionalString enableNomad "echo - github.com/prometheus/prometheus/discovery/nomad"} 79 ${lib.optionalString enableOpenstack "echo - github.com/prometheus/prometheus/discovery/openstack"} 80 ${lib.optionalString enableOVHCloud "echo - github.com/prometheus/prometheus/discovery/ovhcloud"} 81 ${lib.optionalString enablePuppetDB "echo - github.com/prometheus/prometheus/discovery/puppetdb"} 82 ${lib.optionalString enableScaleway "echo - github.com/prometheus/prometheus/discovery/scaleway"} 83 ${lib.optionalString enableTriton "echo - github.com/prometheus/prometheus/discovery/triton"} 84 ${lib.optionalString enableUyuni "echo - github.com/prometheus/prometheus/discovery/uyuni"} 85 ${lib.optionalString enableVultr "echo - github.com/prometheus/prometheus/discovery/vultr"} 86 ${lib.optionalString enableXDS "echo - github.com/prometheus/prometheus/discovery/xds"} 87 ${lib.optionalString enableZookeeper "echo - github.com/prometheus/prometheus/discovery/zookeeper"} 88 ) > plugins.yml 89 ''; 90 91 preBuild = '' 92 if [[ -d vendor ]]; then GOARCH= make -o assets assets-compress plugins; fi 93 ''; 94 95 tags = [ "builtinassets" ]; 96 97 ldflags = 98 let 99 t = "github.com/prometheus/common/version"; 100 in 101 [ 102 "-s" 103 "-w" 104 "-X ${t}.Version=${version}" 105 "-X ${t}.Revision=unknown" 106 "-X ${t}.Branch=unknown" 107 "-X ${t}.BuildUser=nix@nixpkgs" 108 "-X ${t}.BuildDate=unknown" 109 "-X ${t}.GoVersion=${lib.getVersion go}" 110 ]; 111 112 preInstall = '' 113 mkdir -p "$out/share/doc/prometheus" "$out/etc/prometheus" 114 cp -a $src/documentation/* $out/share/doc/prometheus 115 cp -a $src/console_libraries $src/consoles $out/etc/prometheus 116 ''; 117 118 postInstall = '' 119 moveToOutput bin/promtool $cli 120 ''; 121 122 # https://hydra.nixos.org/build/130673870/nixlog/1 123 # Test mock data uses 64 bit data without an explicit (u)int64 124 doCheck = !(stdenv.isDarwin || stdenv.hostPlatform.parsed.cpu.bits < 64); 125 126 passthru.tests = { inherit (nixosTests) prometheus; }; 127 128 meta = with lib; { 129 description = "Service monitoring system and time series database"; 130 homepage = "https://prometheus.io"; 131 license = licenses.asl20; 132 maintainers = with maintainers; [ fpletz willibutz Frostman ]; 133 }; 134}