add nix package and installation docs
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -27,6 +27,9 @@ Thumbs.db
|
||||
# go
|
||||
vendor/
|
||||
|
||||
# nix
|
||||
result
|
||||
|
||||
# misc
|
||||
*.log
|
||||
*.tmp
|
||||
|
||||
30
README.md
30
README.md
@@ -4,10 +4,40 @@ a friendlier `ss` / `netstat` for humans. inspect network connections with a cle
|
||||
|
||||
## install
|
||||
|
||||
### go
|
||||
|
||||
```bash
|
||||
go install github.com/karol-broda/snitch@latest
|
||||
```
|
||||
|
||||
### nixos / nix
|
||||
|
||||
```bash
|
||||
# try it
|
||||
nix run github:karol-broda/snitch
|
||||
|
||||
# install to profile
|
||||
nix profile install github:karol-broda/snitch
|
||||
|
||||
# or add to flake inputs
|
||||
{
|
||||
inputs.snitch.url = "github:karol-broda/snitch";
|
||||
}
|
||||
# then use: inputs.snitch.packages.${system}.default
|
||||
```
|
||||
|
||||
### binary
|
||||
|
||||
download from [releases](https://github.com/karol-broda/snitch/releases):
|
||||
|
||||
```bash
|
||||
# amd64
|
||||
curl -L https://github.com/karol-broda/snitch/releases/latest/download/snitch_linux_amd64.tar.gz | tar xz
|
||||
sudo mv snitch /usr/local/bin/
|
||||
|
||||
# or install .deb/.rpm/.apk from releases
|
||||
```
|
||||
|
||||
## quick start
|
||||
|
||||
```bash
|
||||
|
||||
6
flake.lock
generated
6
flake.lock
generated
@@ -2,11 +2,11 @@
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1756217674,
|
||||
"narHash": "sha256-TH1SfSP523QI7kcPiNtMAEuwZR3Jdz0MCDXPs7TS8uo=",
|
||||
"lastModified": 1765687488,
|
||||
"narHash": "sha256-7YAJ6xgBAQ/Nr+7MI13Tui1ULflgAdKh63m1tfYV7+M=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "4e7667a90c167f7a81d906e5a75cba4ad8bee620",
|
||||
"rev": "d02bcc33948ca19b0aaa0213fe987ceec1f4ebe1",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
||||
83
flake.nix
83
flake.nix
@@ -1,5 +1,5 @@
|
||||
{
|
||||
description = "go 1.25.0 dev flake";
|
||||
description = "snitch - a friendlier ss/netstat for humans";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
|
||||
@@ -10,44 +10,29 @@
|
||||
let
|
||||
supportedSystems = import systems;
|
||||
forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: f system);
|
||||
in
|
||||
{
|
||||
overlays.default = final: prev:
|
||||
|
||||
# go 1.25 overlay (required until nixpkgs has it)
|
||||
goOverlay = final: prev:
|
||||
let
|
||||
version = "1.25.0";
|
||||
|
||||
platformInfo = {
|
||||
"x86_64-linux" = { suffix = "linux-amd64"; sri = "sha256-KFKvDLIKExObNEiZLmm4aOUO0Pih5ZQO4d6eGaEjthM="; };
|
||||
"aarch64-linux" = { suffix = "linux-arm64"; sri = "sha256-Bd511plKJ4NpmBXuVTvVqTJ9i3mZHeNuOLZoYngvVK4="; };
|
||||
"i686-linux" = { suffix = "linux-386"; sri = "sha256-jGAt2dmbyUU7OZXSDOS684LMUIVZAKDs5d6ZKd9KmTo="; };
|
||||
"armv6l-linux" = { suffix = "linux-armv6l"; sri = "sha256-paj4GY/PAOHkhbjs757gIHeL8ypAik6Iczcb/ORYzQk="; };
|
||||
|
||||
"x86_64-darwin" = { suffix = "darwin-amd64"; sri = "sha256-W9YOgjA3BiwjB8cegRGAmGURZxTW9rQQWXz1B139gO8="; };
|
||||
"aarch64-darwin" = { suffix = "darwin-arm64"; sri = "sha256-VEkyhEFW2Bcveij3fyrJwVojBGaYtiQ/YzsKCwDAdJw="; };
|
||||
};
|
||||
|
||||
hostSystem = prev.stdenv.hostPlatform.system;
|
||||
|
||||
chosen =
|
||||
if prev.lib.hasAttr hostSystem platformInfo then platformInfo.${hostSystem}
|
||||
else
|
||||
throw ''
|
||||
unsupported system: ${hostSystem}
|
||||
add a mapping for your platform using the upstream tarball + sri sha256
|
||||
'';
|
||||
chosen = platformInfo.${hostSystem} or (throw "unsupported system: ${hostSystem}");
|
||||
in
|
||||
{
|
||||
go_1_25_bin = prev.stdenvNoCC.mkDerivation {
|
||||
go_1_25 = prev.stdenvNoCC.mkDerivation {
|
||||
pname = "go";
|
||||
version = version;
|
||||
|
||||
inherit version;
|
||||
src = prev.fetchurl {
|
||||
url = "https://go.dev/dl/go${version}.${chosen.suffix}.tar.gz";
|
||||
hash = chosen.sri;
|
||||
};
|
||||
|
||||
dontBuild = true;
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
mkdir -p "$out"/{bin,share}
|
||||
@@ -57,35 +42,57 @@
|
||||
ln -s "$out/share/go/bin/gofmt" "$out/bin/gofmt"
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
dontPatchELF = true;
|
||||
dontStrip = true;
|
||||
|
||||
meta = with prev.lib; {
|
||||
description = "go compiler and tools v${version}";
|
||||
homepage = "https://go.dev/dl/";
|
||||
license = licenses.bsd3;
|
||||
platforms = [ hostSystem ];
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
overlays.default = final: prev: {
|
||||
snitch = final.callPackage ./nix/package.nix { };
|
||||
};
|
||||
|
||||
packages = forAllSystems (system:
|
||||
let pkgs = import nixpkgs { inherit system; overlays = [ self.overlays.default ]; };
|
||||
in {
|
||||
default = pkgs.go_1_25_bin;
|
||||
go_1_25_bin = pkgs.go_1_25_bin;
|
||||
let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [ goOverlay ];
|
||||
};
|
||||
in
|
||||
{
|
||||
default = pkgs.buildGoModule {
|
||||
pname = "snitch";
|
||||
version = self.shortRev or self.dirtyShortRev or "dev";
|
||||
src = self;
|
||||
vendorHash = "sha256-BNNbA72puV0QSLkAlgn/buJJt7mIlVkbTEBhTXOg8pY=";
|
||||
env.CGO_ENABLED = 0;
|
||||
ldflags = [
|
||||
"-s" "-w"
|
||||
"-X snitch/cmd.version=${self.shortRev or "dev"}"
|
||||
"-X snitch/cmd.commit=${self.shortRev or "unknown"}"
|
||||
];
|
||||
meta = with pkgs.lib; {
|
||||
description = "a friendlier ss/netstat for humans";
|
||||
homepage = "https://github.com/karol-broda/snitch";
|
||||
license = licenses.mit;
|
||||
platforms = platforms.linux;
|
||||
mainProgram = "snitch";
|
||||
};
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
devShells = forAllSystems (system:
|
||||
let pkgs = import nixpkgs { inherit system; overlays = [ self.overlays.default ]; };
|
||||
in {
|
||||
let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [ goOverlay ];
|
||||
};
|
||||
in
|
||||
{
|
||||
default = pkgs.mkShell {
|
||||
packages = [ pkgs.go_1_25_bin pkgs.git ];
|
||||
|
||||
packages = [ pkgs.go_1_25 pkgs.git ];
|
||||
GOTOOLCHAIN = "local";
|
||||
|
||||
shellHook = ''
|
||||
echo "go toolchain: $(go version)"
|
||||
'';
|
||||
|
||||
Reference in New Issue
Block a user