repositories / dotfiles
dotfiles
bugabingas dorkfiles
owned by bugabinga
nushell/modules/package/os_path.nu
Raw# setup PATH envrionment for installed packages
use ./folders.nu
# sets PATH, so that it points to installed packages
export def --env setup-system-path [] {
let bin = (folders binaries)
match $nu.os-info.family {
'unix' => {
if ( $env.PATH | find $bin | is-empty) {
let envd = [$nu.home-path .config environment.d] | path join
if (not ($envd | path exists)) {
error make {msg: $"systemd environment.d must exist under ($envd)!"}
}
let package_conf = [$envd package.conf] | path join
if (not ($package_conf | path exists)) {
let packgage_path = $'PATH = "$PATH:($bin)"'
$packgage_path | save --raw ($package_conf)
$env | upsert PATH $bin
}
}
}
'windows' => {
if ( $env.Path | find $bin | is-empty ) {
let ps_command = $"
$newPath = [Environment]::GetEnvironmentVariable\(\"Path\", \"User\"\) + \";($bin)\"
[Environment]::SetEnvironmentVariable\(\"Path\", $newPath, \"User\"\)"
run-external powershell '-EncodedCommand' ($ps_command | endode base64)
$env | upsert Path $bin
}
}
}
null
}