【问题标题】:How can I install extension of vscode?如何安装 vscode 的扩展?
【发布时间】:2019-07-15 14:27:30
【问题描述】:

这是一个初学者的问题。所以有一个包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
  ];

在里面。

【问题讨论】:

    标签: nixos nixpkgs


    【解决方案1】:

    所以,显然它可以直接进入environment.systemPackages,但需要括号:

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

    【讨论】:

      【解决方案2】:

      你应该直接在 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";
          }
        ];
      })
        ];
      

      或者,在更易读的版本中:

      environment.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
          ];
      

      【讨论】:

      • 从哪里获得 sha256?
      • 通常的方法是在其中放一个随机字符串(“0000000000000000000000000000000000000000000000000000”)然后让 nix 抱怨它,它会告诉你实际计算出来的那个
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-12-24
      • 1970-01-01
      • 1970-01-01
      • 2021-06-07
      • 2020-10-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多