From 65817f4e7022667e0049a7c276b7e379cb4efa76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geoffrey=20=E2=80=9CFrogeye=E2=80=9D=20Preud=27homme?= Date: Mon, 19 May 2025 21:48:44 +0200 Subject: [PATCH] Do not sync direnv It will only add the the cache to gcroots on the first computer that built it, so everyone else has to re-fetch it. --- hm/shell/direnv.nix | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/hm/shell/direnv.nix b/hm/shell/direnv.nix index bf6c87d..6fb2922 100644 --- a/hm/shell/direnv.nix +++ b/hm/shell/direnv.nix @@ -1,5 +1,8 @@ # Allow switching to a specific environment when going into a directory { + config, + lib, + pkgs, ... }: { @@ -11,7 +14,46 @@ enableZshIntegration = true; nix-direnv.enable = true; }; - git.ignores = [ ".envrc" ".direnv" ]; + git.ignores = [ + ".envrc" + ".direnv" + ]; + }; + systemd.user.services.direnv_ignore = { + Service = { + Type = "oneshot"; + ExecStart = lib.getExe ( + pkgs.writeShellApplication { + name = "direnv_ignore"; + text = + '' + ignore_direnv() { + dir="$1" + if [ ! -f "$dir/.stignore" ] + then + touch "$dir/.stignore" + fi + rule="**/.direnv" + if ! grep -qFx "$rule" "$dir/.stignore" + then + echo "$rule" >> "$dir/.stignore" + fi + } + '' + + (lib.trivial.pipe config.frogeye.folders [ + builtins.attrValues + (builtins.filter (folder: folder.syncthing.enable)) + (builtins.map (folder: '' + ignore_direnv ${lib.strings.escapeShellArg folder.fullPath} + '')) + lib.strings.concatLines + ]); + } + ); + }; + Install = { + WantedBy = [ "default.target" ]; + }; }; }; }