mirror of
https://github.com/aykhans/sarin.git
synced 2026-10-17 14:53:52 +00:00
feat: add nix flake packaging
This commit is contained in:
5 files changed
+172
-4
No files matched your search
@@ -1 +1,5 @@
|
|||||||
bin/*
|
bin/*
|
||||||
|
|
||||||
|
# Nix build artifacts
|
||||||
|
result
|
||||||
|
result-*
|
||||||
@@ -36,10 +36,11 @@ Sarin is designed for efficient HTTP load testing with minimal resource consumpt
|
|||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
### Docker (Recommended)
|
<details open>
|
||||||
|
<summary><b>Docker</b></summary>
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
docker pull aykhans/sarin:latest
|
docker run -it aykhans/sarin:latest --version
|
||||||
```
|
```
|
||||||
|
|
||||||
With a local config file:
|
With a local config file:
|
||||||
@@ -54,11 +55,46 @@ With a remote config file:
|
|||||||
docker run --rm -it aykhans/sarin -f https://example.com/config.yaml
|
docker run --rm -it aykhans/sarin -f https://example.com/config.yaml
|
||||||
```
|
```
|
||||||
|
|
||||||
### Pre-built Binaries
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary><b>Nix</b></summary>
|
||||||
|
|
||||||
|
Run directly without installing (requires flakes enabled):
|
||||||
|
|
||||||
|
```sh
|
||||||
|
nix run github:aykhans/sarin/v1.3.2 -- -U http://example.com -r 100 -c 10
|
||||||
|
```
|
||||||
|
|
||||||
|
Install into your profile:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
nix profile install github:aykhans/sarin/v1.3.2
|
||||||
|
```
|
||||||
|
|
||||||
|
Or add it to your own flake via the overlay:
|
||||||
|
|
||||||
|
```nix
|
||||||
|
{
|
||||||
|
inputs.sarin.url = "github:aykhans/sarin/v1.3.2";
|
||||||
|
|
||||||
|
# In your outputs, apply the overlay to nixpkgs:
|
||||||
|
# nixpkgs.overlays = [ inputs.sarin.overlays.default ];
|
||||||
|
# then reference pkgs.sarin
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary><b>Pre-built Binaries</b></summary>
|
||||||
|
|
||||||
Download the latest binaries from the [releases](https://github.com/aykhans/sarin/releases) page.
|
Download the latest binaries from the [releases](https://github.com/aykhans/sarin/releases) page.
|
||||||
|
|
||||||
### Building from Source
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary><b>Building from Source</b></summary>
|
||||||
|
|
||||||
Requires [Go 1.26+](https://golang.org/dl/).
|
Requires [Go 1.26+](https://golang.org/dl/).
|
||||||
|
|
||||||
@@ -74,6 +110,8 @@ CGO_ENABLED=0 go build \
|
|||||||
-o sarin ./cmd/cli/main.go
|
-o sarin ./cmd/cli/main.go
|
||||||
```
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
## Quick Start
|
## Quick Start
|
||||||
|
|
||||||
Send 10,000 GET requests with 50 concurrent connections and a random User-Agent for each request:
|
Send 10,000 GET requests with 50 concurrent connections and a random User-Agent for each request:
|
||||||
|
|||||||
Generated
+27
@@ -0,0 +1,27 @@
|
|||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1784796856,
|
||||||
|
"narHash": "sha256-wWFrV5/Qbm+lyt5x20E/bSbfJiGKMo4RCxZV8cl/WZI=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "e2587caef70cea85dd97d7daab492899902dbf5d",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixos-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": "nixpkgs"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
{
|
||||||
|
description = "Sarin - high-performance HTTP load testing tool built with Go and fasthttp";
|
||||||
|
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = { self, nixpkgs }:
|
||||||
|
let
|
||||||
|
inherit (nixpkgs) lib;
|
||||||
|
|
||||||
|
systems = [
|
||||||
|
"x86_64-linux"
|
||||||
|
"aarch64-linux"
|
||||||
|
"x86_64-darwin"
|
||||||
|
"aarch64-darwin"
|
||||||
|
];
|
||||||
|
|
||||||
|
forAllSystems = f: lib.genAttrs systems (system: f nixpkgs.legacyPackages.${system});
|
||||||
|
|
||||||
|
rev = self.rev or self.dirtyRev or "unknown";
|
||||||
|
|
||||||
|
# self.lastModifiedDate is "YYYYMMDDHHMMSS"; reshape to RFC 3339 (UTC).
|
||||||
|
raw = self.lastModifiedDate or "19700101000000";
|
||||||
|
s = i: n: lib.substring i n raw;
|
||||||
|
buildDate = "${s 0 4}-${s 4 2}-${s 6 2}T${s 8 2}:${s 10 2}:${s 12 2}Z";
|
||||||
|
in
|
||||||
|
{
|
||||||
|
packages = forAllSystems (pkgs: {
|
||||||
|
default = pkgs.callPackage ./nix/package.nix {
|
||||||
|
inherit rev buildDate;
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
# nix run github:aykhans/sarin -- <args>
|
||||||
|
apps = forAllSystems (pkgs: {
|
||||||
|
default = {
|
||||||
|
type = "app";
|
||||||
|
program = "${self.packages.${pkgs.system}.default}/bin/sarin";
|
||||||
|
meta.description = "High-performance HTTP load testing tool";
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
devShells = forAllSystems (pkgs: {
|
||||||
|
default = pkgs.mkShell {
|
||||||
|
packages = [ pkgs.go_1_26 pkgs.golangci-lint pkgs.go-task ];
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
# For downstream flakes: inputs.sarin.overlays.default
|
||||||
|
overlays.default = final: _prev: {
|
||||||
|
sarin = final.callPackage ./nix/package.nix { };
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
{ lib
|
||||||
|
, stdenv
|
||||||
|
, buildGoModule
|
||||||
|
, go_1_26
|
||||||
|
, rev ? "unknown"
|
||||||
|
, buildDate ? "unknown"
|
||||||
|
}:
|
||||||
|
|
||||||
|
(buildGoModule.override { go = go_1_26; }) (finalAttrs: {
|
||||||
|
pname = "sarin";
|
||||||
|
version = "1.3.2"; # bump per release
|
||||||
|
|
||||||
|
src = lib.cleanSource ../.;
|
||||||
|
|
||||||
|
vendorHash = "sha256-BMH0alJeZoK/8cE9Y+s++G7D+Dg5xcZNTU4zkRMBpfU=";
|
||||||
|
|
||||||
|
subPackages = [ "cmd/cli" ];
|
||||||
|
|
||||||
|
env.CGO_ENABLED = 0; # fully static binary
|
||||||
|
|
||||||
|
ldflags = [
|
||||||
|
"-s"
|
||||||
|
"-w"
|
||||||
|
"-X=go.aykhans.me/sarin/internal/version.Version=v${finalAttrs.version}"
|
||||||
|
"-X=go.aykhans.me/sarin/internal/version.GitCommit=${rev}"
|
||||||
|
"-X=go.aykhans.me/sarin/internal/version.BuildDate=${buildDate}"
|
||||||
|
# Value has spaces, so it is single-quoted: `go build` splits -ldflags
|
||||||
|
# shell-style and honours the quotes, keeping this as one -X value.
|
||||||
|
"-X 'go.aykhans.me/sarin/internal/version.GoVersion=go version go${go_1_26.version} ${stdenv.hostPlatform.go.GOOS}/${stdenv.hostPlatform.go.GOARCH}'"
|
||||||
|
];
|
||||||
|
|
||||||
|
# cmd/cli produces a binary named "cli"; rename it to "sarin".
|
||||||
|
postInstall = ''
|
||||||
|
mv $out/bin/cli $out/bin/sarin
|
||||||
|
'';
|
||||||
|
|
||||||
|
meta = {
|
||||||
|
description = "High-performance HTTP load testing tool built with Go and fasthttp";
|
||||||
|
homepage = "https://github.com/aykhans/sarin";
|
||||||
|
license = lib.licenses.mit;
|
||||||
|
mainProgram = "sarin";
|
||||||
|
maintainers = [ ];
|
||||||
|
};
|
||||||
|
})
|
||||||
Reference in new issue
Block a user