!QCCCSJHEsTIfozrZxz:nixos.org

Nix + Go

235 Members
Go packaging for and with Nixpkgs. | Be excellent to each other.48 Servers

Load older messages


SenderMessageTime
2 Feb 2025
@k900:0upti.meK900 ⚡️
/nix/store/a1cr17kwgakznfw4pp8paw8yv189ikk5-binutils-2.43.1/bin/ld: cannot find -lresolv: No such file or directory
/nix/store/a1cr17kwgakznfw4pp8paw8yv189ikk5-binutils-2.43.1/bin/ld: cannot find -lpthread: No such file or directory
/nix/store/a1cr17kwgakznfw4pp8paw8yv189ikk5-binutils-2.43.1/bin/ld: cannot find -ldl: No such file or directory
/nix/store/a1cr17kwgakznfw4pp8paw8yv189ikk5-binutils-2.43.1/bin/ld: cannot find -lc: No such file or directory
10:25:21
@k900:0upti.meK900 ⚡️Tried giving it glibc and it still doesn't work10:25:31
@katexochen:matrix.orgPaul Meyer (katexochen) @k900:0upti.me: no instant idea, can you share code for this? 10:43:34
@k900:0upti.meK900 ⚡️Uhh give me like 15 minutes 10:44:41
@k900:0upti.meK900 ⚡️Need to finish some chores before I get to a computer10:44:51
@k900:0upti.meK900 ⚡️
{
  lib,
  buildGoModule,
  fetchFromGitHub,
  libpcap,
  glibc,
}:

buildGoModule rec {
  pname = "ptcpdump";
  version = "0.32.0";

  src = fetchFromGitHub {
    owner = "mozillazg";
    repo = "ptcpdump";
    rev = "v${version}";
    hash = "sha256-ndDSOWaBmKvn7Eo8h72Zg9qGbcz2/IBcSJSw/mk7fUs=";
  };

  vendorHash = null;

  buildInputs = [
    libpcap
  ];

  NIX_LDFLAGS = [
    "-L${glibc}/lib"
  ];

  ldflags = [
    "-X=github.com/mozillazg/ptcpdump/internal.Version=${version}"
    "-X=github.com/mozillazg/ptcpdump/internal.GitCommit=${src.rev}"
  ];

  meta = {
    description = "Process-aware, eBPF-based tcpdump";
    homepage = "https://github.com/mozillazg/ptcpdump";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ k900 ];
    mainProgram = "ptcpdump";
  };
}
10:55:21
@k900:0upti.meK900 ⚡️ The NIX_LDFLAGS was my attempt at getting it to work 10:55:40
@k900:0upti.meK900 ⚡️And it did not work anyway10:55:44
@katexochen:matrix.orgPaul Meyer (katexochen)
{
  buildGoModule,
  fetchFromGitHub,
  stdenv,
  bpftools,
  lib,
  nspr,
  libpcap,
  clang,
  fd,
  go-bindata,
  glibc,
  gnutls,
  bashInteractive,
  postgresql,
  mariadb,
  openssl,
  bash,
  zsh,
  nix-update-script,
}:

