kamilchm / go2nix

Reproducible builds and development environment for Go
MIT License
94 stars 17 forks source link

Cannot work out how to package rabbitmq-explorer #64

Open ocharles opened 6 years ago

ocharles commented 6 years ago
➜  work mkdir rabbitmq_explorer                                                                                                                                        ~/work
➜  work cd rabbitmq_explorer                                                                                                                                           ~/work
➜  rabbitmq_explorer nix-shell -p go dep                                                                                                             ~/work/rabbitmq_explorer

[nix-shell:~/work/rabbitmq_explorer]$ go get -v github.com/kbudde/rabbitmq_exporter
github.com/kbudde/rabbitmq_exporter (download)
github.com/Sirupsen/logrus (download)
Fetching https://golang.org/x/crypto/ssh/terminal?go-get=1
Parsing meta tags from https://golang.org/x/crypto/ssh/terminal?go-get=1 (status code 200)
get "golang.org/x/crypto/ssh/terminal": found meta tag get.metaImport{Prefix:"golang.org/x/crypto", VCS:"git", RepoRoot:"https://go.googlesource.com/crypto"} at https://golang.org/x/crypto/ssh/terminal?go-get=1
get "golang.org/x/crypto/ssh/terminal": verifying non-authoritative meta tag
Fetching https://golang.org/x/crypto?go-get=1
Parsing meta tags from https://golang.org/x/crypto?go-get=1 (status code 200)
golang.org/x/crypto (download)
Fetching https://golang.org/x/sys/unix?go-get=1
Parsing meta tags from https://golang.org/x/sys/unix?go-get=1 (status code 200)
get "golang.org/x/sys/unix": found meta tag get.metaImport{Prefix:"golang.org/x/sys", VCS:"git", RepoRoot:"https://go.googlesource.com/sys"} at https://golang.org/x/sys/unix?go-get=1
get "golang.org/x/sys/unix": verifying non-authoritative meta tag
Fetching https://golang.org/x/sys?go-get=1
Parsing meta tags from https://golang.org/x/sys?go-get=1 (status code 200)
golang.org/x/sys (download)
github.com/kbudde/gobert (download)
github.com/prometheus/client_golang (download)
github.com/beorn7/perks (download)
github.com/golang/protobuf (download)
github.com/prometheus/client_model (download)
github.com/prometheus/common (download)
github.com/matttproud/golang_protobuf_extensions (download)
github.com/prometheus/procfs (download)
golang.org/x/sys/unix
github.com/kbudde/gobert
github.com/beorn7/perks/quantile
github.com/golang/protobuf/proto
github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg
github.com/prometheus/procfs/xfs
github.com/prometheus/common/model
github.com/prometheus/procfs
golang.org/x/crypto/ssh/terminal
github.com/Sirupsen/logrus
github.com/prometheus/client_model/go
github.com/matttproud/golang_protobuf_extensions/pbutil
github.com/prometheus/common/expfmt
github.com/prometheus/client_golang/prometheus
github.com/kbudde/rabbitmq_exporter

[nix-shell:~/work/rabbitmq_explorer]$ cd src/g
github.com/ golang.org/ 

[nix-shell:~/work/rabbitmq_explorer]$ cd src/github.com/kbudde/
gobert/            rabbitmq_exporter/ 

[nix-shell:~/work/rabbitmq_explorer]$ cd src/github.com/kbudde/rabbitmq_exporter/

[nix-shell:~/work/rabbitmq_explorer/src/github.com/kbudde/rabbitmq_exporter]$ go get

[nix-shell:~/work/rabbitmq_explorer/src/github.com/kbudde/rabbitmq_exporter]$ dep ensure -v
Gopkg.lock was already in sync with imports and Gopkg.toml
(1/18) Wrote github.com/beorn7/perks@master
(2/18) Wrote github.com/matttproud/golang_protobuf_extensions@v1.0.0
(3/18) Wrote github.com/pkg/errors@v0.8.0
(4/18) Wrote github.com/cenk/backoff@v1.1.0
(5/18) Wrote github.com/kylelemons/godebug@master
(6/18) Wrote github.com/kbudde/gobert@master
(7/18) Wrote golang.org/x/crypto@master
(8/18) Wrote github.com/prometheus/client_model@master
(9/18) Wrote golang.org/x/sys@master
(10/18) Wrote github.com/prometheus/procfs@master
(11/18) Wrote github.com/prometheus/common@master
(12/18) Wrote github.com/Sirupsen/logrus@master
(13/18) Wrote gopkg.in/ory-am/dockertest.v3@v3.0.9
(14/18) Wrote golang.org/x/net@master
(15/18) Wrote github.com/prometheus/client_golang@v0.8.0
(16/18) Wrote github.com/streadway/amqp@master
(17/18) Wrote github.com/fsouza/go-dockerclient@docker-1.9/go-1.4
(18/18) Wrote github.com/golang/protobuf@master

