From 883138bbde0be108b34c3dd1ee201992e2edde41 Mon Sep 17 00:00:00 2001 From: Gabriel Arazas Date: Wed, 10 Jul 2024 19:24:29 +0800 Subject: [PATCH] home-manager/files/mutable-files: refactor module --- modules/home-manager/files/mutable-files.nix | 21 +++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/modules/home-manager/files/mutable-files.nix b/modules/home-manager/files/mutable-files.nix index 9fb81e54..49046bb1 100644 --- a/modules/home-manager/files/mutable-files.nix +++ b/modules/home-manager/files/mutable-files.nix @@ -3,8 +3,12 @@ let cfg = config.home.mutableFile; + runtimeInputs = lib.makeBinPath (with pkgs; [ + archiver curl git gopass + ]); + # An attribute set to be used to get the fetching script. - fetchScript = path: value: + fetchScript = _: value: let url = lib.escapeShellArg value.url; path = lib.escapeShellArg value.path; @@ -177,10 +181,6 @@ in ) '') cfg; - - runtimeInputs = lib.makeBinPath (with pkgs; [ - archiver curl git gopass - ]); in pkgs.writeShellScript "fetch-mutable-files" '' export PATH=${runtimeInputs} @@ -192,14 +192,11 @@ in mutableFilesCmds = lib.mapAttrsToList (path: value: value.postScript) cfg; - - script = pkgs.writeShellApplication { - name = "fetch-mutable-files-post-script"; - runtimeInputs = with pkgs; [ archiver curl git gopass ]; - text = lib.concatStringsSep "\n" mutableFilesCmds; - }; 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" ];