From 7cf15b19a931b99f9a918887fc488d577fd07516 Mon Sep 17 00:00:00 2001 From: mihnea-s <43088426+mihnea-s@users.noreply.github.com> Date: Sat, 19 Mar 2022 00:54:24 +0200 Subject: [PATCH] vscode: add user tasks (#2804) --- modules/programs/vscode.nix | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/modules/programs/vscode.nix b/modules/programs/vscode.nix index d30dee85..df1dd237 100644 --- a/modules/programs/vscode.nix +++ b/modules/programs/vscode.nix @@ -28,6 +28,7 @@ let "${config.xdg.configHome}/${configDir}/User"; configFilePath = "${userDir}/settings.json"; + tasksFilePath = "${userDir}/tasks.json"; keybindingsFilePath = "${userDir}/keybindings.json"; # TODO: On Darwin where are the extensions? @@ -70,6 +71,27 @@ in { ''; }; + userTasks = mkOption { + type = jsonFormat.type; + default = { }; + example = literalExpression '' + { + "version": "2.0.0", + "tasks": [ + { + "type": "shell", + "label": "Hello task", + "command": "hello", + } + ] + } + ''; + description = '' + Configuration written to Visual Studio Code's + tasks.json. + ''; + }; + keybindings = mkOption { type = types.listOf (types.submodule { options = { @@ -146,6 +168,10 @@ in { "${configFilePath}".source = jsonFormat.generate "vscode-user-settings" cfg.userSettings; }) + (mkIf (cfg.userTasks != { }) { + "${tasksFilePath}".source = + jsonFormat.generate "vscode-user-tasks" cfg.userTasks; + }) (mkIf (cfg.keybindings != [ ]) (let dropNullFields = filterAttrs (_: v: v != null); in {