buildGoModule rec {
  pname = "ecapture";
  version = "0.9.3";

  src = fetchFromGitHub {
    owner = "gojue";
    repo = "ecapture";
    tag = "v${version}";
    hash = "sha256-nqNFbZrmCleWcRM2HsbgmCHqsar3KmiGYxt55ZqhY+U=";
    fetchSubmodules = true;
  };

  nativeBuildInputs = [
    clang
    fd
    bpftools
    go-bindata
  ];

  newlibpcap = libpcap.overrideAttrs (previousAttrs: {
    configureFlags = previousAttrs.configureFlags ++ [ "--without-libnl" ];
  });

  buildInputs = [
    newlibpcap
    glibc.static
    glibc
  ];

  CGO_LDFLAGS = "-lpcap -lpthread -static";

  ldflags = [
    "-extldflags '-static'"
    "-linkmode=external"
  ];

  hardeningDisable = [
    "zerocallusedregs"
  ];

  postPatch = ''
    substituteInPlace user/config/config_gnutls_linux.go \
      --replace-fail 'return errors.New("cant found Gnutls so load path")' 'gc.Gnutls = "${lib.getLib gnutls}/lib/libgnutls.so.30"' \
      --replace-fail '"errors"' ' '

    substituteInPlace user/module/probe_bash.go \
      --replace-fail '/bin/bash' '${lib.getExe bashInteractive}'

    substituteInPlace user/config/config_bash.go \
      --replace-fail '/bin/bash' '${lib.getExe bashInteractive}'

    substituteInPlace user/config/config_nspr_linux.go \
      --replace-fail '/usr/lib/firefox/libnspr4.so' '${lib.getLib nspr}/lib/libnspr4.so'

    substituteInPlace user/config/config_zsh.go \
      --replace-fail '/bin/zsh' '${lib.getExe zsh}'

    substituteInPlace user/module/probe_zsh.go \
      --replace-fail '/bin/zsh' '${lib.getExe zsh}'

    substituteInPlace cli/cmd/postgres.go \
      --replace-fail '/usr/bin/postgres' '${postgresql}/bin/postgres'

    substituteInPlace cli/cmd/mysqld.go \
      --replace-fail '/usr/sbin/mariadbd' '${mariadb}/bin/mariadbd'

    substituteInPlace user/module/probe_mysqld.go \
      --replace-fail '/usr/sbin/mariadbd' '${mariadb}/bin/mariadbd'

    substituteInPlace user/config/config_openssl_linux.go \
      --replace-fail 'return errors.New("cant found openssl so load path")' 'oc.Openssl = "${lib.getLib openssl}/lib/libssl.so.3"' \
      --replace-fail '"errors"' ' '
  '';

  postConfigure = ''
    sed -i '/git/d' Makefile
    sed -i '/git/d' variables.mk

    substituteInPlace Makefile \
      --replace-fail '/bin/bash' '${lib.getExe bash}'

    make ebpf
    go-bindata -pkg assets -o "assets/ebpf_probe.go" $(find user/bytecode -name "*.o" -printf "./%p ")
  '';

  checkFlags =
    let
      skippedTests = [
        "TestCheckLatest"
      ];
    in
    [ "-skip=^${builtins.concatStringsSep "$|^" skippedTests}$" ];

  vendorHash = "sha256-8ilfqPt5Phuj5Uaf90+Ir/DFN27oW5Fd+Wsp34/EU9M=";

  passthru.updateScript = nix-update-script { };

  meta = {
    description = "Capture SSL/TLS text content without CA certificate Using eBPF";
    changelog = "https://github.com/gojue/ecapture/releases/tag/v${version}";
    homepage = "https://ecapture.cc";
    platforms = [
      "x86_64-linux"
      "aarch64-linux"
    ];
    license = lib.licenses.asl20;
    maintainers = with lib.maintainers; [ bot-wxt1221 ];
    mainProgram = "ecapture";
  };
}

11:26:26
@katexochen:matrix.orgPaul Meyer (katexochen) *
{
  lib,
  buildGoModule,
  fetchFromGitHub,
  libpcap,
  pkg-config,
  glibc,
}:

buildGoModule rec {
  pname = "ptcpdump";
  version = "0.32.0";

  src = fetchFromGitHub {
    owner = "mozillazg";
    repo = "ptcpdump";
    rev = "v${version}";
    hash = "sha256-ndDSOWaBmKvn7Eo8h72Zg9qGbcz2/IBcSJSw/mk7fUs=";
  };

  vendorHash = null;

  subPackages = [ "." ];

  # nativeBuildInputs = [ pkg-config ];
  buildInputs = [
    libpcap
    glibc.static
    glibc
  ];

  tags = [ "static" ];

  ldflags = [
    "-linkmode external"
    "-extldflags -static"
    "-X=github.com/mozillazg/ptcpdump/internal.Version=${version}"
    "-X=github.com/mozillazg/ptcpdump/internal.GitCommit=${src.rev}"
  ];

  # env.CGO_FLAGS_STATIC = "-I${libpcap}/include";
  # env.CGO_LDFLAGS_STATIC = "-L${libpcap}/lib -lpcap ${libpcap}/lib/libpcap.a";

  meta = {
    description = "Process-aware, eBPF-based tcpdump";
    homepage = "https://github.com/mozillazg/ptcpdump";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ k900 ];
    mainProgram = "ptcpdump";
  };
}

