about summary refs log tree commit diff
path: root/pkgs/by-name/fl
diff options
context:
space:
mode:
authorBryan Honof <bryanhonof@gmail.com>2024-02-20 02:32:34 +0100
committerBryan Honof <bryanhonof@gmail.com>2024-02-20 12:26:22 +0100
commit8fcb45896aeca58e9cbbc743f0290ac193ab7f65 (patch)
tree27ee34507761fcd9cc908536c8e03dd6805424f0 /pkgs/by-name/fl
parent6476f360a4c5257011a868cbf68fb826acd2a4ce (diff)
flottbot: init at 0.13.0
Co-authored-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
Diffstat (limited to 'pkgs/by-name/fl')
-rw-r--r--pkgs/by-name/fl/flottbot/package.nix44
-rw-r--r--pkgs/by-name/fl/flottbot/version.patch37
2 files changed, 81 insertions, 0 deletions
diff --git a/pkgs/by-name/fl/flottbot/package.nix b/pkgs/by-name/fl/flottbot/package.nix
new file mode 100644
index 0000000000000..43866e947c817
--- /dev/null
+++ b/pkgs/by-name/fl/flottbot/package.nix
@@ -0,0 +1,44 @@
+{ lib
+, buildGoModule
+, fetchFromGitHub
+, nix-update-script
+, substituteAll
+}:
+buildGoModule rec {
+  pname = "flottbot";
+  version = "0.13.0";
+
+  src = fetchFromGitHub {
+    owner = "target";
+    repo = "flottbot";
+    rev = version;
+    hash = "sha256-ldWE5QcLHyIqap5Qe6OTTIJZ1sshI+CVoJoRUxWHfxM=";
+  };
+
+  patches = [
+    # patch out debug.ReadBuidlInfo since version information is not available with buildGoModule
+    (substituteAll {
+      src = ./version.patch;
+      version = version;
+      vcsHash = version; # Maybe there is a way to get the git ref from src? idk.
+    })
+  ];
+
+  vendorHash = "sha256-XRcTp3ZnoPupzI1kjoM4oF5+VlNJFV0Bu+WAwfRWl7g=";
+
+  subPackages = [ "cmd/flottbot" ];
+
+  passthru = {
+    updateScript = nix-update-script { };
+  };
+
+  meta = with lib; {
+    description = "A chatbot framework written in Go";
+    homepage = "https://github.com/target/flottbot";
+    license = licenses.asl20;
+    maintainers = with maintainers; [ bryanhonof ];
+    sourceProvenance = [ sourceTypes.fromSource ];
+    mainProgram = "flottbot";
+    platforms = platforms.unix;
+  };
+}
diff --git a/pkgs/by-name/fl/flottbot/version.patch b/pkgs/by-name/fl/flottbot/version.patch
new file mode 100644
index 0000000000000..eaec6eec5fdbc
--- /dev/null
+++ b/pkgs/by-name/fl/flottbot/version.patch
@@ -0,0 +1,37 @@
+diff --git a/version/version.go b/version/version.go
+index 9ca8aba..d9bd968 100644
+--- a/version/version.go
++++ b/version/version.go
+@@ -4,9 +4,6 @@ package version
+ 
+ import (
+ 	"fmt"
+-	"runtime/debug"
+-
+-	"github.com/Masterminds/semver/v3"
+ )
+ 
+ // Version supplies the semantic version.
+@@ -14,20 +11,8 @@ var Version string
+ 
+ // String prints the build information for the bot.
+ func String() string {
+-	hash := "unknown"
+-
+-	_, err := semver.NewVersion(Version)
+-	if err != nil {
+-		Version = "dev"
+-	}
+-
+-	if info, ok := debug.ReadBuildInfo(); ok {
+-		for _, s := range info.Settings {
+-			if s.Key == "vcs.revision" {
+-				hash = s.Value
+-			}
+-		}
+-	}
++	Version = "@version@"
++	hash := "@vcsHash@"
+ 
+ 	return fmt.Sprintf("Version : %s\nGit Hash: %s\n", Version, hash)
+ }