From e64319616f9d1f13ebeb2fba51457f409a02359b Mon Sep 17 00:00:00 2001 From: tux Date: Thu, 27 Feb 2025 17:01:50 +0530 Subject: [PATCH] feat: setup flake --- default.nix | 17 +++++++++++++++++ flake.lock | 27 +++++++++++++++++++++++++++ flake.nix | 27 +++++++++++++++++++++++++++ result | 1 + shell.nix | 13 +++++++++++++ 5 files changed, 85 insertions(+) create mode 100644 default.nix create mode 100644 flake.lock create mode 100644 flake.nix create mode 120000 result create mode 100644 shell.nix diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..b0c4737 --- /dev/null +++ b/default.nix @@ -0,0 +1,17 @@ +{ + lib, + buildGoModule, +}: +buildGoModule { + pname = "trok"; + version = "0.1.0"; + + src = ./.; + vendorHash = "sha256-P7UBLLMMOwCeiM7aAY6A8cyXqxwn7mDTNS2kJTALHPU="; + + meta = { + license = lib.licenses.mit; + maintainers = with lib.maintainers; [tuxdotrs]; + mainProgram = "trok"; + }; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..e604777 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1740547748, + "narHash": "sha256-Ly2fBL1LscV+KyCqPRufUBuiw+zmWrlJzpWOWbahplg=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "3a05eebede89661660945da1f151959900903b6a", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-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..c44f4fa --- /dev/null +++ b/flake.nix @@ -0,0 +1,27 @@ +{ + description = "Simple tunneler in Go that exposes local ports to the internet"; + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + + outputs = { + self, + nixpkgs, + }: let + systems = [ + "x86_64-linux" + "aarch64-linux" + "x86_64-darwin" + "aarch64-darwin" + ]; + + forAllSystems = function: nixpkgs.lib.genAttrs systems (system: function nixpkgs.legacyPackages.${system}); + in { + packages = forAllSystems (pkgs: rec { + default = trok; + trok = pkgs.callPackage ./default.nix {}; + }); + + devShells = forAllSystems (pkgs: { + default = pkgs.callPackage ./shell.nix {}; + }); + }; +} diff --git a/result b/result new file mode 120000 index 0000000..d123e5e --- /dev/null +++ b/result @@ -0,0 +1 @@ +/nix/store/gn03pkmsyjvqxb44vmb0m2anjlvgvp1c-trok-0.1.0 \ No newline at end of file diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..39ec4ab --- /dev/null +++ b/shell.nix @@ -0,0 +1,13 @@ +{ + callPackage, + go, +}: let + mainPkg = callPackage ./default.nix {}; +in + mainPkg.overrideAttrs (oa: { + nativeBuildInputs = + [ + go + ] + ++ (oa.nativeBuildInputs or []); + })