repositories / dotfiles
dotfiles
bugabingas dorkfiles
owned by bugabinga
nushell/modules/package/provider.nu
Raw# Provisions a systems by installing/uninstalling packages in provisions.
# Provisions are a collection of nuon files in PACKAGE_HOME/Provsions/*.
# All files there are expected to list manifests.
# They are collected and installed.
# A precedence order for package sources will be enforced:
# packages > native packages > language packages.
# This precedence will be enforced, even if, packages need to be reinstalled.
# It depends on the availablity of packages in their given source.
use ./folders.nu
use ./environment_path.nu
use ./installer.nu
export def provision [] {
cd (folders manifests)
let manifests = ls
| get name
| str replace '.nuon' ''
| wrap manifest
| upsert action uninstall
cd (folders provisions)
let provisions = open **/*.nuon
| uniq
| wrap manifest
| upsert action install
let actions = $provisions | merge deep --strategy append $manifests | uniq-by manifest
$actions | each {
|item|
match $item.action {
'install' => {
print $'Installing ($item.manifest)'
installer install $item.manifest
}
'uninstall' => {
print $'Uninstalling ($item.manifest)'
# installer uninstall $item.manifest
}
}
}
# check if current installed packages are installed via correct source
# uninstall non-provisioned
environment_path setup
}