feat(nix): add health
This commit is contained in:
parent
1162e7046b
commit
2148d9bd07
2 changed files with 16 additions and 3 deletions
|
|
@ -19,11 +19,13 @@ local function check()
|
||||||
end
|
end
|
||||||
|
|
||||||
if utils.is_nix_build() then
|
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()
|
local py = utils.get_nix_python()
|
||||||
|
vim.health.info('Python: ' .. py)
|
||||||
local r = vim.system({ py, '--version' }, { text = true }):wait()
|
local r = vim.system({ py, '--version' }, { text = true }):wait()
|
||||||
if r.code == 0 then
|
if r.code == 0 then
|
||||||
vim.health.info('Python: ' .. r.stdout:gsub('\n', ''))
|
vim.health.info('Python version: ' .. r.stdout:gsub('\n', ''))
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if vim.fn.executable('uv') == 1 then
|
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)')
|
vim.health.warn('uv not found (install https://docs.astral.sh/uv/ for scraping)')
|
||||||
end
|
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 plugin_path = utils.get_plugin_path()
|
||||||
local venv_dir = plugin_path .. '/.venv'
|
local venv_dir = plugin_path .. '/.venv'
|
||||||
if vim.fn.isdirectory(venv_dir) == 1 then
|
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 ''))
|
vim.health.error('GNU time not found: ' .. (time_cap.reason or ''))
|
||||||
end
|
end
|
||||||
|
|
||||||
local timeout_cap = utils.time_capability()
|
local timeout_cap = utils.timeout_capability()
|
||||||
if timeout_cap.ok then
|
if timeout_cap.ok then
|
||||||
vim.health.ok('GNU timeout found: ' .. timeout_cap.path)
|
vim.health.ok('GNU timeout found: ' .. timeout_cap.path)
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ local M = {}
|
||||||
local logger = require('cp.log')
|
local logger = require('cp.log')
|
||||||
|
|
||||||
local _nix_python = nil
|
local _nix_python = nil
|
||||||
|
local _nix_discovered = false
|
||||||
|
|
||||||
local uname = vim.loop.os_uname()
|
local uname = vim.loop.os_uname()
|
||||||
|
|
||||||
|
|
@ -89,6 +90,10 @@ function M.get_nix_python()
|
||||||
return _nix_python
|
return _nix_python
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function M.is_nix_discovered()
|
||||||
|
return _nix_discovered
|
||||||
|
end
|
||||||
|
|
||||||
function M.get_python_cmd(module, plugin_path)
|
function M.get_python_cmd(module, plugin_path)
|
||||||
if _nix_python then
|
if _nix_python then
|
||||||
return { _nix_python, '-m', 'scrapers.' .. module }
|
return { _nix_python, '-m', 'scrapers.' .. module }
|
||||||
|
|
@ -113,6 +118,7 @@ local function discover_nix_python()
|
||||||
end
|
end
|
||||||
|
|
||||||
local plugin_path = M.get_plugin_path()
|
local plugin_path = M.get_plugin_path()
|
||||||
|
logger.log('Building Python environment with nix...', nil, true)
|
||||||
local result = vim
|
local result = vim
|
||||||
.system(
|
.system(
|
||||||
{ 'nix', 'build', plugin_path .. '#pythonEnv', '--no-link', '--print-out-paths' },
|
{ 'nix', 'build', plugin_path .. '#pythonEnv', '--no-link', '--print-out-paths' },
|
||||||
|
|
@ -141,6 +147,7 @@ local function discover_nix_python()
|
||||||
end
|
end
|
||||||
|
|
||||||
_nix_python = python_path
|
_nix_python = python_path
|
||||||
|
_nix_discovered = true
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue