summaryrefslogtreecommitdiffstats
path: root/tv
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2023-01-03 16:58:37 +0100
committertv <tv@krebsco.de>2023-01-03 17:01:07 +0100
commitb81598ccd93ed2583ce6e9366184992b6f41a177 (patch)
treefb8a00426c6a295d629e97bd012b196266b72215 /tv
parentab36074df19bfec95c9a88ee8dba0d5878709cc2 (diff)
tv alacritty: mkdir and cp only when needed
Diffstat (limited to 'tv')
-rw-r--r--tv/5pkgs/simple/alacritty-tv.nix29
1 files changed, 16 insertions, 13 deletions
diff --git a/tv/5pkgs/simple/alacritty-tv.nix b/tv/5pkgs/simple/alacritty-tv.nix
index d80c46cbb..fd4dec9ec 100644
--- a/tv/5pkgs/simple/alacritty-tv.nix
+++ b/tv/5pkgs/simple/alacritty-tv.nix
@@ -51,6 +51,20 @@ let
scrolling.multiplier = 8;
};
config-file = pkgs.writeJSON "alacritty-tv.json" config;
+ 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
+ export HOME
+
+ # Install stored configuration if it has changed.
+ # This allows for both declarative updates and runtime modifications.
+ ${pkgs.coreutils}/bin/mkdir -p "$HOME"
+ if test "$(${pkgs.coreutils}/bin/cat "$HOME"/ref)" != ${config-file}; then
+ echo ${config-file} > "$HOME"/ref
+ ${pkgs.coreutils}/bin/cp ${config-file} "$HOME"/.alacritty.yml
+ fi
+ '';
in
pkgs.symlinkJoin {
@@ -62,27 +76,16 @@ pkgs.symlinkJoin {
set -efu
- # Use home so Alacritty can find the configuration without arguments.
- # HOME will be reset once in Alacritty.
- HOME=$TMPDIR/Alacritty
- export HOME
-
- # Install stored configuration if it has changed.
- # This allows for both declarative updates and runtime modifications.
- ${pkgs.coreutils}/bin/mkdir -p "$HOME"
- if test "$(${pkgs.coreutils}/bin/cat "$HOME"/ref)" != ${config-file}; then
- echo ${config-file} > "$HOME"/ref
- ${pkgs.coreutils}/bin/cp ${config-file} "$HOME"/.alacritty.yml
- fi
-
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