[nix-shell:~/work/rabbitmq_explorer/src/github.com/kbudde/rabbitmq_exporter]$ go2nix save

[nix-shell:~/work/rabbitmq_explorer/src/github.com/kbudde/rabbitmq_exporter]$ nix-build -E 'with import <nixpkgs> {}; callPackage ./. {}'
these derivations will be built:
  /nix/store/b4ri3na2mf0qhp41q0s2l77jfba2dqww-rabbitmq_exporter-unstable-2017-12-02.drv
these paths will be fetched (1.96 MiB download, 5.23 MiB unpacked):
  /nix/store/dk0hjq9hxxlwi301i5sql42fscmw2bs6-parallel-20170722
  /nix/store/qnw30iqd5zs2wld9nz0c46nrrpalfn1n-govers-20150109-3b5f175
  /nix/store/wp3k5x5iw9s18pabi5s4kkiy0c3pkvbf-govers-20150109-3b5f175-bin
fetching path ‘/nix/store/wp3k5x5iw9s18pabi5s4kkiy0c3pkvbf-govers-20150109-3b5f175-bin’...
fetching path ‘/nix/store/dk0hjq9hxxlwi301i5sql42fscmw2bs6-parallel-20170722’...

*** Downloading ‘http://cache.nixos.org/nar/0wmgswq2bqc7bp790h5vwc6qkhhwzmrggq78s3j3bnwk6nb6k418.nar.xz’ to ‘/nix/store/dk0hjq9hxxlwi301i5sql42fscmw2bs6-parallel-20170722’...

*** Downloading ‘http://cache.nixos.org/nar/1xsdl4hkj36rhspycsxb2y39hnicnwnlm56r3805yvqbqi2q3jbi.nar.xz’ to ‘/nix/store/wp3k5x5iw9s18pabi5s4kkiy0c3pkvbf-govers-20150109-3b5f175-bin’...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  780k  100  780k    0     0   780k      0  0:00:01  0:00:01 --:--:--  600k

fetching path ‘/nix/store/qnw30iqd5zs2wld9nz0c46nrrpalfn1n-govers-20150109-3b5f175’...
 87 1225k   87 1068k    0     0  1068k      0  0:00:01  0:00:01 --:--:--  762k
*** Downloading ‘http://cache.nixos.org/nar/1h42w323z56d6wwgxx2vriw7jnycnkndh7prg0101569bmb885zb.nar.xz’ to ‘/nix/store/qnw30iqd5zs2wld9nz0c46nrrpalfn1n-govers-20150109-3b5f175’...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 1225k  100 1225k    0     0  1225k      0  0:00:01  0:00:01 --:--:--  808k

100  4080  100  4080    0     0   4080      0  0:00:01 --:--:--  0:00:01 28531

