Skip to content

Commit

Permalink
nixd/attrs-eval: do not eval real nixpkgs
Browse files Browse the repository at this point in the history
  • Loading branch information
inclyc committed Apr 17, 2024
1 parent a8154f8 commit aaa7d9b
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 48 deletions.
10 changes: 2 additions & 8 deletions nixd/tools/nixd-attrset-eval/test/attrs-completion-scope.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"jsonrpc":"2.0",
"id":0,
"method":"attrset/evalExpr",
"params": "import <nixpkgs> { }"
"params": "{ a = 1; llvmPackages = { clang = 1; clang-manpages = 1; }; }"
}
```

Expand All @@ -28,13 +28,7 @@
CHECK-NEXT: "jsonrpc": "2.0",
CHECK-NEXT: "result": [
CHECK-NEXT: "clang",
CHECK-NEXT: "clang-manpages",
CHECK-NEXT: "clang-unwrapped",
CHECK-NEXT: "clangNoCompilerRt",
CHECK-NEXT: "clangNoCompilerRtWithLibc",
CHECK-NEXT: "clangNoLibc",
CHECK-NEXT: "clangNoLibcxx",
CHECK-NEXT: "clangUseLLVM"
CHECK-NEXT: "clang-manpages"
```

```json
Expand Down
36 changes: 4 additions & 32 deletions nixd/tools/nixd-attrset-eval/test/attrs-completion.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"jsonrpc":"2.0",
"id":0,
"method":"attrset/evalExpr",
"params": "import <nixpkgs> { }"
"params": "{ py1 = 1; py2 = 2; py3 = 3; }"
}
```

Expand All @@ -27,37 +27,9 @@
CHECK: "id": 1,
CHECK-NEXT: "jsonrpc": "2.0",
CHECK-NEXT: "result": [
CHECK-NEXT: "py-spy",
CHECK-NEXT: "py3c",
CHECK-NEXT: "py65",
CHECK-NEXT: "pyCA",
CHECK-NEXT: "pycflow2dot",
CHECK-NEXT: "pycoin",
CHECK-NEXT: "pycritty",
CHECK-NEXT: "pydeps",
CHECK-NEXT: "pydf",
CHECK-NEXT: "pyditz",
CHECK-NEXT: "pyenv",
CHECK-NEXT: "pygmentex",
CHECK-NEXT: "pyinfra",
CHECK-NEXT: "pykms",
CHECK-NEXT: "pylint",
CHECK-NEXT: "pylint-exit",
CHECK-NEXT: "pyload-ng",
CHECK-NEXT: "pylode",
CHECK-NEXT: "pyls-black",
CHECK-NEXT: "pyls-mypy",
CHECK-NEXT: "pylyzer",
CHECK-NEXT: "pymol",
CHECK-NEXT: "pympress",
CHECK-NEXT: "pynac",
CHECK-NEXT: "pynitrokey",
CHECK-NEXT: "pyo3-pack",
CHECK-NEXT: "pyocd",
CHECK-NEXT: "pyotherside",
CHECK-NEXT: "pyp",
CHECK-NEXT: "pypass",
CHECK-NEXT: "pypi-mirror"
CHECK-NEXT: "py1",
CHECK-NEXT: "py2",
CHECK-NEXT: "py3"
CHECK-NEXT: ]
```

Expand Down
2 changes: 1 addition & 1 deletion nixd/tools/nixd-attrset-eval/test/attrs-info.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"jsonrpc":"2.0",
"id":0,
"method":"attrset/evalExpr",
"params": "import <nixpkgs> { }"
"params": "{ hello.meta.description = \"A program that produces a familiar, friendly greeting\"; }"
}
```

Expand Down
21 changes: 20 additions & 1 deletion nixd/tools/nixd-attrset-eval/test/option-complete.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,31 @@
# RUN: nixd-attrset-eval --lit-test < %s | FileCheck %s


