From 4fd2bcb0fee6f737421c005d6d02a74a9132e7e0 Mon Sep 17 00:00:00 2001 From: zowoq <59103226+zowoq@users.noreply.github.com> Date: Mon, 8 Aug 2022 10:50:52 +1000 Subject: [PATCH] go: convert seds to substitute patches --- pkgs/development/compilers/go/1.18.nix | 30 +++++++++++-------- pkgs/development/compilers/go/1.19.nix | 30 +++++++++++-------- .../compilers/go/iana-etc-1.17.patch | 26 ++++++++++++++++ .../compilers/go/mailcap-1.17.patch | 12 ++++++++ .../compilers/go/tzdata-1.17.patch | 12 ++++++++ .../compilers/go/tzdata-1.19.patch | 12 ++++++++ 6 files changed, 98 insertions(+), 24 deletions(-) create mode 100644 pkgs/development/compilers/go/iana-etc-1.17.patch create mode 100644 pkgs/development/compilers/go/mailcap-1.17.patch create mode 100644 pkgs/development/compilers/go/tzdata-1.17.patch create mode 100644 pkgs/development/compilers/go/tzdata-1.19.patch diff --git a/pkgs/development/compilers/go/1.18.nix b/pkgs/development/compilers/go/1.18.nix index f004b9308071..364e562fbfc3 100644 --- a/pkgs/development/compilers/go/1.18.nix +++ b/pkgs/development/compilers/go/1.18.nix @@ -2,6 +2,7 @@ , stdenv , fetchurl , tzdata +, substituteAll , iana-etc , which , pkg-config @@ -68,21 +69,26 @@ stdenv.mkDerivation rec { hardeningDisable = [ "all" ]; postPatch = '' - patchShebangs ./ # replace /bin/bash - - # Patch the mimetype database location which is missing on NixOS. - # 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 - - sed -i 's,/etc/protocols,${iana-etc}/etc/protocols,' src/net/lookup_unix.go - sed -i 's,/etc/services,${iana-etc}/etc/services,' src/net/port_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 + patchShebangs . ''; patches = [ + (substituteAll { + src = ./iana-etc-1.17.patch; + iana = iana-etc; + }) + # Patch the mimetype database location which is missing on NixOS. + # but also allow static binaries built with NixOS to run outside nix + (substituteAll { + src = ./mailcap-1.17.patch; + inherit mailcap; + }) + # prepend the nix path to the zoneinfo files but also leave the original value for static binaries + # that run outside a nix server + (substituteAll { + src = ./tzdata-1.17.patch; + inherit tzdata; + }) ./remove-tools-1.11.patch ./ssl-cert-file-1.16.patch ./go_no_vendor_checks-1.16.patch diff --git a/pkgs/development/compilers/go/1.19.nix b/pkgs/development/compilers/go/1.19.nix index ca24592e93e3..cd2685835efb 100644 --- a/pkgs/development/compilers/go/1.19.nix +++ b/pkgs/development/compilers/go/1.19.nix @@ -2,6 +2,7 @@ , stdenv , fetchurl , tzdata +, substituteAll , iana-etc , which , pkg-config @@ -68,21 +69,26 @@ stdenv.mkDerivation rec { hardeningDisable = [ "all" ]; postPatch = '' - patchShebangs ./ # replace /bin/bash - - # Patch the mimetype database location which is missing on NixOS. - # 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 - - sed -i 's,/etc/protocols,${iana-etc}/etc/protocols,' src/net/lookup_unix.go - sed -i 's,/etc/services,${iana-etc}/etc/services,' src/net/port_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 + patchShebangs . ''; patches = [ + (substituteAll { + src = ./iana-etc-1.17.patch; + iana = iana-etc; + }) + # Patch the mimetype database location which is missing on NixOS. + # but also allow static binaries built with NixOS to run outside nix + (substituteAll { + src = ./mailcap-1.17.patch; + inherit mailcap; + }) + # prepend the nix path to the zoneinfo files but also leave the original value for static binaries + # that run outside a nix server + (substituteAll { + src = ./tzdata-1.19.patch; + inherit tzdata; + }) ./remove-tools-1.11.patch ./ssl-cert-file-1.16.patch ./go_no_vendor_checks-1.16.patch diff --git a/pkgs/development/compilers/go/iana-etc-1.17.patch b/pkgs/development/compilers/go/iana-etc-1.17.patch new file mode 100644 index 000000000000..6f1382758989 --- /dev/null +++ b/pkgs/development/compilers/go/iana-etc-1.17.patch @@ -0,0 +1,26 @@ +diff --git a/src/net/lookup_unix.go b/src/net/lookup_unix.go +index 8030e3d99e..5a7472d933 100644 +--- a/src/net/lookup_unix.go ++++ b/src/net/lookup_unix.go +@@ -21,7 +21,7 @@ var onceReadProtocols sync.Once + // readProtocols loads contents of /etc/protocols into protocols map + // for quick access. + func readProtocols() { +- file, err := open("/etc/protocols") ++ file, err := open("@iana@/etc/protocols") + if err != nil { + return + } +diff --git a/src/net/port_unix.go b/src/net/port_unix.go +index a9a96a2323..0df6efe9e5 100644 +--- a/src/net/port_unix.go ++++ b/src/net/port_unix.go +@@ -17,7 +17,7 @@ import ( + var onceReadServices sync.Once + + func readServices() { +- file, err := open("/etc/services") ++ file, err := open("@iana@/etc/services") + if err != nil { + return + } diff --git a/pkgs/development/compilers/go/mailcap-1.17.patch b/pkgs/development/compilers/go/mailcap-1.17.patch new file mode 100644 index 000000000000..6e4302acc097 --- /dev/null +++ b/pkgs/development/compilers/go/mailcap-1.17.patch @@ -0,0 +1,12 @@ +diff --git a/src/mime/type_unix.go b/src/mime/type_unix.go +index f954bc8a1f..06d897bfbf 100644 +--- a/src/mime/type_unix.go ++++ b/src/mime/type_unix.go +@@ -26,6 +26,7 @@ var mimeGlobs = []string{ + + // Common locations for mime.types files on unix. + var typeFiles = []string{ ++ "@mailcap@/etc/mime.types", + "/etc/mime.types", + "/etc/apache2/mime.types", + "/etc/apache/mime.types", diff --git a/pkgs/development/compilers/go/tzdata-1.17.patch b/pkgs/development/compilers/go/tzdata-1.17.patch new file mode 100644 index 000000000000..5532c8d32366 --- /dev/null +++ b/pkgs/development/compilers/go/tzdata-1.17.patch @@ -0,0 +1,12 @@ +diff --git a/src/time/zoneinfo_unix.go b/src/time/zoneinfo_unix.go +index 4ea029dbde..af94a4d90b 100644 +--- a/src/time/zoneinfo_unix.go ++++ b/src/time/zoneinfo_unix.go +@@ -20,6 +20,7 @@ import ( + // Many systems use /usr/share/zoneinfo, Solaris 2 has + // /usr/share/lib/zoneinfo, IRIX 6 has /usr/lib/locale/TZ. + var zoneSources = []string{ ++ "@tzdata@/share/zoneinfo/", + "/usr/share/zoneinfo/", + "/usr/share/lib/zoneinfo/", + "/usr/lib/locale/TZ/", diff --git a/pkgs/development/compilers/go/tzdata-1.19.patch b/pkgs/development/compilers/go/tzdata-1.19.patch new file mode 100644 index 000000000000..f5b55d5d7e5c --- /dev/null +++ b/pkgs/development/compilers/go/tzdata-1.19.patch @@ -0,0 +1,12 @@ +diff --git a/src/time/zoneinfo_unix.go b/src/time/zoneinfo_unix.go +index 67b8beb47b..5cd1fb1759 100644 +--- a/src/time/zoneinfo_unix.go ++++ b/src/time/zoneinfo_unix.go +@@ -18,6 +18,7 @@ import ( + // Many systems use /usr/share/zoneinfo, Solaris 2 has + // /usr/share/lib/zoneinfo, IRIX 6 has /usr/lib/locale/TZ. + var platformZoneSources = []string{ ++ "@tzdata@/share/zoneinfo/", + "/usr/share/zoneinfo/", + "/usr/share/lib/zoneinfo/", + "/usr/lib/locale/TZ/",