diff options
author | figsoda <figsoda@pm.me> | 2023-09-21 10:21:14 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-21 10:21:14 -0400 |
commit | c68510839b08a5b06222d81262ce4b5505d711ff (patch) | |
tree | 0d4f35c012f21f3466276eb77209164272d49901 /pkgs | |
parent | 44479f34e6e40e971f98d543b1c7346ffdcad3e3 (diff) | |
parent | 303d0ed896cfd5d32c64f54a35f769521f68bee7 (diff) |
Merge pull request #255737 from figsoda/static
static-server: init at 1.2.1
Diffstat (limited to 'pkgs')
-rw-r--r-- | pkgs/by-name/st/static-server/package.nix | 56 | ||||
-rw-r--r-- | pkgs/by-name/st/static-server/version.patch | 23 |
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) + } + |