Merge pull request #255737 from figsoda/static
static-server: init at 1.2.1
This commit is contained in:
commit
c68510839b
56
pkgs/by-name/st/static-server/package.nix
Normal file
56
pkgs/by-name/st/static-server/package.nix
Normal file
|
@ -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";
|
||||
};
|
||||
}
|
23
pkgs/by-name/st/static-server/version.patch
Normal file
23
pkgs/by-name/st/static-server/version.patch
Normal file
|
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in a new issue