Unverified Commit 7c5ef35c authored by Matthieu Coudron's avatar Matthieu Coudron Committed by GitHub
Browse files

tailscale: use buildGoModule and enable tests (#386492)

parents 9ae53ffe 079c28fb
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  buildGo123Module,
  buildGoModule,
  tailscale,
}:

buildGo123Module {
buildGoModule {
  pname = "tailscale-nginx-auth";
  inherit (tailscale) version src vendorHash;

@@ -27,11 +27,11 @@ buildGo123Module {
    install -D -m0444 -t $out/lib/systemd/system ./cmd/nginx-auth/tailscale.nginx-auth.socket
  '';

  meta = with lib; {
  meta = {
    homepage = "https://tailscale.com";
    description = "Tool that allows users to use Tailscale Whois authentication with NGINX as a reverse proxy";
    license = licenses.bsd3;
    license = lib.licenses.bsd3;
    mainProgram = "tailscale.nginx-auth";
    maintainers = with maintainers; [ phaer ];
    maintainers = with lib.maintainers; [ phaer ];
  };
}
+72 −9
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  buildGo123Module,

  buildGoModule,
  fetchFromGitHub,
  fetchpatch,

  makeWrapper,
  installShellFiles,
  # runtime tooling - linux
  getent,
  iproute2,
  iptables,
  lsof,
  shadow,
  procps,
  # runtime tooling - darwin
  lsof,

  nixosTests,
  installShellFiles,
  tailscale-nginx-auth,
}:

let
  version = "1.80.2";
in
buildGo123Module {
buildGoModule {
  pname = "tailscale";
  inherit version;

@@ -60,6 +65,12 @@ buildGo123Module {
    "cmd/tsidp"
  ];

  excludedPackages = [
    # exlude integration tests which fail to work
    # and require additional tooling
    "tstest/integration"
  ];

  ldflags = [
    "-w"
    "-s"
@@ -71,7 +82,59 @@ buildGo123Module {
    "ts_include_cli"
  ];

  doCheck = false;
  # remove vendored tooling to ensure it's not used
  # also avoids some unnecessary tests
  preBuild = ''
    rm -rf ./tool
  '';

  preCheck = ''
    # feed in all tests for testing
    # subPackages above limits what is built to just what we
    # want but also limits the tests
    unset subPackages

    # several tests hang
    rm tsnet/tsnet_test.go
  '';

  checkFlags =
    let
      skippedTests = [
        # dislikes vendoring
        "TestPackageDocs" # .
        # tries to start tailscaled
        "TestContainerBoot" # cmd/containerboot

        # just part of a tool which generates yaml for k8s CRDs
        # requires helm
        "Test_generate" # cmd/k8s-operator/generate
        # self reported potentially flakey test
        "TestConnMemoryOverhead" # control/controlbase

        # interacts with `/proc/net/route` and need a default route
        "TestDefaultRouteInterface" # net/netmon
        "TestRouteLinuxNetlink" # net/netmon
        "TestGetRouteTable" # net/routetable

        # remote udp call to 8.8.8.8
        "TestDefaultInterfacePortable" # net/netutil

        # launches an ssh server which works when provided openssh
        # also requires executing commands but nixbld user has /noshell
        "TestSSH" # ssh/tailssh
        # wants users alice & ubuntu
        "TestMultipleRecorders" # ssh/tailssh
        "TestSSHAuthFlow" # ssh/tailssh
        "TestSSHRecordingCancelsSessionsOnUploadFailure" # ssh/tailssh
        "TestSSHRecordingNonInteractive" # ssh/tailssh

        # test for a dev util which helps to fork golang.org/x/crypto/acme
        # not necessary and fails to match
        "TestSyncedToUpstream" # tempfork/acme
      ];
    in
    [ "-skip=^${builtins.concatStringsSep "$|^" skippedTests}$" ];

  postInstall =
    ''
@@ -93,9 +156,9 @@ buildGo123Module {
      wrapProgram $out/bin/tailscaled \
        --prefix PATH : ${
          lib.makeBinPath [
            getent
            iproute2
            iptables
            getent
            shadow
          ]
        } \
@@ -116,13 +179,13 @@ buildGo123Module {
    inherit tailscale-nginx-auth;
  };

  meta = with lib; {
  meta = {
    homepage = "https://tailscale.com";
    description = "Node agent for Tailscale, a mesh VPN built on WireGuard";
    changelog = "https://github.com/tailscale/tailscale/releases/tag/v${version}";
    license = licenses.bsd3;
    license = lib.licenses.bsd3;
    mainProgram = "tailscale";
    maintainers = with maintainers; [
    maintainers = with lib.maintainers; [
      mbaillie
      jk
      mfrw