11:26:50
@katexochen:matrix.orgPaul Meyer (katexochen)This should get you at least one step further. I found package ecapture to have similar hacks in place, maybe there are more helpful thinks in there. 11:28:06
@katexochen:matrix.orgPaul Meyer (katexochen)* This should get you at least one step further. I found package ecapture to have similar hacks in place, maybe there are more helpful things in there. 11:30:28
@katexochen:matrix.orgPaul Meyer (katexochen)
{
  lib,
  buildGoModule,
  fetchFromGitHub,
  libpcap,
  glibc,
}:

let
  newlibpcap = libpcap.overrideAttrs (previousAttrs: {
    configureFlags = previousAttrs.configureFlags ++ [ "--without-libnl" ];
  });
in

buildGoModule rec {
  pname = "ptcpdump";
  version = "0.32.0";

  src = fetchFromGitHub {
    owner = "mozillazg";
    repo = "ptcpdump";
    rev = "v${version}";
    hash = "sha256-ndDSOWaBmKvn7Eo8h72Zg9qGbcz2/IBcSJSw/mk7fUs=";
  };

  vendorHash = null;

  subPackages = [ "." ];

  buildInputs = [
    newlibpcap
    glibc.static
    glibc
  ];

  tags = [ "static" ];

  ldflags = [
    "-linkmode external"
    "-extldflags -static"
    "-X=github.com/mozillazg/ptcpdump/internal.Version=${version}"
    "-X=github.com/mozillazg/ptcpdump/internal.GitCommit=${src.rev}"
  ];

  meta = {
    description = "Process-aware, eBPF-based tcpdump";
    homepage = "https://github.com/mozillazg/ptcpdump";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ k900 ];
    mainProgram = "ptcpdump";
  };
}
11:46:08
@katexochen:matrix.orgPaul Meyer (katexochen)Works.11:47:44
@k900:0upti.meK900 ⚡️Oof 11:48:03
@k900:0upti.meK900 ⚡️OK I think I'm not going to bother lol 11:48:11
@k900:0upti.meK900 ⚡️This looks giga cursed 11:50:45
@katexochen:matrix.orgPaul Meyer (katexochen)The libpcap override? Or the static linking part?11:51:33
@k900:0upti.meK900 ⚡️Both?11:58:09
@raboof:matrix.org@raboof:matrix.org changed their display name from raboof@FOSDEM to raboof.22:18:17
3 Feb 2025
@anarcompiler:beeper.com@anarcompiler:beeper.com joined the room.07:00:59
5 Feb 2025
@13k:matrix.org@13k:matrix.org left the room.07:34:33
7 Feb 2025
@vxtls:synapse.skymansion.netvxtls joined the room.18:33:56
@jsnf:matrix.orgjsnf joined the room.21:30:00
@diamondburned:matrix.orgDiamond (it/she) changed their profile picture.23:11:04
@diamondburned:matrix.orgDiamond (it/she) changed their profile picture.23:19:12
11 Feb 2025
@lunchtime:envs.netlunchtime left the room.19:06:53
13 Feb 2025
@glepage:matrix.orgGaétan LepageIs there a simple way to skip specific go tests?13:30:28
@katexochen:matrix.orgPaul Meyer (katexochen)https://nixos.org/manual/nixpkgs/unstable/#ssec-skip-go-tests13:31:19
@glepage:matrix.orgGaétan LepageThanks!13:31:43

Show newer messages


Back to Room ListRoom Version: 9