From 9103ac269ec04a99045c75bbf3dca7e57d1606c0 Mon Sep 17 00:00:00 2001 From: BenZuckier Date: Wed, 11 Mar 2026 09:45:51 -0400 Subject: [PATCH] static-web-server: handle files from nix store epoch+1 files served from the nix store have time of epoch+1 and static-web-server assumes they're old unchanged files and doesn't send partial updates or refresh the file when it changes. It already has special handling for files with the unix epoch, but the nix store time is epoch+1s; add that special case. --- .../include-unix-time-plus-one.diff | 13 +++++++++++++ pkgs/by-name/st/static-web-server/package.nix | 11 ++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 pkgs/by-name/st/static-web-server/include-unix-time-plus-one.diff 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 da749e0757ca..7b08734fbdf2 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 rec { 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