about summary refs log tree commit diff
path: root/pkgs/by-name
diff options
context:
space:
mode:
authorfigsoda <figsoda@pm.me>2023-09-17 15:11:05 -0400
committerfigsoda <figsoda@pm.me>2023-09-20 10:36:19 -0400
commit303d0ed896cfd5d32c64f54a35f769521f68bee7 (patch)
tree04ab7518fd7aa53747d9d23ec3f18e61fb6c0a1f /pkgs/by-name
parent6e4a1f742666aa5b11093672ad5756fd6b804d40 (diff)
static-server: init at 1.2.1
https://github.com/eliben/static-server
Diffstat (limited to 'pkgs/by-name')
-rw-r--r--pkgs/by-name/st/static-server/package.nix56
-rw-r--r--pkgs/by-name/st/static-server/version.patch23
2 files changed, 79 insertions, 0 deletions
diff --git a/pkgs/by-name/st/static-server/package.nix b/pkgs/by-name/st/static-server/package.nix
new file mode 100644
index 0000000000000..3a5f0748f9687
--- /dev/null
+++ b/pkgs/by-name/st/static-server/package.nix
@@ -0,0 +1,56 @@
+{ lib
+, buildGo121Module
+, fetchFromGitHub
+, curl
+, stdenv
+, testers
+, static-server
+, substituteAll
+}:
+
+buildGo121Module rec {
+  pname = "static-server";
+  version = "1.2.1";
+
+  src = fetchFromGitHub {
+    owner = "eliben";
+    repo = "static-server";
+    rev = "v${version}";
+    hash = "sha256-AZcNh/kF6IdAceA7qe+nhRlwU4yGh19av/S1Zt7iKIs=";
+  };
+
+  vendorHash = "sha256-1p3dCLLo+MTPxf/Y3zjxTagUi+tq7nZSj4ZB/aakJGY=";
+
+  patches = [
+    # patch out debug.ReadBuidlInfo since version information is not available with buildGoModule
+    (substituteAll {
+      src = ./version.patch;
+      inherit version;
+    })
+  ];
+
+  nativeCheckInputs = [
+    curl
+  ];
+
+  ldflags = [ "-s" "-w" ];
+
+  # tests sometimes fail with SIGQUIT on darwin
+  doCheck = !stdenv.isDarwin;
+
+  passthru.tests = {
+    version = testers.testVersion {
+      package = static-server;
+    };
+  };
+
+  __darwinAllowLocalNetworking = true;
+
+  meta = with lib; {
+    description = "A simple, zero-configuration HTTP server CLI for serving static files";
+    homepage = "https://github.com/eliben/static-server";
+    license = licenses.unlicense;
+    maintainers = with maintainers; [ figsoda ];
+    mainProgram = "static-server";
+  };
+}
diff --git a/pkgs/by-name/st/static-server/version.patch b/pkgs/by-name/st/static-server/version.patch
new file mode 100644
index 0000000000000..c92d7e482ed49
--- /dev/null
+++ b/pkgs/by-name/st/static-server/version.patch
@@ -0,0 +1,23 @@
+--- a/internal/server/server.go
++++ b/internal/server/server.go
+@@ -15,7 +15,6 @@ import (
+ 	"net"
+ 	"net/http"
+ 	"os"
+-	"runtime/debug"
+ 	"strings"
+ )
+ 
+@@ -50,11 +49,7 @@ func Main() int {
+ 	flags.Parse(os.Args[1:])
+ 
+ 	if *versionFlag {
+-		if buildInfo, ok := debug.ReadBuildInfo(); ok {
+-			fmt.Printf("%v %v\n", programName, buildInfo.Main.Version)
+-		} else {
+-			errorLog.Printf("version info unavailable! run 'go version -m %v'", programName)
+-		}
++		fmt.Printf("%v %v\n", programName, "@version@")
+ 		os.Exit(0)
+ 	}
+