summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfigsoda <figsoda@pm.me>2023-09-21 10:21:14 -0400
committerGitHub <noreply@github.com>2023-09-21 10:21:14 -0400
commitc68510839b08a5b06222d81262ce4b5505d711ff (patch)
tree0d4f35c012f21f3466276eb77209164272d49901
parentMerge pull request #256494 from adamcstephens/lxd/5.18 (diff)
parentstatic-server: init at 1.2.1 (diff)
downloadnixpkgs-c68510839b08a5b06222d81262ce4b5505d711ff.tar.gz
Merge pull request #255737 from figsoda/static
static-server: init at 1.2.1
-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 000000000000..3a5f0748f968
--- /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 000000000000..c92d7e482ed4
--- /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)
+ }
+