Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go: do not replace path to zoneinfo.zip and mime.types #75013

Merged
merged 2 commits into from Dec 8, 2019
Merged

go: do not replace path to zoneinfo.zip and mime.types #75013

merged 2 commits into from Dec 8, 2019

Conversation

fmpwizard
Copy link
Contributor

@fmpwizard fmpwizard commented Dec 5, 2019

Prepend the nix path to the zoneinfo.zip file and keep the original alternatives
to allow go programs built using nix to run on non nix servers.

see #54603

Motivation for this change

Fixes: #54603

Allow Go programs built using nix to run on servers that don't have nix

Things done

I am very new to nix and could not figure out how to test this branch locally, reading
https://nixos.org/nixpkgs/manual/#chap-submitting-changes

I don't know what to replace this like with:

nix-env -i pkg-name -f <path to your local nixpkgs folder>
$ nix-env -i go -f /nix/store

[...] many warning similar to:
warning: name collision in input Nix expressions, skipping '/nix/store/mcgh4v55zwfp6f1x4b4zrdp6lrzki475-user-environment/nixpkgs'
[...] and finally:
error: cannot auto-call a function that has an argument without a default value ('derivations')

  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.
Notify maintainers

cc @veprbl

Prepend the nix path to the zoneinfo.zip file and keep the original alternatives
to allow go programs built using nix to run on non nix servers.

see #54603
@Mic92
Copy link
Member

Mic92 commented Dec 6, 2019

The -f parameter should point to the git repository you used to make the pull request from:

$ git clone https://github.com/fmpwizard/nixpkgs
$ cd nixpkgs
$nixpkgs> git checkout issue_54603
$nixpkgs> nix-env -i go -f .

@Mic92
Copy link
Member

Mic92 commented Dec 6, 2019

@GrahamcOfBorg build go

@kalbasit kalbasit self-assigned this Dec 7, 2019
@kalbasit
Copy link
Member

kalbasit commented Dec 7, 2019

The same thing is happening with the mime types. I suggest fixing that as well if we want full support outside of Nix.

Our side:

# Patch the mimetype database location which is missing on NixOS.
substituteInPlace src/mime/type_unix.go \
--replace '/etc/mime.types' '${mailcap}/etc/mime.types'

Upstream code: https://github.com/golang/go/blob/da4d58587e0e4028ea384580053c3c455127e446/src/mime/type_unix.go#L19-L23

I'll wait for the second fix before merging to avoid rebuilding twice.

@fmpwizard
Copy link
Contributor Author

@kalbasit great idea, I added a new commit. I tried to test this locally by running

nix-env -i go -f .

(at the root of this repo)

but I get this error:

--- FAIL: TestChown (0.00s)
        os_unix_test.go:51: gid: 100
        os_unix_test.go:63: groups:  [65534 100]
        os_unix_test.go:66: chown /tmp/_Go_TestChown141509686 -1 65534: chown /tmp/_Go_TestChown141509686: invalid argument
FAIL

I'm on Fedora 30 5.3.14-200.fc30.x86_64

Thanks!

@kalbasit
Copy link
Member

kalbasit commented Dec 8, 2019

it works locally for me. Can you please fix the commit, it should go: do not replace path to mime.types. It must start with go: (see CONTRIBUTING.md) and the rest is for consistency. Please also update the title of the PR to reflect the change.

Once that's done, I'll submit it for build by ofborg and test locally on Linux/Mac.

@fmpwizard fmpwizard changed the title go: do not replace path to zoneinfo.zip go: do not replace path to zoneinfo.zip and mime.types Dec 8, 2019
@fmpwizard
Copy link
Contributor Author

@kalbasit thanks, I updated the commit message and the PR title

@kalbasit
Copy link
Member

kalbasit commented Dec 8, 2019

@GrahamcOfBorg build go pet jx

sed -i 's,/usr/share/zoneinfo/,${tzdata}/share/zoneinfo/,' src/time/zoneinfo_unix.go
# prepend the nix path to the zoneinfo files but also leave the original value for static binaries
# that run outside a nix server
sed -i 's,\"/usr/share/zoneinfo/,"${tzdata}/share/zoneinfo/\"\,\n\t&,' src/time/zoneinfo_unix.go
Copy link
Member

Choose a reason for hiding this comment

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

I wonder why are using the zoneinfo from Nix on Linux only. Is there something I'm not aware of @LnL7?

@kalbasit kalbasit merged commit b0db7c4 into NixOS:master Dec 8, 2019
@fmpwizard fmpwizard deleted the issue_54603 branch December 8, 2019 23:45
dtzWill pushed a commit to dtzWill/nixpkgs that referenced this pull request Dec 9, 2019
go: do not replace path to zoneinfo.zip and mime.types
(cherry picked from commit b0db7c4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Go: update path to zoneinfo.zip
3 participants