From 5a0be78562c7de3daa450ee2c4698842e8ff7f8c Mon Sep 17 00:00:00 2001 From: Diego Medina Date: Wed, 4 Dec 2019 21:45:41 -0500 Subject: [PATCH 1/2] go: do not replace path to zoneinfo.zip 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 https://github.com/NixOS/nixpkgs/issues/54603 --- pkgs/development/compilers/go/1.13.nix | 5 ++++- pkgs/development/compilers/go/1.4.nix | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pkgs/development/compilers/go/1.13.nix b/pkgs/development/compilers/go/1.13.nix index 9e8a6601724b..aad9ab9c68ef 100644 --- a/pkgs/development/compilers/go/1.13.nix +++ b/pkgs/development/compilers/go/1.13.nix @@ -97,7 +97,10 @@ stdenv.mkDerivation rec { rm src/net/cgo_unix_test.go '' + optionalString stdenv.isLinux '' - 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 + '' + optionalString stdenv.isAarch32 '' echo '#!${runtimeShell}' > misc/cgo/testplugin/test.bash '' + optionalString stdenv.isDarwin '' diff --git a/pkgs/development/compilers/go/1.4.nix b/pkgs/development/compilers/go/1.4.nix index 1052f1f1ae1e..0dd852a1ef16 100644 --- a/pkgs/development/compilers/go/1.4.nix +++ b/pkgs/development/compilers/go/1.4.nix @@ -61,7 +61,9 @@ stdenv.mkDerivation rec { sed -i 's,/etc/protocols,${iana-etc}/etc/protocols,' src/net/lookup_unix.go '' + lib.optionalString stdenv.isLinux '' - 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 # Find the loader dynamically LOADER="$(find ${lib.getLib libc}/lib -name ld-linux\* | head -n 1)" From 051bc353d06c86602f9af078cae4d839b819ca23 Mon Sep 17 00:00:00 2001 From: Diego Medina Date: Sat, 7 Dec 2019 21:45:25 -0500 Subject: [PATCH 2/2] go: do not replace path to mime.types --- pkgs/development/compilers/go/1.13.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/compilers/go/1.13.nix b/pkgs/development/compilers/go/1.13.nix index aad9ab9c68ef..4354529a58cd 100644 --- a/pkgs/development/compilers/go/1.13.nix +++ b/pkgs/development/compilers/go/1.13.nix @@ -57,8 +57,8 @@ stdenv.mkDerivation rec { --replace '#!/usr/bin/env bash' '#!${runtimeShell}' # Patch the mimetype database location which is missing on NixOS. - substituteInPlace src/mime/type_unix.go \ - --replace '/etc/mime.types' '${mailcap}/etc/mime.types' + # but also allow static binaries built with NixOS to run outside nix + sed -i 's,\"/etc/mime.types,"${mailcap}/etc/mime.types\"\,\n\t&,' src/mime/type_unix.go # Disabling the 'os/http/net' tests (they want files not available in # chroot builds)