nixpkgs/pkgs/servers/dns/coredns/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

80 lines
2.2 KiB
Nix
Raw Normal View History

2022-05-25 22:45:19 +01:00
{ lib
, stdenv
, buildGoModule
, fetchFromGitHub
2022-12-13 16:00:00 +00:00
, installShellFiles
, externalPlugins ? []
, vendorHash ? "sha256-tp22jj6DNnYFQhtAFW2uLo10ty//dyNqIDH2egDgbOw="
2022-05-25 22:45:19 +01:00
}:
2016-09-21 23:44:32 +01:00
let
attrsToPlugins = attrs:
builtins.map ({name, repo, version}: "${name}:${repo}") attrs;
attrsToSources = attrs:
builtins.map ({name, repo, version}: "${repo}@${version}") attrs;
in buildGoModule rec {
pname = "coredns";
version = "1.11.1";
2016-09-21 23:44:32 +01:00
src = fetchFromGitHub {
2019-01-30 11:50:31 +00:00
owner = "coredns";
2016-09-21 23:44:32 +01:00
repo = "coredns";
rev = "v${version}";
sha256 = "sha256-XZoRN907PXNKV2iMn51H/lt8yPxhPupNfJ49Pymdm9Y=";
2016-09-21 23:44:32 +01:00
};
inherit vendorHash;
2016-09-21 23:44:32 +01:00
2022-12-13 16:00:00 +00:00
nativeBuildInputs = [ installShellFiles ];
outputs = [ "out" "man" ];
# Override the go-modules fetcher derivation to fetch plugins
modBuildPhase = ''
for plugin in ${builtins.toString (attrsToPlugins externalPlugins)}; do echo $plugin >> plugin.cfg; done
for src in ${builtins.toString (attrsToSources externalPlugins)}; do go get $src; done
GOOS= GOARCH= go generate
go mod vendor
'';
modInstallPhase = ''
mv -t vendor go.mod go.sum plugin.cfg
cp -r --reflink=auto vendor "$out"
'';
preBuild = ''
chmod -R u+w vendor
mv -t . vendor/go.{mod,sum} vendor/plugin.cfg
GOOS= GOARCH= go generate
'';
2022-03-16 13:42:28 +00:00
postPatch = ''
substituteInPlace test/file_cname_proxy_test.go \
--replace "TestZoneExternalCNAMELookupWithProxy" \
"SkipZoneExternalCNAMELookupWithProxy"
substituteInPlace test/readme_test.go \
--replace "TestReadme" "SkipReadme"
# this test fails if any external plugins were imported.
# it's a lint rather than a test of functionality, so it's safe to disable.
substituteInPlace test/presubmit_test.go \
--replace "TestImportOrdering" "SkipImportOrdering"
2022-05-25 22:45:19 +01:00
'' + lib.optionalString stdenv.isDarwin ''
# loopback interface is lo0 on macos
sed -E -i 's/\blo\b/lo0/' plugin/bind/setup_test.go
2022-03-16 13:42:28 +00:00
'';
2022-12-13 16:00:00 +00:00
postInstall = ''
installManPage man/*
'';
meta = with lib; {
2019-12-16 12:05:23 +00:00
homepage = "https://coredns.io";
2016-09-21 23:44:32 +01:00
description = "A DNS server that runs middleware";
license = licenses.asl20;
2022-10-04 18:06:48 +01:00
maintainers = with maintainers; [ rushmorem rtreffer deltaevo ];
2016-09-21 23:44:32 +01:00
};
}