github nix-community/nixd 2.8.0

13 hours ago

What's Changed

This version primarily focuses on enhancing primop (builtin) support in nixd.

Context: NixOS/nixpkgs#449123

New Features

Validate builtins members: (by @inclyc)
nixd now checks if a member accessed via builtins actually exists. If an unknown primop is detected, a diagnostic error is triggered.

builtins.concatStringSep 
#        ^ Error: Unknown primop

Suggest removing redundant builtins. prefixes: (by @inclyc)
For globally available primops (like map), nixd will suggest removing the builtins. prefix to keep the code concise.

builtins.map
# ^^^^^ Hint: 'map' is globally available; 'builtins.' is unnecessary.

Suggest to add builtins prefixes: (by @inclyc)

image

Give warnings when user code overrides built-in names (by @inclyc)

Special thanks to @Mic92 for the suggestion!

In the Nix language, it is possible to override (shadow) builtin names. However, this is generally considered a bad practice as it is highly error-prone. For example:

nix-repl> let
            __lessThan = a: b: true;
          in
          2 < 1
true

Now nixd will place a warning on __lessThan definition:

overriding a builtin name `__lessThan` is discouraged, rename it to avoid confusion

Bug Fixes

  • libnixf/Sema: make constants available in builtins attrset by @inclyc in #723
  • libnixf/package: fix meta.mainProgram by @jfly in #730
  • libnixf/Sema: fixes #731 by creating a trivial env for empty let-in exprs by @inclyc in #734
  • libnixf/Sema: allow inherit (builtins) var by @inclyc in #741

Documentation

Other Changes

  • nixd/Controller: clear diagnostics when removing document by @rszyma in #716
  • build(deps): bump actions/upload-artifact from 4 to 5 by @dependabot[bot] in #725
  • build(deps): bump actions/checkout from 5 to 6 by @dependabot[bot] in #729

New Contributors

🎉 Event Announcement

I’ll be giving a talk on nixd at the NixOS CN Meetup #2, slides. This session is tailored for the Chinese NixOS community, and I’m looking forward to sharing some insights with you all. 欢迎一起交流 ❤️ .

Full Changelog: 2.7.0...2.8.0

Don't miss a new nixd release

NewReleases is sending notifications on new releases.