Update rsync-local-config

Now copies targets to tmp directory and removes all occurances of
/nix/.../bin/ to be compatible with target system
This commit is contained in:
Evie Litherland-Smith 2023-10-20 16:31:35 +01:00
parent dda19b7660
commit e8f6a065bd

View file

@ -210,11 +210,22 @@
} }
rsync-local-config () { rsync-local-config () {
HOST=$1 HOST=$1
for TARGET in starship.toml; do for TARGET in bat git starship.toml; do
SOURCE="${config.xdg.configHome}/$TARGET" SOURCE="${config.xdg.configHome}/$TARGET"
TMP_TARGET=/tmp/config-$TARGET
TMP_SOURCE=$TMP_TARGET
NIX_SED="${pkgs.gnused}/bin/sed -i 's|/nix/.*/bin/||g'"
NIX_REPLACE="$NIX_SED $TMP_TARGET"
if [[ -e ${config.xdg.configHome}/$TARGET ]]; then if [[ -e ${config.xdg.configHome}/$TARGET ]]; then
[[ -d $SOURCE ]] && SOURCE="$SOURCE/" if [[ -d $SOURCE ]]; then
${pkgs.rsync}/bin/rsync -avzL $SOURCE $HOST:.config/$TARGET SOURCE=$SOURCE/
TMP_SOURCE=$TMP_SOURCE/
NIX_REPLACE="${pkgs.fd}/bin/fd -g '**' $TMP_TARGET -tfile -x $NIX_SED {};"
fi
${pkgs.rsync}/bin/rsync -avzL $SOURCE /tmp/config-$TARGET
${pkgs.bash}/bin/sh -c "$NIX_REPLACE"
${pkgs.rsync}/bin/rsync -avzL $TMP_SOURCE $HOST:.config/$TARGET
${pkgs.coreutils}/bin/rm -rf $TMP_SOURCE
fi fi
done done
} }