From 2148d9bd0700464aef997cc46470ad5492f00651 Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Wed, 18 Feb 2026 13:49:42 -0500 Subject: [PATCH] feat(nix): add health --- lua/cp/health.lua | 12 +++++++++--- lua/cp/utils.lua | 7 +++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/lua/cp/health.lua b/lua/cp/health.lua index 6a3913f..d3a3fea 100644 --- a/lua/cp/health.lua +++ b/lua/cp/health.lua @@ -19,11 +19,13 @@ local function check() end if utils.is_nix_build() then - vim.health.ok('Nix-built Python environment detected') + local source = utils.is_nix_discovered() and 'runtime discovery' or 'flake install' + vim.health.ok('Nix Python environment detected (' .. source .. ')') local py = utils.get_nix_python() + vim.health.info('Python: ' .. py) local r = vim.system({ py, '--version' }, { text = true }):wait() if r.code == 0 then - vim.health.info('Python: ' .. r.stdout:gsub('\n', '')) + vim.health.info('Python version: ' .. r.stdout:gsub('\n', '')) end else if vim.fn.executable('uv') == 1 then @@ -36,6 +38,10 @@ local function check() vim.health.warn('uv not found (install https://docs.astral.sh/uv/ for scraping)') end + if vim.fn.executable('nix') == 1 then + vim.health.info('nix available but Python environment not resolved via nix') + end + local plugin_path = utils.get_plugin_path() local venv_dir = plugin_path .. '/.venv' if vim.fn.isdirectory(venv_dir) == 1 then @@ -52,7 +58,7 @@ local function check() vim.health.error('GNU time not found: ' .. (time_cap.reason or '')) end - local timeout_cap = utils.time_capability() + local timeout_cap = utils.timeout_capability() if timeout_cap.ok then vim.health.ok('GNU timeout found: ' .. timeout_cap.path) else diff --git a/lua/cp/utils.lua b/lua/cp/utils.lua index 0ac4916..0031216 100644 --- a/lua/cp/utils.lua +++ b/lua/cp/utils.lua @@ -3,6 +3,7 @@ local M = {} local logger = require('cp.log') local _nix_python = nil +local _nix_discovered = false local uname = vim.loop.os_uname() @@ -89,6 +90,10 @@ function M.get_nix_python() return _nix_python end +function M.is_nix_discovered() + return _nix_discovered +end + function M.get_python_cmd(module, plugin_path) if _nix_python then return { _nix_python, '-m', 'scrapers.' .. module } @@ -113,6 +118,7 @@ local function discover_nix_python() end local plugin_path = M.get_plugin_path() + logger.log('Building Python environment with nix...', nil, true) local result = vim .system( { 'nix', 'build', plugin_path .. '#pythonEnv', '--no-link', '--print-out-paths' }, @@ -141,6 +147,7 @@ local function discover_nix_python() end _nix_python = python_path + _nix_discovered = true return true end