```nix
{
boot.bcache.bar = 1;
boot.binfmt.bar = 1;
boot.binfmtMiscRegistrations = {
_type = "option";
description = "Alias of {option}`boot.binfmt.registrations`.";
type = {
description = "attribute set of (submodule)";
name = "attrsOf";
};
declarationPositions = [
{ column = 16; file = "/nix/store/43fgdg04gbrjh8ww8q8zgbqxn4sb35py-source/lib/attrsets.nix"; line = 190; }
];
};
}
```


```json
{
"jsonrpc":"2.0",
"id":0,
"method":"attrset/evalExpr",
"params": "(let pkgs = import <nixpkgs> { }; in (pkgs.lib.evalModules { modules = (import <nixpkgs/nixos/modules/module-list.nix>) ++ [ ({...}: { nixpkgs.hostPlatform = builtins.currentSystem;} ) ] ; })).options"
"params": "{\r\n boot.bcache.bar = 1;\r\n boot.binfmt.bar = 1;\r\n boot.binfmtMiscRegistrations = {\r\n _type = \"option\";\r\n description = \"Alias of {option}`boot.binfmt.registrations`.\";\r\n type = {\r\n description = \"attribute set of (submodule)\";\r\n name = \"attrsOf\";\r\n };\r\n declarationPositions = [\r\n { column = 16; file = \"\/nix\/store\/43fgdg04gbrjh8ww8q8zgbqxn4sb35py-source\/lib\/attrsets.nix\"; line = 190; }\r\n ];\r\n };\r\n}"
}
```

Expand Down
32 changes: 26 additions & 6 deletions nixd/tools/nixd-attrset-eval/test/option-info.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,48 @@
# RUN: nixd-attrset-eval --lit-test < %s | FileCheck %s


```nix
{
boot.bcache.bar = 1;
boot.binfmt.bar = 1;
boot.binfmtMiscRegistrations = {
_type = "option";
description = "Alias of {option}`boot.binfmt.registrations`.";
type = {
description = "attribute set of (submodule)";
name = "attrsOf";
};
declarationPositions = [
{ column = 16; file = "/nix/store/43fgdg04gbrjh8ww8q8zgbqxn4sb35py-source/lib/attrsets.nix"; line = 190; }
];
};
}
```

```json
{
"jsonrpc":"2.0",
"id":0,
"method":"attrset/evalExpr",
"params": "(let pkgs = import <nixpkgs> { }; in (pkgs.lib.evalModules { modules = (import <nixpkgs/nixos/modules/module-list.nix>) ++ [ ({...}: { nixpkgs.hostPlatform = builtins.currentSystem;} ) ] ; })).options"
"params": "{\r\n boot.bcache.bar = 1;\r\n boot.binfmt.bar = 1;\r\n boot.binfmtMiscRegistrations = {\r\n _type = \"option\";\r\n description = \"Alias of {option}`boot.binfmt.registrations`.\";\r\n type = {\r\n description = \"attribute set of (submodule)\";\r\n name = \"attrsOf\";\r\n };\r\n declarationPositions = [\r\n { column = 16; file = \"\/nix\/store\/43fgdg04gbrjh8ww8q8zgbqxn4sb35py-source\/lib\/attrsets.nix\"; line = 190; }\r\n ];\r\n };\r\n}"
}
```


```json
{
"jsonrpc":"2.0",
"id":1,
"method":"attrset/optionInfo",
"params": [ "boot", "devSize" ]
"params": [ "boot", "binfmtMiscRegistrations" ]
}
```

```
CHECK: "Description": "Size limit for the /dev tmpfs. Look at mount(8), tmpfs size option,\nfor the accepted syntax.\n",
CHECK: "Example": "32m"
CHECK: "Description": "Alias of {option}`boot.binfmt.registrations`.",
CHECK-NEXT: "Example": null,
CHECK-NEXT: "Type": {
CHECK-NEXT: "Description": "attribute set of (submodule)",
CHECK-NEXT: "Name": "attrsOf"
CHECK-NEXT: }
```

```json
Expand Down

0 comments on commit aaa7d9b

Please sign in to comment.