Add silo utils
parent
a16f0d496b
commit
78ee26fc1b
@ -1,35 +1,23 @@
|
||||
package.path = package.path .. ";../?.lua"
|
||||
local silo = require 'silo'
|
||||
local utils = require 'utils'
|
||||
local log = require 'log'
|
||||
local sutils = require "silo-utils"
|
||||
|
||||
local config = {
|
||||
local config = sutils.enhance_dircfg {
|
||||
path = silo.dirs.config,
|
||||
mode = "exclude",
|
||||
exclude = {},
|
||||
}
|
||||
|
||||
local function not_installed(program)
|
||||
return utils.nu ("which "..program.." | is-empty") == "true\n"
|
||||
end
|
||||
|
||||
local function needs(program, glob)
|
||||
if not_installed(program) then
|
||||
table.insert(config.exclude, glob)
|
||||
end
|
||||
end
|
||||
|
||||
needs("broot", "broot")
|
||||
needs("firecfg", "firejail")
|
||||
needs("btm", "bottom")
|
||||
needs("helix", "helix")
|
||||
needs("home-manager", "home-manager")
|
||||
needs("nix", "nixpkgs")
|
||||
needs("nu", "nushell")
|
||||
needs("systemctl", "systemd")
|
||||
needs("wezterm", "wezterm")
|
||||
needs("zellij", "zellij")
|
||||
needs("starship", "starship")
|
||||
|
||||
log.debug(config)
|
||||
config:needs("broot", "broot")
|
||||
config:needs("firecfg", "firejail")
|
||||
config:needs("btm", "bottom")
|
||||
config:needs("helix", "helix")
|
||||
config:needs("home-manager", "home-manager")
|
||||
config:needs("nix", "nixpkgs")
|
||||
config:needs("nu", "nushell")
|
||||
config:needs("systemctl", "systemd")
|
||||
config:needs("wezterm", "wezterm")
|
||||
config:needs("zellij", "zellij")
|
||||
config:needs("starship", "starship")
|
||||
|
||||
return config
|
||||
|
@ -0,0 +1,25 @@
|
||||
local utils = require 'utils'
|
||||
|
||||
-- dirconfig
|
||||
|
||||
local function not_installed(program)
|
||||
return utils.nu("which " .. program .. " | is-empty") == "true\n"
|
||||
end
|
||||
|
||||
local function needs(config, program, glob)
|
||||
if not_installed(program) then
|
||||
table.insert(config.exclude, glob)
|
||||
end
|
||||
end
|
||||
|
||||
local function enhanced_dircfg(config)
|
||||
setmetatable(config, { __index = { needs = needs } })
|
||||
return config
|
||||
end
|
||||
|
||||
|
||||
return {
|
||||
not_installed = not_installed,
|
||||
needs = needs,
|
||||
enhance_dircfg = enhanced_dircfg,
|
||||
}
|
Loading…
Reference in New Issue