如何安装vscode扩展名?

时间:2019-02-21 15:50:16

标签: nixos nixpkgs

这是一个初学者的问题。因此,有一个软件包vscode-with-extensionspackage说:

  

与编辑器一起安装的一组vscode扩展。这是一个示例:

vscode-with-extensions.override {
  # When the extension is already available in the default extensions set.
  vscodeExtensions = with vscode-extensions; [
    bbenoist.Nix
  ]
  # Concise version from the vscode market place when not available in the default set.
  ++ vscode-utils.extensionsFromVscodeMarketplace [
    {
      name = "code-runner";
      publisher = "formulahendry";
      version = "0.6.33";
      sha256 = "166ia73vrcl5c9hm4q1a73qdn56m0jc7flfsk5p5q41na9f10lb0";
    }
  ];
}

我必须在configuration.nix中的哪个位置放置此表达式?我已经有

  environment.systemPackages = with pkgs; [
     wget 
     vim 
     vscode-with-extensions
  ];

在那里。

2 个答案:

答案 0 :(得分:1)

您应该像在configuration.nix中一样直接使用它,例如

  environment.systemPackages = with pkgs; [
     wget 
     vim 
     (vscode-with-extensions.override {
  # When the extension is already available in the default extensions set.
  vscodeExtensions = with vscode-extensions; [
    bbenoist.Nix
  ]
  # Concise version from the vscode market place when not available in the default set.
  ++ vscode-utils.extensionsFromVscodeMarketplace [
    {
      name = "code-runner";
      publisher = "formulahendry";
      version = "0.6.33";
      sha256 = "166ia73vrcl5c9hm4q1a73qdn56m0jc7flfsk5p5q41na9f10lb0";
    }
  ];
})
  ];

或者,在更具可读性的版本中:

enviornment.systemPackages = with pkgs;
  let
    vcsodeWithExtension = vscode-with-extensions.override {
      # When the extension is already available in the default extensions set.
      vscodeExtensions = with vscode-extensions; [
        bbenoist.Nix
      ]
      # Concise version from the vscode market place when not available in the default set.
      ++ vscode-utils.extensionsFromVscodeMarketplace [
        {
          name = "code-runner";
          publisher = "formulahendry";
          version = "0.6.33";
          sha256 = "166ia73vrcl5c9hm4q1a73qdn56m0jc7flfsk5p5q41na9f10lb0";
        }
      ];
    })
  in
    [
      wget
      vim
      vcsodeWithExtension
    ];

答案 1 :(得分:0)

因此,显然它可以直接放入environment.systemPackages,但需要括号:

  environment.systemPackages = with pkgs; [
    wget 
    vim 
    (vscode-with-extensions.override {
      vscodeExtensions = with vscode-extensions; [
        bbenoist.Nix
      ];
    })
  ];