diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..6f3c06e --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1750134718, + "narHash": "sha256-v263g4GbxXv87hMXMCpjkIxd/viIF7p3JpJrwgKdNiI=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "9e83b64f727c88a7711a2c463a7b16eedb69a84c", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..4e2187b --- /dev/null +++ b/flake.nix @@ -0,0 +1,25 @@ +{ + description = "Fast and minimal parallel TCP connection testing utility "; + inputs.nixpkgs.url = "github:NixOS/nixpkgs?ref=nixos-unstable"; + + outputs = { + self, + nixpkgs, + ... + }: let + systems = ["x86_64-linux" "aarch64-linux"]; + forEachSystem = nixpkgs.lib.genAttrs systems; + + pkgsForEach = nixpkgs.legacyPackages; + in { + packages = forEachSystem (system: { + default = pkgsForEach.${system}.callPackage ./nix/package.nix {}; + }); + + devShells = forEachSystem (system: { + default = pkgsForEach.${system}.callPackage ./nix/shell.nix {}; + }); + + hydraJobs = self.packages; + }; +} diff --git a/nix/package.nix b/nix/package.nix new file mode 100644 index 0000000..a6fc842 --- /dev/null +++ b/nix/package.nix @@ -0,0 +1,24 @@ +{ + lib, + buildGoModule, +}: let + fs = lib.fileset; + s = ../.; +in + buildGoModule { + pname = "tct"; + version = "0.1.0"; + + src = fs.toSource { + root = s; + fileset = fs.unions [ + (fs.fileFilter (file: builtins.any file.hasExt ["go"]) s) + ../go.mod + ../go.sum + ]; + }; + + vendorHash = "sha256-m5mBubfbXXqXKsygF5j7cHEY+bXhAMcXUts5KBKoLzM="; + + ldflags = ["-s" "-w"]; + } diff --git a/nix/shell.nix b/nix/shell.nix new file mode 100644 index 0000000..226ab68 --- /dev/null +++ b/nix/shell.nix @@ -0,0 +1,14 @@ +{ + mkShell, + go, + gopls, + delve, +}: +mkShell { + name = "go"; + packages = [ + delve + go + gopls + ]; +}