building path(s) ‘/nix/store/3wd6asnixh00lgm7iw6im8pkynlc9619-rabbitmq_exporter-unstable-2017-12-02-bin’, ‘/nix/store/8f1x0aknqkj8g0apzz0jgxvjjxbx08fh-rabbitmq_exporter-unstable-2017-12-02’
unpacking sources
unpacking source archive /nix/store/m05bz2bqfja0g5mdcnr9y9rbr0y22s5z-rabbitmq_exporter-8238c5d
source root is rabbitmq_exporter-8238c5d
patching sources
configuring
unpacking source archive /nix/store/0bx688c40a4jh06ng79g6si6c4hgx9gd-logrus-d682213
unpacking source archive /nix/store/vig8636xz89jj36725rdgi5jjw7n8n31-perks-4c0e845
unpacking source archive /nix/store/n3ma80dcyqqzli3b22lq8d6iq3w8zxd8-protobuf-1e59b77
unpacking source archive /nix/store/hw16868wxgj2ygnv1sff4r91l9ai4bv5-gobert-a6daecb
unpacking source archive /nix/store/3z30spv34fzy2dckaw65rzshhbdgn6cm-golang_protobuf_extensions-c12348c
unpacking source archive /nix/store/0rby1zkhs2bwxh1axvz851cy9jxaxlfh-client_golang-661e31b
unpacking source archive /nix/store/7lfwbx42rmjrl9n6m94xnf13mn62rx61-client_model-99fa1f4
unpacking source archive /nix/store/ifvvihp3s1pv1ik38q74lbk5vv4pj9py-common-2e54d0b
unpacking source archive /nix/store/6325fw09bz5j0a1ss8ydbaa13bq3243x-procfs-f98634e
unpacking source archive /nix/store/f03mmim3hqfbyxxm456wkfw42m7lrs3d-crypto-d585fd2
unpacking source archive /nix/store/wx7zzfdkiib6m4x2aj40944aaynyac0f-sys-571f7bb
building
go/src/github.com/kbudde/rabbitmq_exporter/testenv/rabbit.go:8:2: cannot find package "github.com/streadway/amqp" in any of:
    /nix/store/120g15mjvimcvlvz0525rz9cqbpkyjhz-go-1.9.2/share/go/src/github.com/streadway/amqp (from $GOROOT)
    /tmp/nix-build-rabbitmq_exporter-unstable-2017-12-02.drv-0/go/src/github.com/streadway/amqp (from $GOPATH)
    /nix/store/qnw30iqd5zs2wld9nz0c46nrrpalfn1n-govers-20150109-3b5f175/share/go/src/github.com/streadway/amqp
go/src/github.com/kbudde/rabbitmq_exporter/testenv/testenv.go:18:2: cannot find package "gopkg.in/ory-am/dockertest.v3" in any of:
    /nix/store/120g15mjvimcvlvz0525rz9cqbpkyjhz-go-1.9.2/share/go/src/gopkg.in/ory-am/dockertest.v3 (from $GOROOT)
    /tmp/nix-build-rabbitmq_exporter-unstable-2017-12-02.drv-0/go/src/gopkg.in/ory-am/dockertest.v3 (from $GOPATH)
    /nix/store/qnw30iqd5zs2wld9nz0c46nrrpalfn1n-govers-20150109-3b5f175/share/go/src/gopkg.in/ory-am/dockertest.v3
golang.org/x/sys/unix
github.com/kbudde/gobert
github.com/beorn7/perks/quantile
github.com/golang/protobuf/proto
github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg
github.com/prometheus/common/model
github.com/prometheus/procfs/xfs
github.com/prometheus/procfs
golang.org/x/crypto/ssh/terminal
github.com/Sirupsen/logrus
github.com/prometheus/client_model/go
github.com/matttproud/golang_protobuf_extensions/pbutil
github.com/prometheus/common/expfmt
github.com/prometheus/client_golang/prometheus
github.com/kbudde/rabbitmq_exporter
builder for ‘/nix/store/b4ri3na2mf0qhp41q0s2l77jfba2dqww-rabbitmq_exporter-unstable-2017-12-02.drv’ failed with exit code 1
error: build of ‘/nix/store/b4ri3na2mf0qhp41q0s2l77jfba2dqww-rabbitmq_exporter-unstable-2017-12-02.drv’ failed
ocharles commented 6 years ago

This is go2nix 1.2.1.

ixmatus commented 6 years ago

@ocharles I was able to build that package manually after adding a few deps; I'm not sure why go2nix didn't pick them up.

