vscode-with-extensions = pkgs.vscode-with-extensions.override {
vscodeExtensions = extensions;
};
in {
environment.systemPackages = with pkgs; [
vscode-with-extensions
];
}
I was trying to use config.vscode.vim = true/false to add or ingore vim plugin. However it does not work.
I searched some wiki page and tutorial, it mentions the option = {} is declaration however config = {} is definition. However, I found most example seems tend to use the declared option to init the already existing system options. I am not sure how to fit the case to my usage.
What the best way to add some simple Flags in configuration.nix?
{ config, pkgs, lib, ...}:
# Used to import optionals function in scope
with lib;
let
# Just to shorten the different calls
cfg = config.vscode;
extensions = (with pkgs.vscode-extensions; [
ms-vscode.cpptools
ms-python.python
]) ++ (optionals cfg.enableVim [ pkgs.vscode-extensions.vscodevim.vim ])
vscode-with-extensions = pkgs.vscode-with-extensions.override {
vscodeExtensions = extensions;
};
in
{
# Option declaration
options.vscode = {
# This helper function generates what you wrote
enableVim = mkEnableOption “vim extension for vscode”;
};
# Now the result of the configuration:
config = {
environment.systemPackages = [
vscode-with-extensions
];
}
}