Skip to content

Rework goPackages#16017

Merged
rushmorem merged 78 commits intoNixOS:masterfrom
kamilchm:rework-go
Jun 9, 2016
Merged

Rework goPackages#16017
rushmorem merged 78 commits intoNixOS:masterfrom
kamilchm:rework-go

Conversation

@kamilchm
Copy link
Member

@kamilchm kamilchm commented Jun 6, 2016

Motivation for this change

This is my try on better goPackages as I mentioned in #13819 (comment)

I started with an assumption that there's no need to have goPackages that aren't used in a compiled program. So I've created new derivations in proper program categories for all all-packages.nix that comes from go-packages.nix using prototype tool go2nix.
All program dependencies are extracted to json file than can include other json dependency files for better package reuse and making overrides possible.
libs.json and deps.json files can be easily updated with tools like proposed in #13819 or generated from go native dependency managers.

There are few more things to do, but I'm looking for feedback to proritize tasks. Let's make go packaging better.

CC: @edolstra @cstrahan @copumpkin @viric @hrdinka @wkennington @zimbatm

Things done
  • Tested using sandboxing
    (nix.useSandbox on NixOS,
    or option build-use-sandbox in nix.conf
    on non-NixOS)
  • Built on platform(s)
    • NixOS
    • OS X
    • Linux
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

@zimbatm
Copy link
Member

zimbatm commented Jun 6, 2016

+100. Let's merge this soon before it gets stale.

@offlinehacker
Copy link
Contributor

nice :)

@kamilchm
Copy link
Member Author

kamilchm commented Jun 6, 2016

I'm working on replacing all fetchgit with fetchFromGitHub. I don't know why but fetchgit doesn't work with version tags on travis :/
Give me an hour ;)

@zimbatm
Copy link
Member

zimbatm commented Jun 6, 2016

Should go2nix be patched to automatically generate the right thing ?

@kamilchm
Copy link
Member Author

kamilchm commented Jun 6, 2016

I left changes in go2nix until we settle on dependencies file format and buildGoPackage.goDeps attribute.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it ok like this or maybe we want to produce every otutput? I couldn't figure it out and make 2 styles of it to make it consistent later.

@kamilchm
Copy link
Member Author

kamilchm commented Jun 6, 2016

strange thing happens on travis:

unpacking source archive /nix/store/mjyfcvkr9dw9in717ya5r4va30nyz9h4-consul-v0.6.4-src
source root is consul-v0.6.4-src
patching sources
patching script interpreter paths in ./ui/scripts/dist.sh
./ui/scripts/dist.sh: interpreter directive changed from "/usr/bin/env bash" to "/nix/store/p7cn4rd7rkc4x0g3354aj5ynh90pfcv2-bash-4.3-p42/bin/bash "
configuring
no configure script, doing nothing
building
/run/user/1001/nix-build-consul-ui-0.6.4.drv-0/consul-v0.6.4-src/ui /run/user/1001/nix-build-consul-ui-0.6.4.drv-0/consul-v0.6.4-src
sh: /run/user/1001/nix-build-consul-ui-0.6.4.drv-0/consul-v0.6.4-src/ui/scripts/dist.sh: Permission denied

I can't reproduce it on my machine :/
What could be wrong?

@groxxda
Copy link
Contributor

groxxda commented Jun 6, 2016

Most certainly a travis issue you don't have to care about See

@kamilchm kamilchm force-pushed the rework-go branch 2 times, most recently from 5c1ca7f to 73f47c5 Compare June 6, 2016 12:24
@kamilchm
Copy link
Member Author

kamilchm commented Jun 6, 2016

So I leave travis as is.

@kamilchm kamilchm closed this Jun 6, 2016
@kamilchm kamilchm reopened this Jun 6, 2016
@kamilchm
Copy link
Member Author

kamilchm commented Jun 6, 2016

Trying again after @domenkozar fix

@kamilchm
Copy link
Member Author

kamilchm commented Jun 7, 2016

Needs update after #16042

@dguibert
Copy link
Member