[
  {
    goPackagePath = "golang.org/x/net";
    fetch = {
      type = "git";
      url = "https://go.googlesource.com/net";
      rev = "a8b9294777976932365dabb6640cf1468d95c70f";
      sha256 = "112v83jfwd1brwaanjijvb7da4dx1iqk8b4bf9ahx0hvir56c2g8";
    };
  }

  {
    goPackagePath = "github.com/pkg/errors";
    fetch = {
      type = "git";
      url = "https://github.com/pkg/errors";
      rev = "645ef00459ed84a119197bfb8d8205042c6df63d";
      sha256 = "001i6n71ghp2l6kdl3qq1v2vmghcz3kicv9a5wgcihrzigm75pp5";
    };
  }

  {
    goPackagePath = "github.com/fsouza/go-dockerclient";
    fetch = {
      type = "git";
      url = "https://github.com/fsouza/go-dockerclient";
      rev = "1d4f4ae73768d3ca16a6fb964694f58dc5eba601";
      sha256 = "1s3m8jq8z1cm5rkn7dmjacf38n6ihkkzbdfang2aa2cgs5wl28y0";
    };
  }

  {
    goPackagePath = "github.com/cenk/backoff";
    fetch = {
      type = "git";
      url = "https://github.com/cenk/backoff";
      rev = "61153c768f31ee5f130071d08fc82b85208528de";
      sha256 = "08x77mgb9zsj047n74rx6c16jjx985lmy4s6fl58mdgxgxjv54y5";
    };
  }

  {
    goPackagePath = "gopkg.in/ory-am/dockertest.v3";
    fetch = {
      type = "git";
      url = "https://gopkg.in/ory-am/dockertest.v3";
      rev = "a7951f7a8442f0e70d36e499ed4d744f00af2963";
      sha256 = "13qv0vl79m2wirhbjs0k2a3cjl6ib7sw6rg98v95xxpn8r39ijzw";
    };
  }

  {
    goPackagePath = "github.com/streadway/amqp";
    fetch = {
      type = "git";
      url = "https://github.com/streadway/amqp";
      rev = "ff791c2d22d3f1588b4e2cc71a9fba5e1da90654";
      sha256 = "1drridn4k1n7qy82msvw9r18w4pmrah1nip36wixz098nzalz55x";
    };
  }

  {
    goPackagePath = "github.com/Sirupsen/logrus";
    fetch = {
      type = "git";
      url = "https://github.com/Sirupsen/logrus";
      rev = "d682213848ed68c0a260ca37d6dd5ace8423f5ba";
      sha256 = "0nzyqwzx3k7nqfq8q7yv32gaf3ymq3bpwhkmw1hj2zakq5a93d8x";
    };
  }
  {
    goPackagePath = "github.com/beorn7/perks";
    fetch = {
      type = "git";
      url = "https://github.com/beorn7/perks";
      rev = "4c0e84591b9aa9e6dcfdf3e020114cd81f89d5f9";
      sha256 = "1hrybsql68xw57brzj805xx2mghydpdiysv3gbhr7f5wlxj2514y";
    };
  }
  {
    goPackagePath = "github.com/golang/protobuf";
    fetch = {
      type = "git";
      url = "https://github.com/golang/protobuf";
      rev = "1e59b77b52bf8e4b449a57e6f79f21226d571845";
      sha256 = "19bkh81wnp6njg3931wky6hsnnl2d1ig20vfjxpv450sd3k6yys8";
    };
  }
  {
    goPackagePath = "github.com/kbudde/gobert";
    fetch = {
      type = "git";
      url = "https://github.com/kbudde/gobert";
      rev = "a6daecb9ddeb548b7cfb3f5ac9deef9ded522730";
      sha256 = "06g036w4dny8wdjwvprjjcdh0vx851qphgrvilrn5lghv3jdr29z";
    };
  }
  {
    goPackagePath = "github.com/matttproud/golang_protobuf_extensions";
    fetch = {
      type = "git";
      url = "https://github.com/matttproud/golang_protobuf_extensions";
      rev = "c12348ce28de40eed0136aa2b644d0ee0650e56c";
      sha256 = "1d0c1isd2lk9pnfq2nk0aih356j30k3h1gi2w0ixsivi5csl7jya";
    };
  }
  {
    goPackagePath = "github.com/prometheus/client_golang";
    fetch = {
      type = "git";
      url = "https://github.com/prometheus/client_golang";
      rev = "661e31bf844dfca9aeba15f27ea8aa0d485ad212";
      sha256 = "0r9sr3m57ks7rc5bbghl0gy9wxlznzmz331xdp42zlgk6g774xcn";
    };
  }
  {
    goPackagePath = "github.com/prometheus/client_model";
    fetch = {
      type = "git";
      url = "https://github.com/prometheus/client_model";
      rev = "99fa1f4be8e564e8a6b613da7fa6f46c9edafc6c";
      sha256 = "19y4ywsivhpxj7ikf2j0gm9k3cmyw37qcbfi78n526jxcc7kw998";
    };
  }
  {
    goPackagePath = "github.com/prometheus/common";
    fetch = {
      type = "git";
      url = "https://github.com/prometheus/common";
      rev = "2e54d0b93cba2fd133edc32211dcc32c06ef72ca";
      sha256 = "14kn5w7imcxxlfdqxl21fsnlf1ms7200g3ldy29hwamldv8qlm7j";
    };
  }
  {
    goPackagePath = "github.com/prometheus/procfs";
    fetch = {
      type = "git";
      url = "https://github.com/prometheus/procfs";
      rev = "f98634e408857669d61064b283c4cde240622865";
      sha256 = "098r6x3b1vawp69scz0z9drrx9pdz1a8f7nimqgw26wm39cms15w";
    };
  }
  {
    goPackagePath = "golang.org/x/crypto";
    fetch = {
      type = "git";
      url = "https://go.googlesource.com/crypto";
      rev = "d585fd2cc9195196078f516b69daff6744ef5e84";
      sha256 = "0d4p1zb9kbg1y4z3034f15xygdnaap7mxbsy66xxxpc1fkjjpn29";
    };
  }
  {
    goPackagePath = "golang.org/x/sys";
    fetch = {
      type = "git";
      url = "https://go.googlesource.com/sys";
      rev = "571f7bbbe08da2a8955aed9d4db316e78630e9a3";
      sha256 = "048ahxnvk0246qssrplsr19zis4nr242g70jgcxmgy5awips4bmb";
    };
  }
]
ixmatus commented 6 years ago

