audiobookshelf: 2.18.1 -> 2.19.0 (#378967)
[NixPkgs.git] / pkgs / by-name / nc / ncdns / package.nix
bloba603b9674f029dbd32536d16f81337c44f564ec8
2   lib,
3   stdenv,
4   fetchpatch,
5   buildGoModule,
6   fetchFromGitHub,
7   nixosTests,
8   libcap,
9   go,
12 let
14   # Note: this module is actually the source code of crypto/x509
15   # taken from the Go stdlib and patcheed. So, it can't simply
16   # be pinned and added to the vendor dir as everything else.
17   x509 = stdenv.mkDerivation rec {
18     pname = "x509-compressed";
19     version = "0.0.3";
21     src = fetchFromGitHub {
22       owner = "namecoin";
23       repo = "x509-compressed";
24       rev = "v${version}";
25       hash = "sha256-BmVtClZ3TsUbQrhwREXa42pUOlkBA4a2HVBzl1sdBIo=";
26     };
28     patches = [
29       # https://github.com/namecoin/x509-compressed/pull/4
30       (fetchpatch {
31         url = "https://github.com/namecoin/x509-compressed/commit/b4fb598b.patch";
32         hash = "sha256-S4Y4B4FH15IyaTJtSb03C8QffnsMXSYc6q1Gka/PVV4=";
33       })
34     ];
36     nativeBuildInputs = [ go ];
38     buildPhase = ''
39       # Put in our own lockfiles
40       cp ${./x509-go.mod} go.mod
41       cp ${./x509-go.sum} go.sum
43       # Generate Go code
44       env HOME=/tmp go generate ./...
46       # Clean up more references to internal modules
47       # (see https://github.com/namecoin/x509-compressed/pull/4)
48       sed -e '/import "internal/d' \
49           -e 's/goos.IsAndroid/0/g' -i x509/*.go
50     '';
52     installPhase = ''
53       cp -r . "$out"
54     '';
55   };
59 buildGoModule {
60   pname = "ncdns";
61   version = "unstable-2024-05-18";
63   src = fetchFromGitHub {
64     owner = "namecoin";
65     repo = "ncdns";
66     rev = "8a9f7c3037384f12fae400268d0a7f79d26b5532";
67     hash = "sha256-lFpjfpOAgvYoV3ci2oSdy8ZOlQ2rWlApiFWcvOMdkyk=";
68   };
70   # Note: to update ncdns add the following lines
71   #
72   #   chmod -R +w .
73   #   go mod tidy
74   #   cat go.mod go.sum
75   #   exit 1
76   #
77   # to the `preBuild` here and update the lock files
78   preBuild = ''
79     # Sideload the generated x509 module
80     ln -s '${x509}' x509
81   '';
83   vendorHash = "sha256-FoCK2qkhbc+6D4V77pNLiC9d68nkeYJxb7uiNYEP2Xw=";
85   buildInputs = [ libcap ];
87   patches = [ ./fix-tpl-path.patch ];
89   # Put in our own lockfiles
90   postPatch = ''
91     cp ${./ncdns-go.mod} go.mod
92     cp ${./ncdns-go.sum} go.sum
93   '';
95   preCheck = ''
96     # needed to run the ncdns test suite
97     ln -s $PWD/vendor ../go/src
98   '';
100   postInstall = ''
101     mkdir -p "$out/share"
102     cp -r _doc "$out/share/doc"
103     cp -r _tpl "$out/share/tpl"
104   '';
106   passthru.tests.ncdns = nixosTests.ncdns;
108   meta = with lib; {
109     description = "Namecoin to DNS bridge daemon";
110     homepage = "https://github.com/namecoin/ncdns";
111     license = licenses.gpl3Plus;
112     maintainers = with maintainers; [ rnhmjoj ];
113   };