From 6ab6488e5a63978e8af0c4484b6250b1d5a769ab Mon Sep 17 00:00:00 2001 From: hyperfekt Date: Mon, 19 Nov 2018 17:50:35 +0100 Subject: [PATCH] vscode: add module --- modules/misc/news.nix | 7 +++++ modules/modules.nix | 1 + modules/programs/vscode.nix | 52 +++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 modules/programs/vscode.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index a6f1efd9..403787c6 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -871,6 +871,13 @@ in A new module is available: 'services.nextcloud-client'. ''; } + + { + time = "2018-11-25T22:55:12+00:00"; + message = '' + A new module is available: 'programs.vscode'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 7a8dd453..3619d0c4 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -67,6 +67,7 @@ let ./programs/tmux.nix ./programs/urxvt.nix ./programs/vim.nix + ./programs/vscode.nix ./programs/zathura.nix ./programs/zsh.nix ./services/blueman-applet.nix diff --git a/modules/programs/vscode.nix b/modules/programs/vscode.nix new file mode 100644 index 00000000..cda18979 --- /dev/null +++ b/modules/programs/vscode.nix @@ -0,0 +1,52 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.vscode; + +in + +{ + options = { + programs.vscode = { + enable = mkEnableOption "Visual Studio Code"; + + userSettings = mkOption { + type = types.attrs; + default = {}; + example = literalExample '' + { + "update.channel" = "none"; + "[nix]"."editor.tabSize" = 2; + } + ''; + description = '' + Configuration written to + ~/.config/Code/User/settings.json. + ''; + }; + + extensions = mkOption { + type = types.listOf types.package; + default = []; + description = '' + The extensions Visual Studio Code should be started with. + These will override but not delete manually installed ones. + ''; + }; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ + (pkgs.vscode-with-extensions.override { + vscodeExtensions = cfg.extensions; + }) + ]; + + xdg.configFile."Code/User/settings.json".text = + builtins.toJSON cfg.userSettings; + }; +}