nix-community / vscode-nix-ide

Nix language support for VSCode editor [maintainer: @jnoortheen]
https://marketplace.visualstudio.com/items?itemName=jnoortheen.nix-ide
MIT License
309 stars 23 forks source link

feat: support use vscode variables in settings #399

Closed njzydark closed 3 months ago

njzydark commented 5 months ago

https://github.com/nix-community/nixd/blob/main/nixd/docs/configuration.md#where-to-place-the-configuration

According to the above document, when defining the expr of options, only absolute paths can be used. This is very inconvenient for configuring across machines. Therefore, this PR introduces the vscode-variables package to support using ${workspaceFolder} in configuration files to define paths.

before

{
    "nixd": {
      "options": {
        "nixpkgs": {
          "expr": "import <nixpkgs> { }"
        },
        "nix-darwin": {
          "expr": "(builtins.getFlake \"/absolute/path/to/flake\").darwinConfigurations.default.options"
        }
      }
    }
}

after

{
    "nixd": {
      "options": {
        "nixpkgs": {
          "expr": "import <nixpkgs> { }"
        },
        "nix-darwin": {
          "expr": "(builtins.getFlake \"${workspaceFolder}/flake\").darwinConfigurations.default.options"
        }
      }
    }
}
jnoortheen commented 3 months ago

Thanks for the contribution @njzydark !