1
0
forked from extern/nix-config

overlays: Patch zola serve fix for config.toml changes

This commit is contained in:
Donovan Glover 2023-09-13 10:36:00 -04:00
parent 3a6c2f44ed
commit 281664b6d8
No known key found for this signature in database
GPG Key ID: EA7408A77AE1BE65
3 changed files with 54 additions and 0 deletions

View File

@ -2,5 +2,6 @@
imports = [ imports = [
./alejandra.nix ./alejandra.nix
./hyprland.nix ./hyprland.nix
./zola.nix
]; ];
} }

9
overlays/zola.nix Normal file
View File

@ -0,0 +1,9 @@
{
nixpkgs.overlays = [
(final: prev: {
zola = prev.zola.overrideAttrs (oldAttrs: {
patches = (oldAttrs.patches or [ ]) ++ [ ../patches/zola-serve-fix.patch ];
});
})
];
}

View File

@ -0,0 +1,44 @@
From d9d41a0d919d90008e4c0db31cc86786ca502aa1 Mon Sep 17 00:00:00 2001
From: Andrew Langmeier <raymi306@gmail.com>
Date: Sun, 13 Aug 2023 17:34:32 +0000
Subject: [PATCH] Add fix for detecting changes on files by editors which
replace files on save, such as vi
---
src/cmd/serve.rs | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/src/cmd/serve.rs b/src/cmd/serve.rs
index 46e8d9345..35fd85f1f 100644
--- a/src/cmd/serve.rs
+++ b/src/cmd/serve.rs
@@ -653,6 +653,29 @@ pub fn serve(
};
messages::report_elapsed_time(start);
}
+ NoticeRemove(path) => {
+ // Some editors, like those in the vi family, replace the file you're
+ // working on with a copy, breaking the watcher.
+ //
+ // See https://github.com/notify-rs/notify/issues/247
+ //
+ // If we need to watch other single required files, should handle them
+ // here. For now, just config.toml needs special handling
+ match detect_change_kind(root_dir, &path, &config_path) {
+ (ChangeKind::Config, _) => {
+ console::info("-> Config changed. The browser needs to be refreshed to make the changes visible.");
+
+ if let Some(s) = recreate_site() {
+ site = s;
+ }
+ let entry = config_path_rel.to_str().unwrap_or("config.toml");
+ watcher
+ .watch(root_dir.join(entry), RecursiveMode::Recursive)
+ .with_context(|| format!("Can't watch `{}` for changes in folder `{}`. Does it exist, and do you have correct permissions?", entry, root_dir.display()))?;
+ }
+ _ => {}
+ }
+ }
_ => {}
}
}