diff --git a/pkgs/by-name/st/static-web-server/include-unix-time-plus-one.diff b/pkgs/by-name/st/static-web-server/include-unix-time-plus-one.diff new file mode 100644 index 000000000000..a99c2081f51b --- /dev/null +++ b/pkgs/by-name/st/static-web-server/include-unix-time-plus-one.diff @@ -0,0 +1,13 @@ +diff --git a/src/response.rs b/src/response.rs +index 25da3d3..92d6203 100644 +--- a/src/response.rs ++++ b/src/response.rs +@@ -42,7 +42,7 @@ pub(crate) fn response_body( + let modified = meta + .modified() + .ok() +- .filter(|&t| t != std::time::UNIX_EPOCH) ++ .filter(|&t| t > (std::time::UNIX_EPOCH + std::time::Duration::from_secs(1))) + .map(LastModified::from); + + match conditionals.check(modified) { diff --git a/pkgs/by-name/st/static-web-server/package.nix b/pkgs/by-name/st/static-web-server/package.nix index bfee7235287f..4a8b8b9a60ad 100644 --- a/pkgs/by-name/st/static-web-server/package.nix +++ b/pkgs/by-name/st/static-web-server/package.nix @@ -18,9 +18,14 @@ rustPlatform.buildRustPackage (finalAttrs: { cargoHash = "sha256-rNrGlgUvPezX7RnKhprRjl9DiJ/Crt4phmxnfY9tNXA="; - # Some tests rely on timestamps newer than 18 Nov 1974 00:00:00 - preCheck = '' - find docker/public -exec touch -m {} \; + # static-web-server already has special handling for files with modification + # time = unix epoch, but the nix store is unix epoch + 1 second. + patches = [ ./include-unix-time-plus-one.diff ]; + + # Some tests which implicitly relied on the above behavior now break. Force + # an mtime update to fix. + postUnpack = '' + find . -exec touch -m {} + ''; # Need to copy in the systemd units for systemd.packages to discover them