1{ lib, buildGoModule, fetchFromGitHub, makeWrapper, stdenv }:
2
3buildGoModule rec {
4 pname = "delve";
5 version = "1.20.2";
6
7 src = fetchFromGitHub {
8 owner = "go-delve";
9 repo = "delve";
10 rev = "v${version}";
11 sha256 = "sha256-NHVgNoMa/K1wVbXKycd7sdxfCpLYY6kn2uSfJWUpq1o=";
12 };
13
14 vendorHash = null;
15
16 subPackages = [ "cmd/dlv" ];
17
18 nativeBuildInputs = [ makeWrapper ];
19
20 hardeningDisable = [ "fortify" ];
21
22 preCheck = ''
23 XDG_CONFIG_HOME=$(mktemp -d)
24 '';
25
26 # Disable tests on Darwin as they require various workarounds.
27 #
28 # - Tests requiring local networking fail with or without sandbox,
29 # even with __darwinAllowLocalNetworking allowed.
30 # - CGO_FLAGS warnings break tests' expected stdout/stderr outputs.
31 # - DAP test binaries exit prematurely.
32 doCheck = !stdenv.isDarwin;
33
34 postInstall = ''
35 # fortify source breaks build since delve compiles with -O0
36 wrapProgram $out/bin/dlv \
37 --prefix disableHardening " " fortify
38
39 # add symlink for vscode golang extension
40 # https://github.com/golang/vscode-go/blob/master/docs/debugging.md#manually-installing-dlv-dap
41 ln $out/bin/dlv $out/bin/dlv-dap
42 '';
43
44 meta = with lib; {
45 description = "debugger for the Go programming language";
46 homepage = "https://github.com/go-delve/delve";
47 maintainers = with maintainers; [ SuperSandro2000 vdemeester ];
48 license = licenses.mit;
49 mainProgram = "dlv";
50 };
51}