By getting rid of go-packages.nix, rclone has removed (introduced by #15852).

I wanted to use go2nix save to rebuild the derivation. But how can I populate GOPATH with all the dependencies for rclone (on NixOS)?

@kamilchm
Copy link
Member Author

kamilchm commented Jun 29, 2016

It should be as easy as using go get github.com/ncw/rclone as stated in http://rclone.org/install/, then go to $GOPATH/src/github.com/ncw/rclone, execute go2nix save and you should see 2 files there default.nix and deps.json. If something goes wrong it'll be go2nix bug that you can report there.

@kamilchm
Copy link
Member Author

kamilchm commented Jun 30, 2016

@edolstra is there a way to use nix parser as a library? I can generate nix instead of json using text templates in Go but I can't automate package reuse in go2nix without parsing nix.
I remember that there was an initiative by @zimbatm to make a subset of nix with only literal values, but it looks like it's ended as JSON anyway https://github.com/ryantrinkle/nixpkgs/blob/be30ba8e0eabbc2483122ddf9d5911484df3a578/pkgs/build-support/fetchgit/nix-prefetch-git#L326 ?

@dguibert dguibert mentioned this pull request Jun 30, 2016
7 tasks
@zimbatm
Copy link
Member

zimbatm commented Jun 30, 2016

@kamilchm I think we should drop the libs.json altogether. Then it's not a problem because you don't have to parse the nix code, you just generate new deps.nix files.

Because of the content-addressable store, if two programs have the same dependency it will already result in the same derivation in the store. Git also has compression in the pack files so it won't make much difference to duplicate the dependencies on disk. And finally most users will just use the binary builds so it won't make any differences to them.

@kamilchm
Copy link
Member Author

You're right. I'll make a proposal PR with deps.nix and leave the package reuse at nix store level.

kamilchm added a commit to kamilchm/nixpkgs that referenced this pull request Jul 26, 2016
After NixOS#16017 there were a lot
of comments saying that `nix` would be better than `JSON`
for Go packages dependency sets.
As said in
NixOS#16017 (comment)

> Because of the content-addressable store, if two programs have the
> same dependency it will already result in the same derivation in the
> store. Git also has compression in the pack files so it won't make
> much difference to duplicate the dependencies on disk. And finally
> most users will just use the binary builds so it won't make any
> differences to them.

This PR removes all `deps.json` and `libs.json` files by replacing
it witth standard `deps.nix` dependecy set files that can be
generated by `go2nix`.
kamilchm added a commit to kamilchm/nixpkgs that referenced this pull request Aug 11, 2016
After NixOS#16017 there were a lot
of comments saying that `nix` would be better than `JSON`
for Go packages dependency sets.
As said in NixOS#16017 (comment)

    > Because of the content-addressable store, if two programs have the
    > same dependency it will already result in the same derivation in
    > the
    > store. Git also has compression in the pack files so it won't make
    > much difference to duplicate the dependencies on disk. And finally
    > most users will just use the binary builds so it won't make any
    > differences to them.

This PR removes `libs.json` file and puts all package dependencies in
theirs `deps.json`.
globin pushed a commit to mayflower/nixpkgs that referenced this pull request Aug 14, 2016
After NixOS#16017 there were a lot
of comments saying that `nix` would be better than `JSON`
for Go packages dependency sets.
As said in NixOS#16017 (comment)

    > Because of the content-addressable store, if two programs have the
    > same dependency it will already result in the same derivation in
    > the
    > store. Git also has compression in the pack files so it won't make
    > much difference to duplicate the dependencies on disk. And finally
    > most users will just use the binary builds so it won't make any
    > differences to them.

This PR removes `libs.json` file and puts all package dependencies in
theirs `deps.json`.
@copumpkin
Copy link
Member

@kamilchm did you lose all the fetchFromGitHub calls in this change? And the buildFromGitHub call was quite nice, since the vast majority of Go packages have a ton of nearly identical boilerplate and fetch from github.

@copumpkin
Copy link
Member

@kamilchm @zimbatm I don't think sharing is a storage-level concern for most of us, so the content-addressable deduplication doesn't really address my concern with it. It's a human-level concern for me, where I want to make sure that if I find that I needed to patch some particular Go package for use with Nix (perhaps because it assumed silly things about an FHS filesystem), I don't have to do that every time I use it, but can do that once. Or that if a particular Go package ends up having a security vulnerability, that I don't need to go hunt down a thousand libs.json files to figure out who's vulnerable.

So in some sense I'm kind of disappointed that this is now the approach, and wish I'd paid attention while this was happening.

dguibert added a commit to dguibert/nixpkgs that referenced this pull request Sep 28, 2016
By getting rid of go-packages.nix (NixOS#16017), rclone has removed (introduced by NixOS#15852).
Mic92 pushed a commit that referenced this pull request Oct 2, 2016
By getting rid of go-packages.nix (#16017), rclone has removed (introduced by #15852).
@rbasso rbasso mentioned this pull request Nov 2, 2016
7 tasks
schneefux pushed a commit to schneefux/nixpkgs that referenced this pull request Dec 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: golang Go is a high-level general purpose programming language that is statically typed and compiled.

Projects

None yet

Development

Successfully merging this pull request may close these issues.