diff --git a/MAINTAINING.md b/MAINTAINING.md index f8970c47..0911abb3 100644 --- a/MAINTAINING.md +++ b/MAINTAINING.md @@ -13,9 +13,9 @@ Deprecations should include a comment in the format of: where: -- `n` is the current release; 25.05 at the time of writing -- `n+1` is the next release; 25.11 at the time of writing -- `n+2` is the release following `n+1`; 26.05 at the time of writing +- `n` is the current release; 25.11 at the time of writing +- `n+1` is the next release; 26.05 at the time of writing +- `n+2` is the release following `n+1`; 26.11 at the time of writing If a warning is created on release `n`, then: diff --git a/README.md b/README.md index 1a50ce24..6f87bed4 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,7 @@ If you have any question, please use the [discussions page](https://github.com/n > Nixvim needs to be installed with a compatible nixpkgs version. > This means that the `main` branch of Nixvim requires to be installed with `nixpkgs-unstable`. > -> If you want to use Nixvim with nixpkgs 25.05 you should use the `nixos-25.05` branch. +> If you want to use Nixvim with nixpkgs 25.11 you should use the `nixos-25.11` branch. For more detail, see the [Installation](https://nix-community.github.io/nixvim) section of our documentation. @@ -108,7 +108,7 @@ let nixvim = import (builtins.fetchGit { url = "https://github.com/nix-community/nixvim"; # If you are not running an unstable channel of nixpkgs, select the corresponding branch of Nixvim. - # ref = "nixos-25.05"; + # ref = "nixos-25.11"; }); in { @@ -151,7 +151,7 @@ flakes, just add the `nixvim` input: inputs.nixvim = { url = "github:nix-community/nixvim"; # If you are not running an unstable channel of nixpkgs, select the corresponding branch of Nixvim. - # url = "github:nix-community/nixvim/nixos-25.05"; + # url = "github:nix-community/nixvim/nixos-25.11"; inputs.nixpkgs.follows = "nixpkgs"; }; @@ -286,7 +286,7 @@ in pkgs.mkShell { Documentation is available on this project's GitHub Pages page: [https://nix-community.github.io/nixvim](https://nix-community.github.io/nixvim) -The stable documentation is also available at [https://nix-community.github.io/nixvim/25.05](https://nix-community.github.io/nixvim/25.05). +The stable documentation is also available at [https://nix-community.github.io/nixvim/25.11](https://nix-community.github.io/nixvim/25.11). If the option `enableMan` is set to `true` (by default it is), man pages will also be installed containing the same information, they can be viewed with `man nixvim`. diff --git a/ci/update.nix b/ci/update.nix index e4df72be..9c05e78d 100644 --- a/ci/update.nix +++ b/ci/update.nix @@ -26,86 +26,114 @@ writeShellApplication { shift done - update_args=( ) - if [ -n "$commit" ]; then - update_args+=( "--commit-lock-file" ) - fi - # Ensure we run at the root of the flake cd "$(git rev-parse --show-toplevel)" - currentCommit() { - git show --no-patch --format=%h - } + workdir=$(mktemp -d -t update-XXXXXX) + trap 'rm -rf "$workdir"' EXIT + root_update="$workdir/root_update" + dev_update="$workdir/dev_update" + root_msg="$workdir/root_msg" + dev_msg="$workdir/dev_msg" + commit_msg="$workdir/commit_msg" - hasChanges() { - old="$1" - new="$2" - if [ -n "$commit" ]; then - [ "$old" != "$new" ] - elif git diff --quiet; then - return 1 - else - return 0 - fi + cleanUpdateOutput() { + awk --assign prefix="$PWD/" ' + # Find the start of the update info block + /^warning: updating lock file "/ { + if (match($0, /"([^"]+)"/, m)) { + # Print the first line as `{path} updates:` + path = m[1] + sub("^" prefix, "", path) + print path " updates:" + + # Mark that we have entered the update info block + printing=1 + } + next + } + + # Print while in the update info block + printing { + if ($0 == "") exit + print + } + ' "$1" } writeGitHubOutput() { - if [ -n "$use_github_output" ] && [ -n "$commit" ]; then + if [ -n "$use_github_output" ]; then { echo "$1<> "$GITHUB_OUTPUT" fi } versionInfo() { - extra_args=( ) - if [ "$1" = "--amend" ]; then - extra_args+=( - "--amend" - "--no-edit" - ) - fi - + echo "Updating version-info" "$(nix-build ./ci -A version-info --no-out-link)"/bin/version-info - - if [ -n "$commit" ]; then - git add version-info.toml - git commit "''${extra_args[@]}" - fi } # Initialise version-info.toml if [ ! -f version-info.toml ]; then echo "Creating version-info file" - versionInfo -m "version-info: init" + versionInfo + if [ -n "$commit" ]; then + git add version-info.toml + git commit -m "version-info: init" + fi fi + # Commit message summary + { + # Avoid using impure global config from `nix config show commit-lock-file-summary` + nix-instantiate --raw --eval flake.nix --attr nixConfig.commit-lock-file-summary 2>/dev/null \ + || echo -n "flake: Update" + printf '\n' + } >"$commit_msg" + # Update the root lockfile - old=$(currentCommit) echo "Updating root lockfile" - nix flake update "''${update_args[@]}" - new=$(currentCommit) - if hasChanges "$old" "$new"; then - echo "Updating version-info" - versionInfo --amend - writeGitHubOutput root_lock_body + nix flake update 2> >(tee "$root_update" >&2) + cleanUpdateOutput "$root_update" > "$root_msg" + if [ -s "$root_msg" ]; then + { + printf '\n' + cat "$root_msg" + } >>"$commit_msg" + versionInfo + writeGitHubOutput root_lock_body "$root_msg" fi # Update the dev lockfile root_nixpkgs=$(nix eval --raw --file . 'inputs.nixpkgs.rev') - old=$(currentCommit) echo "Updating dev lockfile" - nix flake update "''${update_args[@]}" \ + nix flake update \ --override-input 'dev-nixpkgs' "github:NixOS/nixpkgs/$root_nixpkgs" \ - --flake './flake/dev' - new=$(currentCommit) - if hasChanges "$old" "$new"; then - echo "Updating version-info" - versionInfo --amend - writeGitHubOutput dev_lock_body + --flake './flake/dev' \ + 2> >(tee "$dev_update" >&2) + cleanUpdateOutput "$dev_update" > "$dev_msg" + if [ -s "$dev_msg" ]; then + { + printf '\n' + cat "$dev_msg" + } >>"$commit_msg" + versionInfo + writeGitHubOutput dev_lock_body "$dev_msg" + fi + + # Only commit if at least one file has changes + if git diff --quiet flake.lock flake/dev/flake.lock version-info.toml; then + echo "Nothing to commit" + elif [ -n "$commit" ]; then + echo "Committing" + git add flake.lock flake/dev/flake.lock version-info.toml + git commit --file "$commit_msg" + else + echo "Would commit as (skipping):" + cat "$commit_msg" fi ''; } diff --git a/docs/user-guide/faq.md b/docs/user-guide/faq.md index 73d9557e..1a23446d 100644 --- a/docs/user-guide/faq.md +++ b/docs/user-guide/faq.md @@ -84,7 +84,7 @@ When using Nixvim, it is possible to encounter errors about something not being ``` This usually means one of two things: -- The nixpkgs version is not in line with NixVim (for example nixpkgs nixos-25.05 is used with NixVim master) +- The nixpkgs version is not in line with NixVim (for example nixpkgs nixos-25.11 is used with NixVim master) - The nixpkgs unstable version used with NixVim is not recent enough. When building nixvim using flakes and our ["standalone mode"][standalone], we usually recommend _not_ declaring a "follows" for `inputs.nixvim`. diff --git a/docs/user-guide/install.md b/docs/user-guide/install.md index 5a373292..1e8dafbb 100644 --- a/docs/user-guide/install.md +++ b/docs/user-guide/install.md @@ -5,7 +5,7 @@ You must use a `nixpkgs` version compatible with the nixvim version you choose. The `main` branch requires to use a _very recent_ version of nixpkgs unstable. In order to guarantee the compatibility between nixvim & nixpkgs it is recommended to always update both at the same time. -When using a `stable` version you must use the corresponding nixvim branch, for example `nixos-25.05` when using NixOS 25.05. +When using a `stable` version you must use the corresponding nixvim branch, for example `nixos-25.11` when using NixOS 25.11. Failure to use the correct branch, or an old revision of nixpkgs will likely result in errors of the form `vimPlugins. attribute not found`. diff --git a/flake.lock b/flake.lock index 3c3b6be9..bc43bc2e 100644 --- a/flake.lock +++ b/flake.lock @@ -7,11 +7,11 @@ ] }, "locked": { - "lastModified": 1763759067, - "narHash": "sha256-LlLt2Jo/gMNYAwOgdRQBrsRoOz7BPRkzvNaI/fzXi2Q=", + "lastModified": 1765495779, + "narHash": "sha256-MhA7wmo/7uogLxiewwRRmIax70g6q1U/YemqTGoFHlM=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "2cccadc7357c0ba201788ae99c4dfa90728ef5e0", + "rev": "5635c32d666a59ec9a55cab87e898889869f7b71", "type": "github" }, "original": { @@ -66,11 +66,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1764338033, - "narHash": "sha256-1LNGcU+aTbATD3BPCf7U1KsP1CjCH+ZWqM6JH0sZ6Q0=", + "lastModified": 1765311797, + "narHash": "sha256-mSD5Ob7a+T2RNjvPvOA1dkJHGVrNVl8ZOrAwBjKBDQo=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "ba9b83e5fb4b552a423d24dabe5ccb47a9c89901", + "rev": "09eb77e94fa25202af8f3e81ddc7353d9970ac1b", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index cd7a9524..7a64a356 100644 --- a/flake.nix +++ b/flake.nix @@ -18,6 +18,7 @@ }; nixConfig = { + commit-lock-file-summary = "flake: Update"; extra-substituters = [ "https://nix-community.cachix.org" ]; extra-trusted-public-keys = [ "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" diff --git a/flake/dev/flake.lock b/flake/dev/flake.lock index cce40ae3..479b3028 100644 --- a/flake/dev/flake.lock +++ b/flake/dev/flake.lock @@ -2,11 +2,11 @@ "nodes": { "dev-nixpkgs": { "locked": { - "lastModified": 1764338033, - "narHash": "sha256-1LNGcU+aTbATD3BPCf7U1KsP1CjCH+ZWqM6JH0sZ6Q0=", + "lastModified": 1765311797, + "narHash": "sha256-mSD5Ob7a+T2RNjvPvOA1dkJHGVrNVl8ZOrAwBjKBDQo=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "ba9b83e5fb4b552a423d24dabe5ccb47a9c89901", + "rev": "09eb77e94fa25202af8f3e81ddc7353d9970ac1b", "type": "github" }, "original": { @@ -38,11 +38,11 @@ }, "flake-compat": { "locked": { - "lastModified": 1761588617, - "narHash": "sha256-bHDJDoMHMMctf90Ug0po2LNanPgdB8aRl0psH7+TWzc=", + "lastModified": 1765186200, + "narHash": "sha256-QN1r/zNqvXHwWqlRAnRtFf4CQwIOJx58PtdExIzAw94=", "owner": "NixOS", "repo": "flake-compat", - "rev": "01ad7ce89c455171e4f864799b21d0785ba94a3a", + "rev": "63d095ca43128741b16fc354b1e918757e6b66e5", "type": "github" }, "original": { @@ -63,11 +63,11 @@ ] }, "locked": { - "lastModified": 1763988335, - "narHash": "sha256-QlcnByMc8KBjpU37rbq5iP7Cp97HvjRP0ucfdh+M4Qc=", + "lastModified": 1765464257, + "narHash": "sha256-dixPWKiHzh80PtD0aLuxYNQ0xP+843dfXG/yM3OzaYQ=", "owner": "cachix", "repo": "git-hooks.nix", - "rev": "50b9238891e388c9fdc6a5c49e49c42533a1b5ce", + "rev": "09e45f2598e1a8499c3594fe11ec2943f34fe509", "type": "github" }, "original": { @@ -104,15 +104,16 @@ ] }, "locked": { - "lastModified": 1764361670, - "narHash": "sha256-jgWzgpIaHbL3USIq0gihZeuy1lLf2YSfwvWEwnfAJUw=", + "lastModified": 1765605144, + "narHash": "sha256-RM2xs+1HdHxesjOelxoA3eSvXShC8pmBvtyTke4Ango=", "owner": "nix-community", "repo": "home-manager", - "rev": "780be8ef503a28939cf9dc7996b48ffb1a3e04c6", + "rev": "90b62096f099b73043a747348c11dbfcfbdea949", "type": "github" }, "original": { "owner": "nix-community", + "ref": "release-25.11", "repo": "home-manager", "type": "github" } @@ -124,15 +125,16 @@ ] }, "locked": { - "lastModified": 1764161084, - "narHash": "sha256-HN84sByg9FhJnojkGGDSrcjcbeioFWoNXfuyYfJ1kBE=", + "lastModified": 1765066094, + "narHash": "sha256-0YSU35gfRFJzx/lTGgOt6ubP8K6LeW0vaywzNNqxkl4=", "owner": "lnl7", "repo": "nix-darwin", - "rev": "e95de00a471d07435e0527ff4db092c84998698e", + "rev": "688427b1aab9afb478ca07989dc754fa543e03d5", "type": "github" }, "original": { "owner": "lnl7", + "ref": "nix-darwin-25.11", "repo": "nix-darwin", "type": "github" } diff --git a/flake/dev/flake.nix b/flake/dev/flake.nix index 888e8d30..cff73fce 100644 --- a/flake/dev/flake.nix +++ b/flake/dev/flake.nix @@ -25,12 +25,12 @@ }; home-manager = { - url = "github:nix-community/home-manager"; + url = "github:nix-community/home-manager/release-25.11"; inputs.nixpkgs.follows = "dev-nixpkgs"; }; nix-darwin = { - url = "github:lnl7/nix-darwin"; + url = "github:lnl7/nix-darwin/nix-darwin-25.11"; inputs.nixpkgs.follows = "dev-nixpkgs"; }; diff --git a/modules/lsp/servers/default.nix b/modules/lsp/servers/default.nix index b0293b6f..3427f81d 100644 --- a/modules/lsp/servers/default.nix +++ b/modules/lsp/servers/default.nix @@ -40,10 +40,10 @@ let # Get suboptions of `lsp.servers.` (opts: opts.${name}.type.getSubOptions opts.${name}.loc) # Get the default package - (opts: opts.package.default or null) - # The default throws if mkPackageOption can't find the package - # E.g. mismatched nixpkgs revision - (package: (builtins.tryEval package).value) + # + # Use tryEval to catch throws when mkPackageOption can't find the package, + # e.g., due to a mismatched nixpkgs revision + (opts: (builtins.tryEval (opts.package.default or null)).value) # Get package's homepage (package: package.meta.homepage or null) ]; diff --git a/modules/misc/default.nix b/modules/misc/default.nix index 84c80418..f2d4ca71 100644 --- a/modules/misc/default.nix +++ b/modules/misc/default.nix @@ -4,5 +4,6 @@ ./context.nix ./meta.nix ./nixvim-info.nix + ./version.nix ]; } diff --git a/modules/misc/version.nix b/modules/misc/version.nix new file mode 100644 index 00000000..98c13240 --- /dev/null +++ b/modules/misc/version.nix @@ -0,0 +1,74 @@ +{ + lib, + pkgs, + config, + options, + ... +}: +let + versionInfo = lib.importTOML ../../version-info.toml; +in +{ + options.version = { + release = lib.mkOption { + type = lib.types.str; + default = versionInfo.release; + description = "The Nixvim release."; + internal = true; + readOnly = true; + }; + + isUnstable = lib.mkOption { + type = lib.types.bool; + default = versionInfo.unstable; + description = "Whether Nixvim is from an unstable branch."; + internal = true; + readOnly = true; + }; + + enableNixpkgsReleaseCheck = lib.mkOption { + type = lib.types.bool; + default = true; + example = false; + description = '' + Whether to check for release version mismatch between Nixvim and Nixpkgs. + + Using mismatched versions is likely to cause errors and unexpected behavior. + It is highly recommended to use corresponding Nixvim and Nixpkgs releases. + + When this option is enabled and a mismatch is detected, + a warning will be printed when the Nixvim configuration is evaluated. + ''; + }; + + }; + + config = { + warnings = + let + nixvimRelease = config.version.release; + libRelease = lib.trivial.release; + pkgsRelease = pkgs.lib.trivial.release; + releaseMismatch = nixvimRelease != libRelease || nixvimRelease != pkgsRelease; + in + lib.optional (config.version.enableNixpkgsReleaseCheck && releaseMismatch) '' + You are using${ + if libRelease == pkgsRelease then + " Nixvim version ${nixvimRelease} and Nixpkgs version ${libRelease}." + else + '' + : + - Nixvim version: ${nixvimRelease} + - Nixpkgs version used to evaluate Nixvim: ${libRelease} + - Nixpkgs version used for packages (`pkgs`): ${pkgsRelease}'' + } + + Using mismatched versions is likely to cause errors and unexpected behavior. + It is highly recommended to use corresponding Nixvim and Nixpkgs releases. + + If you insist, you can disable this warning using: + + ${options.version.enableNixpkgsReleaseCheck} = false; + ''; + }; +} diff --git a/modules/top-level/files/default.nix b/modules/top-level/files/default.nix index ef4a912e..f2fc052f 100644 --- a/modules/top-level/files/default.nix +++ b/modules/top-level/files/default.nix @@ -77,7 +77,7 @@ in # A directory with all the files in it # Implementation based on NixOS's /etc module - build.extraFiles = pkgs.runCommandLocal "nvim-config" { } '' + build.extraFiles = pkgs.runCommandLocal "nvim-config" { passthru.vimPlugin = true; } '' set -euo pipefail makeEntry() { diff --git a/plugins/by-name/friendly-snippets/default.nix b/plugins/by-name/friendly-snippets/default.nix index ae345036..baf160cf 100644 --- a/plugins/by-name/friendly-snippets/default.nix +++ b/plugins/by-name/friendly-snippets/default.nix @@ -27,7 +27,9 @@ lib.nixvim.plugins.mkVimPlugin { { when = config.performance.combinePlugins.enable - && !(builtins.elem "friendly-snippets" config.performance.combinePlugins.standalonePlugins) + && !(builtins.elem "friendly-snippets" ( + map lib.getName config.performance.combinePlugins.standalonePlugins + )) && (enabledConsumers != [ ]); message = '' When using ${options.performance.combinePlugins.enable}, ${options.plugins.friendly-snippets.enable} and ${enabledConsumersPretty}: diff --git a/tests/nixpkgs-module.nix b/tests/nixpkgs-module.nix index 0eea61da..39e5f768 100644 --- a/tests/nixpkgs-module.nix +++ b/tests/nixpkgs-module.nix @@ -24,6 +24,7 @@ let runNvim = false; runCommand = runCommandLocal; }; + version.enableNixpkgsReleaseCheck = false; } ../modules/misc ../modules/top-level/test.nix diff --git a/tests/test-sources/modules/lsp.nix b/tests/test-sources/modules/lsp.nix index ea6c36bb..7bdaee08 100644 --- a/tests/test-sources/modules/lsp.nix +++ b/tests/test-sources/modules/lsp.nix @@ -1,3 +1,4 @@ +{ pkgs }: { example = { lsp.servers = { @@ -254,4 +255,51 @@ } ]; }; + + # Regression test for mkServerOption: + # Ensures tryEval catches missing packages when evaluating the description. + # See https://github.com/nix-community/nixvim/issues/4033 + missing-package = + { lib, options, ... }: + let + # `lsp.servers.lua_ls` option + serverOpt = lib.pipe options.lsp.servers [ + (opt: opt.type.getSubOptions opt.loc) + (opts: opts.lua_ls) + ]; + + # `lsp.servers.lua_ls.package` option + packageOpt = (serverOpt.type.getSubOptions serverOpt.loc).package; + + # The lua_ls package attr to remove from pkgs + packageName = lib.pipe ../../../plugins/lsp/lsp-packages.nix [ + import + (lib.getAttr "packages") + (lib.getAttr "lua_ls") + lib.toList + lib.head + ]; + in + { + # Remove lua_ls's package + _module.args.pkgs = lib.mkOverride 0 (lib.removeAttrs pkgs [ packageName ]); + + assertions = [ + { + # Expect the lua_ls description to evaluate without a link + assertion = serverOpt.description == "The lua_ls language server.\n"; + message = '' + Wrong description for `${serverOpt}`. Found: + ${serverOpt.description} + ''; + } + { + # Expect the package default to throw + assertion = !(builtins.tryEval packageOpt.default).success; + message = "Expected `${packageOpt}`'s default to throw."; + } + ]; + + test.buildNixvim = false; + }; } diff --git a/tests/test-sources/modules/version.nix b/tests/test-sources/modules/version.nix new file mode 100644 index 00000000..d88f204c --- /dev/null +++ b/tests/test-sources/modules/version.nix @@ -0,0 +1,44 @@ +{ pkgs }: +{ + invalid-pkgs = + { lib, config, ... }: + let + versionInfo = lib.importTOML ../../../version-info.toml; + nixvimRelease = versionInfo.release; + pkgsRelease = ""; + in + { + # The test-suite uses `pkgs = mkForce`, so override it. + # Overlay `pkgs` with an invalid `release`: + _module.args.pkgs = lib.mkOverride 0 ( + pkgs.extend ( + final: prev: { + lib = prev.lib.extend ( + final: prev: { + trivial = prev.trivial // { + release = pkgsRelease; + }; + } + ); + } + ) + ); + + test.warnings = expect: [ + (expect "count" 1) + (expect "any" "You are using:") + (expect "any" "- Nixvim version: ${nixvimRelease}") + (expect "any" "- Nixpkgs version used to evaluate Nixvim: ${nixvimRelease}") + (expect "any" "- Nixpkgs version used for packages (`pkgs`): ${pkgsRelease}") + (expect "any" "If you insist, you can disable this warning using:") + (expect "any" " version.enableNixpkgsReleaseCheck = false;") + ]; + + assertions = [ + { + assertion = config.version.release == nixvimRelease; + message = "Expected `config.version.release` to be ${nixvimRelease}, found ${config.version.release}"; + } + ]; + }; +} diff --git a/version-info.toml b/version-info.toml index 787d4c3a..ae64a2b8 100644 --- a/version-info.toml +++ b/version-info.toml @@ -1,18 +1,18 @@ # DO NOT MODIFY! # This file was generated by ci/version-info/default.nix -nixpkgs_rev = "ba9b83e5fb4b552a423d24dabe5ccb47a9c89901" +nixpkgs_rev = "09eb77e94fa25202af8f3e81ddc7353d9970ac1b" release = "25.11" unstable = false [versions."25.05"] branch = "nixos-25.05" channel = "nixos-25.05" -status = "stable" +status = "deprecated" [versions."25.11"] branch = "nixos-25.11" channel = "nixos-25.11" -status = "beta" +status = "stable" [versions."26.05"] branch = "main"