1{ lib, rustPlatform, fetchFromGitHub, stdenv, darwin, nixosTests }:
2
3rustPlatform.buildRustPackage rec {
4 pname = "static-web-server";
5 version = "2.22.1";
6
7 src = fetchFromGitHub {
8 owner = "static-web-server";
9 repo = pname;
10 rev = "v${version}";
11 hash = "sha256-RrwAT+la07A8PQhmUWmV4qrYha6GUFKMRx7jkVegPb8=";
12 };
13
14 cargoHash = "sha256-YOBo2ey83QN26+9cUvoA1QWEPI3oTpwIJoqcPaWvovA=";
15
16 buildInputs = lib.optionals stdenv.isDarwin [
17 darwin.apple_sdk.frameworks.Security
18 ];
19
20 checkFlags = [
21 # TODO: investigate why these tests fail
22 "--skip=tests::handle_byte_ranges_if_range_too_old"
23 "--skip=tests::handle_not_modified"
24 "--skip=handle_precondition"
25 ];
26
27 # Need to copy in the systemd units for systemd.packages to discover them
28 postInstall = ''
29 install -Dm444 -t $out/lib/systemd/system/ systemd/static-web-server.{service,socket}
30 '';
31
32 passthru.tests = { inherit (nixosTests) static-web-server; };
33
34 meta = with lib; {
35 description = "An asynchronous web server for static files-serving";
36 homepage = "https://static-web-server.net/";
37 changelog = "https://github.com/static-web-server/static-web-server/blob/v${version}/CHANGELOG.md";
38 license = with licenses; [ mit /* or */ asl20 ];
39 maintainers = with maintainers; [ figsoda ];
40 };
41}