100 lines
3.0 KiB
Plaintext
100 lines
3.0 KiB
Plaintext
use git.nu
|
|
use download.nu
|
|
|
|
def sshagent_loaded [ ] bool {
|
|
return ( (ssh-add -l | lines -s | length) > 0 )
|
|
}
|
|
|
|
|
|
def url_crystal [] {
|
|
let $ssha = sshagent_loaded
|
|
if $ssha {
|
|
return "git@github.com:freeflowuniverse/crystallib.git"
|
|
} else {
|
|
return "https://github.com/freeflowuniverse/crystallib"
|
|
}
|
|
}
|
|
|
|
export def clone_crystal [ --reset=false , --pull=false ] string {
|
|
let $url = url_crystal
|
|
let $r = git git_clone crystallib $url
|
|
return $r
|
|
}
|
|
|
|
export def clone_nuscripts [ --reset=false , --pull=false ] string {
|
|
let $ssha = sshagent_loaded
|
|
let $dest = $"($env.BASE)/nuscripts"
|
|
if $ssha {
|
|
let $r = git git_clone nuscripts "git@git.ourworld.tf:despiegk/nuscripts.git"
|
|
rm -f $dest
|
|
ln -s $r $dest
|
|
return $r
|
|
} else {
|
|
error make { msg: "load ssh-agent" }
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
def url_mycelium [] string {
|
|
let $os = $nu.os-info.name
|
|
let $arch = $nu.os-info.arch
|
|
if $os == "macos" {
|
|
if $arch == "aarch64" {
|
|
return "https://github.com/threefoldtech/mycelium/releases/download/v0.2.3/mycelium-aarch64-apple-darwin.tar.gz"
|
|
} else if $arch == "x86_64" {
|
|
return "https://github.com/threefoldtech/mycelium/releases/download/v0.2.3/mycelium-x86_64-apple-darwin.tar.gz"
|
|
}
|
|
} else if $os == "linux" {
|
|
if $arch == "aarch64" {
|
|
return "https://github.com/threefoldtech/mycelium/releases/download/v0.2.3/mycelium-aarch64-unknown-linux-musl.tar.gz"
|
|
} else if $arch == "x86_64" {
|
|
return "https://github.com/threefoldtech/mycelium/releases/download/v0.2.3/mycelium-x86_64-unknown-linux-musl.tar.gz"
|
|
}
|
|
} else {
|
|
error make { msg: "only support darwin & linux" }
|
|
}
|
|
}
|
|
|
|
export def install_mycelium [] {
|
|
let $name = "mycelium"
|
|
let tmppath = $"/tmp/($name)"
|
|
let $bin_dir = $"($env.BASE)/bin"
|
|
mkdir $bin_dir
|
|
let $url = url_mycelium
|
|
print $url
|
|
download download_expand $tmppath $"($url)" --minsize 2
|
|
mv -f $"($tmppath)/($name)" $"($bin_dir)/($name)"
|
|
chmod +x $"($bin_dir)/($name)"
|
|
}
|
|
|
|
|
|
def url_hero [] string {
|
|
let $os = $nu.os-info.name
|
|
let $arch = $nu.os-info.arch
|
|
if $os == "macos" {
|
|
if $arch == "aarch64" {
|
|
return "https://f003.backblazeb2.com/file/threefold/macos-arm64/hero"
|
|
} else if $arch == "x86_64" {
|
|
return "https://f003.backblazeb2.com/file/threefold/macos-i64/hero"
|
|
}
|
|
} else if $os == "linux" {
|
|
if $arch == "aarch64" {
|
|
error make { msg: "find url for hero on linux arm" }
|
|
} else if $arch == "x86_64" {
|
|
return "https://f003.backblazeb2.com/file/threefold/linux-i64/hero"
|
|
}
|
|
} else {
|
|
error make { msg: "only support darwin & linux" }
|
|
}
|
|
}
|
|
|
|
export def install_hero [] {
|
|
let $name = "hero"
|
|
let $destpath = $"($env.BASE)/bin/hero"
|
|
let $url = url_hero
|
|
print $url
|
|
download download_do $destpath $"($url)" --minsize 4
|
|
chmod +x $destpath
|
|
} |