diff mbox series

[bug#54560,47/47] gnu: Add go-github-com-prometheus-prometheus.

Message ID 20220325133211.5128-47-hello@lnikki.la
State New
Headers show
Series [bug#54560,01/47] gnu: Add go-google-golang-org-protobuf. | expand

Commit Message

Leo Nikkilä March 25, 2022, 1:32 p.m. UTC
* gnu/packages/patches/go-github-com-prometheus-prometheus-remove-deps.patch:
New patch, reduce go-github-com-prometheus-prometheus dependency tree.
* gnu/packages/monitoring.scm (go-github-com-prometheus-prometheus): New
variable.
---
 gnu/packages/monitoring.scm                   | 83 +++++++++++++++++++
 ...om-prometheus-prometheus-remove-deps.patch | 33 ++++++++
 2 files changed, 116 insertions(+)
 create mode 100644 gnu/packages/patches/go-github-com-prometheus-prometheus-remove-deps.patch

Comments

M March 25, 2022, 8:04 p.m. UTC | #1
Leo Nikkilä schreef op vr 25-03-2022 om 15:32 [+0200]:
> +(define-public go-github-com-prometheus-prometheus

IIUC, the result is some [...]/bin/prometheus binary that can be run or
something like that and not a library, so I think that the 'go-github-
com-prometheus) prefix can be dropped here.  I would go with
"prometheus" such that the user can just do "guix shell prometheus".

Greetings,
Maxime.
M March 25, 2022, 8:05 p.m. UTC | #2
Leo Nikkilä schreef op vr 25-03-2022 om 15:32 [+0200]:
> +    (native-inputs (list go-github-com-alecthomas-template
> +                         go-github-com-alecthomas-units
> +                         go-github-com-aws-aws-sdk-go
> +                         go-github-com-cespare-xxhash
> +                         go-github-com-dennwc-varint
> +                         go-github-com-edsrzf-mmap-go
> +                         go-github-com-fsnotify-fsnotify
> +                         go-github-com-go-kit-log
> +                         go-github-com-go-logfmt-logfmt
> +                         go-github-com-go-openapi-strfmt
> +                         go-github-com-gogo-protobuf
> +                         go-github-com-golang-snappy
> +                         go-github-com-json-iterator-go
> +                         go-github-com-mwitkow-go-conntrack
> +                         go-github-com-oklog-run
> +                         go-github-com-oklog-ulid
> +                         go-github-com-opentracing-contrib-go-stdlib
> +                         go-github-com-opentracing-opentracing-go
> +                         go-github-com-pkg-errors
> +                         go-github-com-prometheus-alertmanager-api
> +                         go-github-com-prometheus-client-golang
> +                         go-github-com-prometheus-client-model
> +                         go-github-com-prometheus-common
> +                         go-github-com-prometheus-exporter-toolkit
> +                         go-github-com-shurcool-httpfs
> +                         go-github-com-shurcool-vfsgen
> +                         go-github-com-simonpasquier-klog-gokit
> +                         go-github-com-simonpasquier-klog-gokit-v3
> +                         go-github-com-stretchr-testify
> +                         go-github-com-uber-jaeger-client-go
> +                         go-github-com-uber-jaeger-lib
> +                         go-go-uber-org-atomic
> +                         go-go-uber-org-goleak
> +                         go-golang-org-x-net
> +                         go-golang-org-x-sync
> +                         go-golang-org-x-sys
> +                         go-golang-org-x-time
> +                         go-golang-org-x-tools
> +                         go-gopkg-in-alecthomas-kingpin.v2
> +                         go-gopkg-in-yaml-v2
> +                         go-gopkg-in-yaml-v3))

I doubt that all of these are test dependencies, probably most of them
need to be in 'inputs'.
Leo Nikkilä March 25, 2022, 10:55 p.m. UTC | #3
> I would go with "prometheus" such that the user can just do "guix shell prometheus".

Great point, will update this.

> I doubt that all of these are test dependencies, probably most of them
> need to be in 'inputs'.

This as well.
diff mbox series

Patch

diff --git a/gnu/packages/monitoring.scm b/gnu/packages/monitoring.scm
index 7935c92815..968eb6b1ee 100644
--- a/gnu/packages/monitoring.scm
+++ b/gnu/packages/monitoring.scm
@@ -10,6 +10,7 @@ 
 ;;; Copyright © 2021, 2022 Marius Bakke <marius@gnu.org>
 ;;; Copyright © 2021 Stefan Reichör <stefan@xsteve.at>
 ;;; Copyright © 2021 Raphaël Mélotte <raphael.melotte@mind.be>
+;;; Copyright © 2022 Leo Nikkilä <hello@lnikki.la>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -48,6 +49,7 @@  (define-module (gnu packages monitoring)
   #:use-module (gnu packages django)
   #:use-module (gnu packages gd)
   #:use-module (gnu packages gettext)
+  #:use-module (gnu packages golang)
   #:use-module (gnu packages image)
   #:use-module (gnu packages mail)
   #:use-module (gnu packages ncurses)
@@ -61,6 +63,7 @@  (define-module (gnu packages monitoring)
   #:use-module (gnu packages python-web)
   #:use-module (gnu packages python-xyz)
   #:use-module (gnu packages rrdtool)
+  #:use-module (gnu packages syncthing)
   #:use-module (gnu packages time)
   #:use-module (gnu packages tls)
   #:use-module (gnu packages web))
@@ -499,6 +502,86 @@  (define-public go-github-com-prometheus-node-exporter
     (home-page "https://github.com/prometheus/node_exporter")
     (license license:asl2.0)))
 
+(define-public go-github-com-prometheus-prometheus
+  (package
+    (name "go-github-com-prometheus-prometheus")
+    (version "2.33.5")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/prometheus/prometheus")
+                    (commit (string-append "v" version))))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "0arz7ksrfavzg3vm5rlf6y3gbj8l59cg4x4zw6gmmd1dkflm2jx3"))
+              (patches (search-patches
+                        "go-github-com-prometheus-prometheus-remove-deps.patch"))))
+    (build-system go-build-system)
+    (arguments
+     '(#:import-path "github.com/prometheus/prometheus/cmd/prometheus"
+       #:unpack-path "github.com/prometheus/prometheus"
+       #:install-source? #f
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'patch-source
+           (lambda* (#:key import-path #:allow-other-keys)
+             ;; `k8s.io/klog' is replaced by `simonpasquier/klog-gokit'
+             (substitute* (find-files (string-append "src/" import-path)
+                                      "\\.go")
+               (("k8s.io/klog/v2") "github.com/simonpasquier/klog-gokit/v3")
+               (("k8s.io/klog") "github.com/simonpasquier/klog-gokit"))
+             #t)))))
+    (native-inputs (list go-github-com-alecthomas-template
+                         go-github-com-alecthomas-units
+                         go-github-com-aws-aws-sdk-go
+                         go-github-com-cespare-xxhash
+                         go-github-com-dennwc-varint
+                         go-github-com-edsrzf-mmap-go
+                         go-github-com-fsnotify-fsnotify
+                         go-github-com-go-kit-log
+                         go-github-com-go-logfmt-logfmt
+                         go-github-com-go-openapi-strfmt
+                         go-github-com-gogo-protobuf
+                         go-github-com-golang-snappy
+                         go-github-com-json-iterator-go
+                         go-github-com-mwitkow-go-conntrack
+                         go-github-com-oklog-run
+                         go-github-com-oklog-ulid
+                         go-github-com-opentracing-contrib-go-stdlib
+                         go-github-com-opentracing-opentracing-go
+                         go-github-com-pkg-errors
+                         go-github-com-prometheus-alertmanager-api
+                         go-github-com-prometheus-client-golang
+                         go-github-com-prometheus-client-model
+                         go-github-com-prometheus-common
+                         go-github-com-prometheus-exporter-toolkit
+                         go-github-com-shurcool-httpfs
+                         go-github-com-shurcool-vfsgen
+                         go-github-com-simonpasquier-klog-gokit
+                         go-github-com-simonpasquier-klog-gokit-v3
+                         go-github-com-stretchr-testify
+                         go-github-com-uber-jaeger-client-go
+                         go-github-com-uber-jaeger-lib
+                         go-go-uber-org-atomic
+                         go-go-uber-org-goleak
+                         go-golang-org-x-net
+                         go-golang-org-x-sync
+                         go-golang-org-x-sys
+                         go-golang-org-x-time
+                         go-golang-org-x-tools
+                         go-gopkg-in-alecthomas-kingpin.v2
+                         go-gopkg-in-yaml-v2
+                         go-gopkg-in-yaml-v3))
+    (synopsis "Monitoring system and time series database")
+    (description
+     "Prometheus is a systems and service monitoring system.  It
+collects metrics from configured targets at given intervals, evaluates
+rule expressions, displays the results, and can trigger alerts when
+specified conditions are observed.")
+    (home-page "https://github.com/prometheus/prometheus")
+    (license license:asl2.0)))
+
 (define-public temper-exporter
   (let ((commit "a87bbab19c05609d62d9e4c7941178700c1ef84d")
         (revision "0"))
diff --git a/gnu/packages/patches/go-github-com-prometheus-prometheus-remove-deps.patch b/gnu/packages/patches/go-github-com-prometheus-prometheus-remove-deps.patch
new file mode 100644
index 0000000000..4d4626d2d1
--- /dev/null
+++ b/gnu/packages/patches/go-github-com-prometheus-prometheus-remove-deps.patch
@@ -0,0 +1,33 @@ 
+This patch reduces the Prometheus dependency tree, most of which
+consists of unpackaged Go libraries, by removing certain discovery
+plugins.
+
+diff --git a/discovery/install/install.go b/discovery/install/install.go
+index e16b348f6..a3944cf9f 100644
+--- a/discovery/install/install.go
++++ b/discovery/install/install.go
+@@ -17,24 +17,9 @@ package install
+ 
+ import (
+-	_ "github.com/prometheus/prometheus/discovery/aws"          // register aws
+-	_ "github.com/prometheus/prometheus/discovery/azure"        // register azure
+-	_ "github.com/prometheus/prometheus/discovery/consul"       // register consul
+-	_ "github.com/prometheus/prometheus/discovery/digitalocean" // register digitalocean
+-	_ "github.com/prometheus/prometheus/discovery/dns"          // register dns
+ 	_ "github.com/prometheus/prometheus/discovery/eureka"       // register eureka
+ 	_ "github.com/prometheus/prometheus/discovery/file"         // register file
+-	_ "github.com/prometheus/prometheus/discovery/gce"          // register gce
+-	_ "github.com/prometheus/prometheus/discovery/hetzner"      // register hetzner
+ 	_ "github.com/prometheus/prometheus/discovery/http"         // register http
+-	_ "github.com/prometheus/prometheus/discovery/kubernetes"   // register kubernetes
+-	_ "github.com/prometheus/prometheus/discovery/linode"       // register linode
+ 	_ "github.com/prometheus/prometheus/discovery/marathon"     // register marathon
+-	_ "github.com/prometheus/prometheus/discovery/moby"         // register moby
+-	_ "github.com/prometheus/prometheus/discovery/openstack"    // register openstack
+ 	_ "github.com/prometheus/prometheus/discovery/puppetdb"     // register puppetdb
+-	_ "github.com/prometheus/prometheus/discovery/scaleway"     // register scaleway
+ 	_ "github.com/prometheus/prometheus/discovery/triton"       // register triton
+-	_ "github.com/prometheus/prometheus/discovery/uyuni"        // register uyuni
+-	_ "github.com/prometheus/prometheus/discovery/xds"          // register xds
+-	_ "github.com/prometheus/prometheus/discovery/zookeeper"    // register zookeeper
+ )