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

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

112 lines
2.6 KiB
Nix
Raw Normal View History

2021-09-08 20:38:57 +00:00
{ lib
, buildGoModule
, fetchFromGitHub
, nixosTests
, libcap
}:
2020-06-04 20:49:55 +00:00
2021-09-08 20:38:57 +00:00
let
2020-06-04 20:49:55 +00:00
2021-09-08 20:38:57 +00:00
# ncdns source
ncdns = fetchFromGitHub {
2020-06-04 20:49:55 +00:00
owner = "namecoin";
repo = "ncdns";
2022-10-25 13:24:17 +00:00
rev = "5adda8d4726d389597df432eb2e17eac1677cea2";
sha256 = "sha256-Q/RrUTY4WfrByvQv1eCX29DQNf2vSIR29msmhgS73xk=";
2021-09-08 20:38:57 +00:00
};
# script to patch the crypto/x509 package
x509 = fetchFromGitHub {
owner = "namecoin";
repo = "x509-compressed";
2022-10-25 13:24:17 +00:00
rev = "2e30a62a69dac54a977410f283308df232a5d244";
sha256 = "sha256-/Bd1gYjguj8AiKHyiaIKT+Y3R7kq5gLZlJhY9g/xFXk=";
2021-09-08 20:38:57 +00:00
# ncdns must be put in a subdirectory for this to work.
2022-05-17 19:10:33 +00:00
postFetch = ''
2021-09-08 20:38:57 +00:00
cp -r --no-preserve=mode "${ncdns}" "$out/ncdns"
'';
2020-06-04 20:49:55 +00:00
};
2021-09-08 20:38:57 +00:00
in
buildGoModule {
pname = "ncdns";
2022-10-25 13:24:17 +00:00
version = "unstable-2022-10-07";
2021-09-08 20:38:57 +00:00
src = x509;
vendorHash = "sha256-ENtTnDsz5WhRz1kiqnWQ5vyEpZtgi7ZeYvksffgW78k=";
2021-09-08 20:38:57 +00:00
# Override the goModules fetcher derivation to apply
2021-09-08 20:38:57 +00:00
# upstream's patch of the crypto/x509 library.
modBuildPhase = ''
go mod init github.com/namecoin/x509-compressed
go generate ./...
go mod tidy
cd ncdns
go mod init github.com/namecoin/ncdns
go mod edit \
-replace github.com/coreos/go-systemd=github.com/coreos/go-systemd/v22@latest \
-replace github.com/namecoin/x509-compressed=$NIX_BUILD_TOP/source
go mod tidy
'';
# Copy over the lockfiles as well, because the source
# doesn't contain it. The fixed-output derivation is
# probably not reproducible anyway.
modInstallPhase = ''
mv -t vendor go.mod go.sum
cp -r --reflink=auto vendor "$out"
'';
2020-06-04 20:49:55 +00:00
buildInputs = [ libcap ];
2021-09-08 20:38:57 +00:00
# The fetcher derivation must run with a different
# $sourceRoot, but buildGoModule doesn't allow that,
# so we use this ugly hack.
unpackPhase = ''
runHook preUnpack
unpackFile "$src"
sourceRoot=$PWD/source/ncdns
chmod -R u+w -- "$sourceRoot"
cd $sourceRoot
2023-05-24 16:21:18 +00:00
runHook postUnpack
2021-09-08 20:38:57 +00:00
'';
# Same as above: can't use `patches` because that would
# be also applied to the fetcher derivation, thus failing.
patchPhase = ''
runHook prePatch
patch -p1 < ${./fix-tpl-path.patch}
runHook postPatch
'';
preBuild = ''
chmod -R u+w vendor
mv -t . vendor/go.{mod,sum}
'';
preCheck = ''
# needed to run the ncdns test suite
ln -s $PWD/vendor ../../go/src
'';
2020-06-04 20:49:55 +00:00
postInstall = ''
mkdir -p "$out/share"
2021-09-08 20:38:57 +00:00
cp -r _doc "$out/share/doc"
cp -r _tpl "$out/share/tpl"
2020-06-04 20:49:55 +00:00
'';
2022-07-13 12:06:10 +00:00
passthru.tests.ncdns = nixosTests.ncdns;
2020-06-04 20:49:55 +00:00
meta = with lib; {
description = "Namecoin to DNS bridge daemon";
homepage = "https://github.com/namecoin/ncdns";
license = licenses.gpl3Plus;
maintainers = with maintainers; [ rnhmjoj ];
};
}