2021-09-18 10:52:07 +00:00
|
|
|
{ lib
|
2024-09-19 14:19:46 +00:00
|
|
|
, stdenv
|
|
|
|
, fetchpatch
|
2021-09-18 10:52:07 +00:00
|
|
|
, buildGoModule
|
|
|
|
, fetchFromGitHub
|
|
|
|
, nixosTests
|
|
|
|
, libcap
|
2024-09-19 14:19:46 +00:00
|
|
|
, go
|
2021-09-18 10:52:07 +00:00
|
|
|
}:
|
2020-07-18 16:06:22 +00:00
|
|
|
|
2021-09-18 10:52:07 +00:00
|
|
|
let
|
2020-07-18 16:06:22 +00:00
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
# Note: this module is actually the source code of crypto/x509
|
|
|
|
# taken from the Go stdlib and patcheed. So, it can't simply
|
|
|
|
# be pinned and added to the vendor dir as everything else.
|
|
|
|
x509 = stdenv.mkDerivation rec {
|
|
|
|
pname = "x509-compressed";
|
|
|
|
version = "0.0.3";
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "namecoin";
|
|
|
|
repo = "x509-compressed";
|
|
|
|
rev = "v${version}";
|
|
|
|
hash = "sha256-BmVtClZ3TsUbQrhwREXa42pUOlkBA4a2HVBzl1sdBIo=";
|
|
|
|
};
|
|
|
|
|
|
|
|
patches = [
|
|
|
|
# https://github.com/namecoin/x509-compressed/pull/4
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://github.com/namecoin/x509-compressed/commit/b4fb598b.patch";
|
|
|
|
hash = "sha256-S4Y4B4FH15IyaTJtSb03C8QffnsMXSYc6q1Gka/PVV4=";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
|
|
|
nativeBuildInputs = [ go ];
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
# Put in our own lockfiles
|
|
|
|
cp ${./x509-go.mod} go.mod
|
|
|
|
cp ${./x509-go.sum} go.sum
|
|
|
|
|
|
|
|
# Generate Go code
|
|
|
|
env HOME=/tmp go generate ./...
|
|
|
|
|
|
|
|
# Clean up more references to internal modules
|
|
|
|
# (see https://github.com/namecoin/x509-compressed/pull/4)
|
|
|
|
sed -e '/import "internal/d' \
|
|
|
|
-e 's/goos.IsAndroid/0/g' -i x509/*.go
|
|
|
|
'';
|
2021-09-18 10:52:07 +00:00
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
installPhase = ''
|
|
|
|
cp -r . "$out"
|
2021-09-18 10:52:07 +00:00
|
|
|
'';
|
2020-07-18 16:06:22 +00:00
|
|
|
};
|
|
|
|
|
2021-09-18 10:52:07 +00:00
|
|
|
in
|
|
|
|
|
|
|
|
buildGoModule {
|
|
|
|
pname = "ncdns";
|
2024-09-19 14:19:46 +00:00
|
|
|
version = "unstable-2024-05-18";
|
2021-09-18 10:52:07 +00:00
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "namecoin";
|
|
|
|
repo = "ncdns";
|
|
|
|
rev = "8a9f7c3037384f12fae400268d0a7f79d26b5532";
|
|
|
|
hash = "sha256-lFpjfpOAgvYoV3ci2oSdy8ZOlQ2rWlApiFWcvOMdkyk=";
|
|
|
|
};
|
2021-09-18 10:52:07 +00:00
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
# Note: to update ncdns add the following lines
|
|
|
|
#
|
|
|
|
# chmod -R +w .
|
|
|
|
# go mod tidy
|
|
|
|
# cat go.mod go.sum
|
|
|
|
# exit 1
|
|
|
|
#
|
|
|
|
# to the `preBuild` here and update the lock files
|
|
|
|
preBuild = ''
|
|
|
|
# Sideload the generated x509 module
|
|
|
|
ln -s '${x509}' x509
|
2021-09-18 10:52:07 +00:00
|
|
|
'';
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
vendorHash = "sha256-FoCK2qkhbc+6D4V77pNLiC9d68nkeYJxb7uiNYEP2Xw=";
|
2020-07-18 16:06:22 +00:00
|
|
|
|
|
|
|
buildInputs = [ libcap ];
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
patches = [./fix-tpl-path.patch ];
|
2021-09-18 10:52:07 +00:00
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
# Put in our own lockfiles
|
|
|
|
postPatch = ''
|
|
|
|
cp ${./ncdns-go.mod} go.mod
|
|
|
|
cp ${./ncdns-go.sum} go.sum
|
2021-09-18 10:52:07 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
preCheck = ''
|
|
|
|
# needed to run the ncdns test suite
|
2024-09-19 14:19:46 +00:00
|
|
|
ln -s $PWD/vendor ../go/src
|
2021-09-18 10:52:07 +00:00
|
|
|
'';
|
|
|
|
|
2020-07-18 16:06:22 +00:00
|
|
|
postInstall = ''
|
|
|
|
mkdir -p "$out/share"
|
2021-09-18 10:52:07 +00:00
|
|
|
cp -r _doc "$out/share/doc"
|
|
|
|
cp -r _tpl "$out/share/tpl"
|
2020-07-18 16:06:22 +00:00
|
|
|
'';
|
|
|
|
|
2022-07-18 16:21:45 +00:00
|
|
|
passthru.tests.ncdns = nixosTests.ncdns;
|
|
|
|
|
2020-07-18 16:06:22 +00:00
|
|
|
meta = with lib; {
|
|
|
|
description = "Namecoin to DNS bridge daemon";
|
|
|
|
homepage = "https://github.com/namecoin/ncdns";
|
|
|
|
license = licenses.gpl3Plus;
|
|
|
|
maintainers = with maintainers; [ rnhmjoj ];
|
|
|
|
};
|
|
|
|
}
|