fix(build): go and nix builds not working properly

This commit is contained in:
Karol Broda
2025-12-23 10:01:01 +01:00
parent b2be0df2f9
commit 7fdb1ed477
20 changed files with 32 additions and 30 deletions

View File

@@ -6,7 +6,7 @@ import (
"strings" "strings"
"testing" "testing"
"snitch/internal/testutil" "github.com/karol-broda/snitch/internal/testutil"
) )
// TestCLIContract tests the CLI interface contracts as specified in the README // TestCLIContract tests the CLI interface contracts as specified in the README

View File

@@ -9,8 +9,8 @@ import (
"strings" "strings"
"testing" "testing"
"snitch/internal/collector" "github.com/karol-broda/snitch/internal/collector"
"snitch/internal/testutil" "github.com/karol-broda/snitch/internal/testutil"
) )
var updateGolden = flag.Bool("update-golden", false, "Update golden files") var updateGolden = flag.Bool("update-golden", false, "Update golden files")

View File

@@ -8,10 +8,10 @@ import (
"log" "log"
"os" "os"
"os/exec" "os/exec"
"snitch/internal/collector" "github.com/karol-broda/snitch/internal/collector"
"snitch/internal/color" "github.com/karol-broda/snitch/internal/color"
"snitch/internal/config" "github.com/karol-broda/snitch/internal/config"
"snitch/internal/resolver" "github.com/karol-broda/snitch/internal/resolver"
"strconv" "strconv"
"strings" "strings"
"text/tabwriter" "text/tabwriter"

View File

@@ -4,8 +4,8 @@ import (
"strings" "strings"
"testing" "testing"
"snitch/internal/collector" "github.com/karol-broda/snitch/internal/collector"
"snitch/internal/testutil" "github.com/karol-broda/snitch/internal/testutil"
) )
func TestLsCommand_EmptyResults(t *testing.T) { func TestLsCommand_EmptyResults(t *testing.T) {

View File

@@ -3,7 +3,7 @@ package cmd
import ( import (
"fmt" "fmt"
"os" "os"
"snitch/internal/config" "github.com/karol-broda/snitch/internal/config"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )

View File

@@ -2,8 +2,8 @@ package cmd
import ( import (
"fmt" "fmt"
"snitch/internal/collector" "github.com/karol-broda/snitch/internal/collector"
"snitch/internal/color" "github.com/karol-broda/snitch/internal/color"
"strconv" "strconv"
"strings" "strings"

View File

@@ -8,7 +8,7 @@ import (
"log" "log"
"os" "os"
"os/signal" "os/signal"
"snitch/internal/collector" "github.com/karol-broda/snitch/internal/collector"
"sort" "sort"
"strconv" "strconv"
"strings" "strings"

View File

@@ -2,8 +2,8 @@ package cmd
import ( import (
"log" "log"
"snitch/internal/config" "github.com/karol-broda/snitch/internal/config"
"snitch/internal/tui" "github.com/karol-broda/snitch/internal/tui"
"time" "time"
tea "github.com/charmbracelet/bubbletea" tea "github.com/charmbracelet/bubbletea"

View File

@@ -7,8 +7,8 @@ import (
"log" "log"
"os" "os"
"os/signal" "os/signal"
"snitch/internal/collector" "github.com/karol-broda/snitch/internal/collector"
"snitch/internal/resolver" "github.com/karol-broda/snitch/internal/resolver"
"strings" "strings"
"syscall" "syscall"
"time" "time"

View File

@@ -18,7 +18,7 @@ import (
"github.com/fatih/color" "github.com/fatih/color"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"snitch/internal/tui" "github.com/karol-broda/snitch/internal/tui"
) )
const ( const (

View File

@@ -50,13 +50,15 @@
version = "nix-${rev}"; version = "nix-${rev}";
go = mkGo125 pkgs; go = mkGo125 pkgs;
buildGoModule = pkgs.buildGoModule.override { inherit go; }; buildGoModule = pkgs.buildGoModule.override { inherit go; };
isDarwin = pkgs.stdenv.isDarwin;
in in
buildGoModule { buildGoModule {
pname = "snitch"; pname = "snitch";
inherit version; inherit version;
src = self; src = self;
vendorHash = "sha256-fX3wOqeOgjH7AuWGxPQxJ+wbhp240CW8tiF4rVUUDzk="; vendorHash = "sha256-fX3wOqeOgjH7AuWGxPQxJ+wbhp240CW8tiF4rVUUDzk=";
env.CGO_ENABLED = "0"; # darwin requires cgo for libproc, linux uses pure go with /proc
env.CGO_ENABLED = if isDarwin then "1" else "0";
env.GOTOOLCHAIN = "local"; env.GOTOOLCHAIN = "local";
ldflags = [ ldflags = [
"-s" "-s"
@@ -69,7 +71,7 @@
description = "a friendlier ss/netstat for humans"; description = "a friendlier ss/netstat for humans";
homepage = "https://github.com/karol-broda/snitch"; homepage = "https://github.com/karol-broda/snitch";
license = pkgs.lib.licenses.mit; license = pkgs.lib.licenses.mit;
platforms = pkgs.lib.platforms.linux; platforms = pkgs.lib.platforms.linux ++ pkgs.lib.platforms.darwin;
mainProgram = "snitch"; mainProgram = "snitch";
}; };
}; };

2
go.mod
View File

@@ -1,4 +1,4 @@
module snitch module github.com/karol-broda/snitch
go 1.24.0 go 1.24.0

View File

@@ -5,7 +5,7 @@ import (
"path/filepath" "path/filepath"
"testing" "testing"
"snitch/internal/collector" "github.com/karol-broda/snitch/internal/collector"
) )
// TestCollector wraps MockCollector for use in tests // TestCollector wraps MockCollector for use in tests

View File

@@ -3,7 +3,7 @@ package tui
import ( import (
"fmt" "fmt"
"regexp" "regexp"
"snitch/internal/collector" "github.com/karol-broda/snitch/internal/collector"
"strings" "strings"
) )

View File

@@ -2,7 +2,7 @@ package tui
import ( import (
"fmt" "fmt"
"snitch/internal/collector" "github.com/karol-broda/snitch/internal/collector"
"time" "time"
tea "github.com/charmbracelet/bubbletea" tea "github.com/charmbracelet/bubbletea"

View File

@@ -2,7 +2,7 @@ package tui
import ( import (
"fmt" "fmt"
"snitch/internal/collector" "github.com/karol-broda/snitch/internal/collector"
"syscall" "syscall"
"time" "time"

View File

@@ -2,8 +2,8 @@ package tui
import ( import (
"fmt" "fmt"
"snitch/internal/collector" "github.com/karol-broda/snitch/internal/collector"
"snitch/internal/theme" "github.com/karol-broda/snitch/internal/theme"
"time" "time"
tea "github.com/charmbracelet/bubbletea" tea "github.com/charmbracelet/bubbletea"

View File

@@ -1,7 +1,7 @@
package tui package tui
import ( import (
"snitch/internal/collector" "github.com/karol-broda/snitch/internal/collector"
"testing" "testing"
"time" "time"

View File

@@ -2,7 +2,7 @@ package tui
import ( import (
"fmt" "fmt"
"snitch/internal/collector" "github.com/karol-broda/snitch/internal/collector"
"strings" "strings"
"time" "time"

View File

@@ -1,7 +1,7 @@
package main package main
import ( import (
"snitch/cmd" "github.com/karol-broda/snitch/cmd"
) )
func main() { func main() {