tv alacritty: mkdir and cp only when needed

This commit is contained in:
tv 2023-01-03 16:58:37 +01:00
parent ab36074df1
commit b81598ccd9

View file

@ -51,17 +51,7 @@ let
scrolling.multiplier = 8;
};
config-file = pkgs.writeJSON "alacritty-tv.json" config;
in
pkgs.symlinkJoin {
name = "alacritty-tv";
paths = [
(pkgs.writeDashBin "alacritty" ''
# usage:
# alacritty [--singleton] [ARGS...]
set -efu
profile = pkgs.writeText "alacritty-tv.profile" /* sh */ ''
# Use home so Alacritty can find the configuration without arguments.
# HOME will be reset once in Alacritty.
HOME=$TMPDIR/Alacritty
@ -74,15 +64,28 @@ pkgs.symlinkJoin {
echo ${config-file} > "$HOME"/ref
${pkgs.coreutils}/bin/cp ${config-file} "$HOME"/.alacritty.yml
fi
'';
in
pkgs.symlinkJoin {
name = "alacritty-tv";
paths = [
(pkgs.writeDashBin "alacritty" ''
# usage:
# alacritty [--singleton] [ARGS...]
set -efu
case ''${1-} in
--singleton)
shift
if ! ${pkgs.alacritty}/bin/alacritty msg create-window "$@"; then
. ${profile}
${pkgs.alacritty}/bin/alacritty "$@" &
fi
;;
*)
. ${profile}
exec ${pkgs.alacritty}/bin/alacritty "$@"
;;
esac