feat(nix): add health

This commit is contained in:
Barrett Ruth 2026-02-18 13:49:42 -05:00 committed by Barrett Ruth
parent 1162e7046b
commit 2148d9bd07
2 changed files with 16 additions and 3 deletions

View file

@ -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

View file

@ -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