about summary refs log tree commit diff
path: root/nixpkgs/pkgs/servers/dns/ncdns/default.nix
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2021-09-13 11:53:06 +0000
committerAlyssa Ross <hi@alyssa.is>2021-09-13 17:18:49 +0000
commitc3e005913d59b8ad64004e60888a71816688af1f (patch)
treef65b32f0d16acaa40f2ee82ac736d150de4b6cf5 /nixpkgs/pkgs/servers/dns/ncdns/default.nix
parent1c8034da05499ca3d999f57ba1f6b235e7711ee1 (diff)
parentdb88608d8c811a93b74c99cfa1224952afc78200 (diff)
downloadnixlib-c3e005913d59b8ad64004e60888a71816688af1f.tar
nixlib-c3e005913d59b8ad64004e60888a71816688af1f.tar.gz
nixlib-c3e005913d59b8ad64004e60888a71816688af1f.tar.bz2
nixlib-c3e005913d59b8ad64004e60888a71816688af1f.tar.lz
nixlib-c3e005913d59b8ad64004e60888a71816688af1f.tar.xz
nixlib-c3e005913d59b8ad64004e60888a71816688af1f.tar.zst
nixlib-c3e005913d59b8ad64004e60888a71816688af1f.zip
Merge commit 'db88608d8c811a93b74c99cfa1224952afc78200'
Conflicts:
	nixpkgs/nixos/modules/config/update-users-groups.pl
Diffstat (limited to 'nixpkgs/pkgs/servers/dns/ncdns/default.nix')
-rw-r--r--nixpkgs/pkgs/servers/dns/ncdns/default.nix102
1 files changed, 89 insertions, 13 deletions
diff --git a/nixpkgs/pkgs/servers/dns/ncdns/default.nix b/nixpkgs/pkgs/servers/dns/ncdns/default.nix
index b046aff12bd7..7fad548df7a5 100644
--- a/nixpkgs/pkgs/servers/dns/ncdns/default.nix
+++ b/nixpkgs/pkgs/servers/dns/ncdns/default.nix
@@ -1,27 +1,103 @@
-{ lib, nixosTests, git, buildGoPackage, fetchFromGitHub, libcap }:
+{ lib
+, buildGoModule
+, fetchFromGitHub
+, nixosTests
+, libcap
+}:
 
-buildGoPackage rec {
-  pname = "ncdns";
-  version = "2020-11-22";
-
-  goPackagePath = "github.com/namecoin/ncdns";
-  goDeps = ./deps.nix;
+let
 
-  src = fetchFromGitHub {
+  # ncdns source
+  ncdns = fetchFromGitHub {
     owner = "namecoin";
     repo = "ncdns";
-    rev = "2fa54cd3b5480dba82170ab8ecb511fbd4977c41";
-    sha256 = "0mrxbg5lmy3s281ff6nxpp03z4mqwq7h5hkqm9qy8nb280x1sx7h";
+    rev = "2a486311b0fe1a921af34aa3b31e6e4e0569accc";
+    sha256 = "01arwlycp1iia4bd3dgyn8dam1av2a7d9hv7f085n14l2i2aza7v";
+  };
+
+  # script to patch the crypto/x509 package
+  x509 = fetchFromGitHub {
+    owner = "namecoin";
+    repo = "x509-compressed";
+    rev = "fb9f2b7bc9fcba954d70f63857cc0c3841b1cf47";
+    sha256 = "1arkbpbzvhcmz5fhjqg34x2jbjnwmlisapk22rjki17qpamh7zks";
+    # ncdns must be put in a subdirectory for this to work.
+    extraPostFetch = ''
+      cp -r --no-preserve=mode "${ncdns}" "$out/ncdns"
+    '';
   };
 
-  patches = [ ./fix-tpl-path.patch ];
+in
+
+buildGoModule {
+  pname = "ncdns";
+  version = "unstable-2020-07-18";
+
+  src = x509;
+
+  vendorSha256 = "02bqf6vkj5msk35sr5sklnqqd16n7gns7knzqslw077xrxiz7bsg";
+
+  # Override the go-modules fetcher derivation to apply
+  # 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"
+  '';
 
   buildInputs = [ libcap ];
 
+  # 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
+
+    runHook postUpack
+  '';
+
+  # 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
+  '';
+
   postInstall = ''
     mkdir -p "$out/share"
-    cp -r "$src/_doc" "$out/share/doc"
-    cp -r "$src/_tpl" "$out/share/tpl"
+    cp -r _doc "$out/share/doc"
+    cp -r _tpl "$out/share/tpl"
   '';
 
   meta = with lib; {