parent
6e4a1f7426
commit
303d0ed896
2 changed files with 79 additions and 0 deletions
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