home-manager/files/mutable-files: refactor module

This commit is contained in:
Gabriel Arazas 2024-07-10 19:24:29 +08:00
parent 96d6a446e1
commit 883138bbde
No known key found for this signature in database
GPG Key ID: 62104B43D00AA360

View File

@ -3,8 +3,12 @@
let let
cfg = config.home.mutableFile; cfg = config.home.mutableFile;
runtimeInputs = lib.makeBinPath (with pkgs; [
archiver curl git gopass
]);
# An attribute set to be used to get the fetching script. # An attribute set to be used to get the fetching script.
fetchScript = path: value: fetchScript = _: value:
let let
url = lib.escapeShellArg value.url; url = lib.escapeShellArg value.url;
path = lib.escapeShellArg value.path; path = lib.escapeShellArg value.path;
@ -177,10 +181,6 @@ in
) )
'') '')
cfg; cfg;
runtimeInputs = lib.makeBinPath (with pkgs; [
archiver curl git gopass
]);
in in
pkgs.writeShellScript "fetch-mutable-files" '' pkgs.writeShellScript "fetch-mutable-files" ''
export PATH=${runtimeInputs} export PATH=${runtimeInputs}
@ -192,14 +192,11 @@ in
mutableFilesCmds = lib.mapAttrsToList mutableFilesCmds = lib.mapAttrsToList
(path: value: value.postScript) (path: value: value.postScript)
cfg; cfg;
script = pkgs.writeShellApplication {
name = "fetch-mutable-files-post-script";
runtimeInputs = with pkgs; [ archiver curl git gopass ];
text = lib.concatStringsSep "\n" mutableFilesCmds;
};
in in
"${script}/bin/fetch-mutable-files-post-script"; pkgs.writeShellScript "fetch-mutable-files-post-script" ''
export PATH=${runtimeInputs}
${lib.concatStringsSep "\n" mutableFilesCmds}
'';
}; };
Install.WantedBy = [ "default.target" ]; Install.WantedBy = [ "default.target" ];