Olical / aniseed

Neovim configuration and plugins in Fennel (Lisp compiled to Lua)
https://discord.gg/wXAMr8F
The Unlicense
606 stars 28 forks source link

File modification check breaks when Nix manages .fnl files #82

Closed mixedCase closed 2 years ago

mixedCase commented 2 years ago

I keep my entire Neovim config managed by Nix. Right now, it seems that in order to recompile a file Aniseed checks its timestamp instead of whether the actual contents have changed (via integrity checks). Files managed in the Nix store have their timestamps set at zero to help with reproducibility, meaning that my .fnl files never get recompiled.

Could this behavior be changed, or at least a flag be introduced to use an integrity check to determine whether a change has occurred? If it helps, the Lua files could contain the checksum of its original source in a comment.

Alternatively if there's a way to compile my Fennel files to Lua with Nix when building instead of using Aniseed I'd love to know it!

Olical commented 2 years ago

Ah interesting! Thank you for raising this, I've seen a few people run into Nix issues recently. I actually use NixOS myself but have never managed my dotfiles with it since it seems like too much hassle 😬

So we'd definitely need some kind of metadata which complicates things, I liked just relying on the filesystem metadata, it felt pretty elegant and efficient.

As an interim step you can call compile.glob directly when you make changes to your configuration... this may actually be the best solution for you! So every time you change your config you can do something like this: (I'll use Lua so you can script it / pass it as an arg easily)

require("aniseed.compile").glob("**/*.fnl", "~/.config/nvim/fnl",  "~/.config/nvim/lua", {})

I'm not sure if you have to expand the tilde or not... but that's minor. The important part is after all of Aniseed's checks to try and avoid compiling, that's essentially all it executes after it works out something has changed and something needs recompiling.

So, I could add another option to allow you to force compiling through the aniseed.env module but I think this will be better for you. You can invoke nvim and tell it to run that Lua at the CLI I think whenever you sync your Nix based config?

Then aniseed.env will load up and not compile (you can set {compile = false} as the env opts to short circuit that check efficiently without touching the fs) but it will load your config.

Soooo if this fits your workflow well, maybe this should be the recommended approach for Nix folks, if not I can look deeper into storing metadata etc, I'd just like to avoid it if possible. So far I've avoided storing anything other than the raw files and their metadata, if I can keep it that way that'd be great, less state is less problems.

Olical commented 2 years ago

Going to close this for now hoping that my previous suggestion is enough to keep people going in Nix land. Maybe I can work something out eventually, it just seems hard to do just for this NixOS based usage