Open antoineco opened 4 hours ago
I forgot to mention that the location of direnv
in the PATH does not change. It is the target of the symlink which changes:
% echo "${commands[direnv]}"
/etc/profiles/per-user/acotten/bin/direnv
% ls -l "${commands[direnv]}"
lrwxrwxrwx 1 root root 68 Jan 1 1970 /etc/profiles/per-user/acotten/bin/direnv -> /nix/store/3lv7pgadn5b587s69y23lpj90170q0n5-direnv-2.35.0/bin/direnv
It seems like the 0 timestamps used across the Nix store are tripping the current -nt
conditional expression:
https://github.com/zimfw/direnv/blob/8d395e563315b0193f375f2a83d27d93b249a5ea/init.zsh#L5
% stat /nix/store/3lv7pgadn5b587s69y23lpj90170q0n5-direnv-2.35.0/bin/direnv
File: /nix/store/3lv7pgadn5b587s69y23lpj90170q0n5-direnv-2.35.0/bin/direnv
Size: 8284784 Blocks: 16184 IO Block: 4096 regular file
Device: 8,32 Inode: 2533042 Links: 1
Access: (0555/-r-xr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2024-11-16 11:05:11.000000000 +0000
Modify: 1970-01-01 00:00:01.000000000 +0000
Change: 2024-11-16 11:05:11.396581001 +0000
Birth: 2024-11-16 11:05:11.077581001 +0000
This makes me wonder whether this issue can actually be addressed when using Nix.
Prerequisites
Bug description
The current logic generates
direnv-hook-zsh.zsh
once, which does not take possible relocations of thedirenv
executable into account.Steps to reproduce
zmodule direnv
to zimrcMy particular scenario is a
direnv
program installed via the Nix package manager usingnix profile install 'nixpkgs#direnv'
(or declarative equivalent on NixOS). Upon updating the program, its location changes inside the Nix store, and Zim's cached hook file no longer matches the current output ofdirenv hook zsh
:Current behavior
direnv-hook-zsh.zsh
is never updated despite thedirenv
executable being a newer version installed at a different location on the filesystem.Expected behavior
direnv-hook-zsh.zsh
is updated along withdirenv
when necessary, e.g. when the location of the currentdirenv
no longer matches the one in the cached hook file).zimfw info
Additional context
No response