These are the ones that I added:


diff --git a/deps.nix b/deps.nix
index 3da504c..a9c0473 100644
--- a/deps.nix
+++ b/deps.nix
@@ -1,5 +1,65 @@
 # This file was generated by https://github.com/kamilchm/go2nix v1.2.1
 [
+  {
+    goPackagePath = "golang.org/x/net";
+    fetch = {
+      type = "git";
+      url = "https://go.googlesource.com/net";
+      rev = "a8b9294777976932365dabb6640cf1468d95c70f";
+      sha256 = "112v83jfwd1brwaanjijvb7da4dx1iqk8b4bf9ahx0hvir56c2g8";
+    };
+  }
+
+  {
+    goPackagePath = "github.com/pkg/errors";
+    fetch = {
+      type = "git";
+      url = "https://github.com/pkg/errors";
+      rev = "645ef00459ed84a119197bfb8d8205042c6df63d";
+      sha256 = "001i6n71ghp2l6kdl3qq1v2vmghcz3kicv9a5wgcihrzigm75pp5";
+    };
+  }
+
+  {
+    goPackagePath = "github.com/fsouza/go-dockerclient";
+    fetch = {
+      type = "git";
+      url = "https://github.com/fsouza/go-dockerclient";
+      rev = "1d4f4ae73768d3ca16a6fb964694f58dc5eba601";
+      sha256 = "1s3m8jq8z1cm5rkn7dmjacf38n6ihkkzbdfang2aa2cgs5wl28y0";
+    };
+  }
+
+  {
+    goPackagePath = "github.com/cenk/backoff";
+    fetch = {
+      type = "git";
+      url = "https://github.com/cenk/backoff";
+      rev = "61153c768f31ee5f130071d08fc82b85208528de";
+      sha256 = "08x77mgb9zsj047n74rx6c16jjx985lmy4s6fl58mdgxgxjv54y5";
+    };
+  }
+
+  {
+    goPackagePath = "gopkg.in/ory-am/dockertest.v3";
+    fetch = {
+      type = "git";
+      url = "https://gopkg.in/ory-am/dockertest.v3";
+      rev = "a7951f7a8442f0e70d36e499ed4d744f00af2963";
+      sha256 = "13qv0vl79m2wirhbjs0k2a3cjl6ib7sw6rg98v95xxpn8r39ijzw";
+    };
+  }
+
+  {
+    goPackagePath = "github.com/streadway/amqp";
+    fetch = {
+      type = "git";
+      url = "https://github.com/streadway/amqp";
+      rev = "ff791c2d22d3f1588b4e2cc71a9fba5e1da90654";
+      sha256 = "1drridn4k1n7qy82msvw9r18w4pmrah1nip36wixz098nzalz55x";
+    };
+  }
+
   {
     goPackagePath = "github.com/Sirupsen/logrus";
     fetch = {
kamilchm commented 6 years ago

You can use this one https://gist.github.com/kamilchm/c81e0b90a2494f2a1beb07d80205ba71 It was generated using v2 branch I'm working on, where I use golang dep tool files to resolve dependencies.

ocharles commented 6 years ago

Thanks @kamilchm - those expressions work great. Do you want to keep this issue open?