From c82f4b2baff11e917f7799e6a5945a7e82cf2abe Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Mon, 25 Feb 2019 12:05:20 +0100 Subject: Wrap common Tasker scripts in functions --- module/tasker.nix | 43 +++++++++++++++++++------------------------ 1 file changed, 19 insertions(+), 24 deletions(-) (limited to 'module') diff --git a/module/tasker.nix b/module/tasker.nix index 8b51d94..4f2e0fe 100644 --- a/module/tasker.nix +++ b/module/tasker.nix @@ -1,36 +1,31 @@ { pkgs, config, ... }: let + launchCommandInDirectory = dir: cmd: '' + #!/bin/sh + pushd ${dir} + exec ${cmd} + popd + ''; + launchTerminalInDirectory = dir: cmd: '' + #!/bin/sh + exec ${pkgs.kitty}/bin/kitty -d ${dir} ${cmd} + ''; + taskivations = pkgs.lib.mapAttrsToList (name: conf: let command = pkgs.writeTextFile { name = "tasker_cmd_" + name; executable = true; destination = "/bin/tasker_cmd_" + name; text = pkgs.lib.attrByPath [ conf.type ] "" { - launcher = '' - #!/bin/sh - pushd ${conf.directory} - exec ${conf.command} - popd - ''; - terminal = '' - #!/bin/sh - exec ${pkgs.kitty}/bin/kitty -d ${conf.directory} ${conf.command} - ''; - local-shell = '' - #!/bin/sh - exec ${pkgs.kitty}/bin/kitty -d ${conf.directory} nix-shell --command fish - ''; - local-editor = '' - #!/bin/sh - pushd ${conf.directory} - exec nix-shell --run 'nvim-qt --no-ext-tabline' - popd - ''; - environment = '' - #!/bin/sh - exec ${pkgs.kitty}/bin/kitty -d ${conf.directory} nix-shell \ - ${builtins.unsafeDiscardStringContext conf.environment.drvPath} --command fish + launcher = launchCommandInDirectory conf.directory conf.command; + terminal = launchTerminalInDirectory conf.directory conf.command; + + local-shell = launchTerminalInDirectory conf.directory "nix-shell --command fish"; + local-editor = launchCommandInDirectory conf.directory "nix-shell --run 'nvim-qt --no-ext-tabline'"; + + environment = launchTerminalInDirectory conf.directory '' + nix-shell ${builtins.unsafeDiscardStringContext conf.environment.drvPath} --command fish ''; }; }; -- cgit v1.2.3