From 51f52dc3f9f270e8a4a4b671d82f6e33a30c7a7e Mon Sep 17 00:00:00 2001 From: Gabriel Arazas Date: Wed, 28 Feb 2024 18:45:37 +0800 Subject: [PATCH] home-manager/files/mutable-files: properly group fetch subscripts --- modules/home-manager/files/mutable-files.nix | 23 ++++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/modules/home-manager/files/mutable-files.nix b/modules/home-manager/files/mutable-files.nix index cf86f7ed..a4d0a399 100644 --- a/modules/home-manager/files/mutable-files.nix +++ b/modules/home-manager/files/mutable-files.nix @@ -35,13 +35,7 @@ let [ -e ${path} ] || gopass clone ${extraArgs} ${url} --path ${path} ${extraArgs} ''; custom = '' - # Allow the extra arguments to make use of the URL and path thru - # variables. - ( - url=${url} - path=${path} - [ -e ${path} ] || ${extraArgs} - ) + [ -e ${path} ] || ${extraArgs} ''; }; @@ -169,8 +163,19 @@ in ExecStart = let mutableFilesCmds = lib.mapAttrsToList - (path: value: - (fetchScript path value).${value.type}) + (path: value: let + url = lib.escapeShellArg value.url; + path = lib.escapeShellArg value.path; + in + '' + ( + URL=${url} + PATH=${path} + DIRNAME=$(dirname ${path}) + mkdir -p "$DIRNAME" + ${(fetchScript path value).${value.type}} + ) + '') cfg; script = pkgs.writeShellApplication {