kamilchm / go2nix

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

Unclear what `go2nix save` is looking for #51

Closed copumpkin closed 7 years ago

copumpkin commented 7 years ago

I'm trying to package the AWS SSM agent with go2nix and am running into some trouble. I'm following the instructions in the go2nix readme and have wrangled the project into building for me, but when I type go2nix save, I get

$ go2nix save
2017/02/06 16:18:25 no buildable Go source files in /Users/copumpkin/Sandbox/amazon-ssm-agent/vendor/src/github.com/aws/amazon-ssm-agent

Which is presumably because the Go sources are in a subdirectory. I cd into agent, which contains all the go sources, and in there go2nix save works just fine but produces an empty deps.nix. How do I convince go2nix to find my source files and my dependencies?

kamilchm commented 7 years ago

Generally, go2nix should be run in the same dir where you normally do go build. In your case it should be agent as you did. amazon-ssm-agent provides it's dependencies in vendor dir and doesn't need any external one, so the empty deps.nix file. One thing I found strange is the location of vendor/src/github.com instead of vendor/github.com. It works good for me when I move it manually. Wrapping up, there's a nix derivation for amazon-ssm-agent that works for me https://gist.github.com/kamilchm/4c07366c0fcec8c9974ae93e07ef3552

copumpkin commented 7 years ago

Awesome, thanks! I'll try it out later and push it to nixpkgs crediting you :)

On Feb 9, 2017, at 10:13, Kamil Chmielewski notifications@github.com wrote:

Generally, go2nix should be run in the same dir where you normally do go build. In your case it should be agent as you did. amazon-ssm-agent provides it's dependencies in vendor dir and doesn't need any external one, so the empty deps.nix file. One thing I found strange is the location of vendor/src/github.com instead of vendor/github.com. It works good for me when I move it manually. Wrapping up, there's a nix derivation for amazon-ssm-agent that works for me https://gist.github.com/kamilchm/4c07366c0fcec8c9974ae93e07ef3552

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

kamilchm commented 7 years ago

I might say too much in "that works for me" - I meant it compiles and I can run the output binary :) Looking closer, there could be few places to patch or configure before merging into nixpkgs:

$ /nix/store/wjilplwya3y7yl5q1kf0mgsj99xqdc6l-amazon-ssm-agent-2.0.633.0-bin/bin/agent --help
2017/02/09 17:40:30 Failed to load instance info from vault. Failed to create vault folder. failed to create directory /var/lib/amazon/ssm/Vault/Store. mkdir /var/lib/amazon: permission denied
Error occured fetching the seelog config file path:  open /etc/amazon/ssm/seelog.xml: no such file or directory
copumpkin commented 7 years ago

Oh yeah, definitely plan on doing that. Although with a NixOS module we'd probably just make sure it gets the right locations from NixOS config.

copumpkin commented 7 years ago

Thanks again! I have the SSM agent working on NixOS and wrote a simple module for it too. I forgot to credit you for the original expression in my initial commit though, sorry 😦 I can't rewrite history now but if you'd like credit I can add a comment or something.

kamilchm commented 7 years ago

It's OK. Good to know that it works.